Skip to content

Commit 13d2a6d

Browse files
ajout dayjs pluggin & objectId utils
1 parent 85c4c5c commit 13d2a6d

File tree

5 files changed

+41
-17
lines changed

5 files changed

+41
-17
lines changed

app/nuxt.config.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import pugPlugin from 'vite-plugin-pug'
33
import openapiTS from 'openapi-typescript'
44
import { writeFileSync } from 'fs'
55
import { resolve } from 'path'
6+
import timezone from 'dayjs/plugin/timezone'
67

78
const TK_APP_API_URL = process.env.TK_APP_API_URL || 'http://localhost:7100'
89

@@ -73,6 +74,17 @@ export default defineNuxtConfig({
7374
},
7475
},
7576
},
77+
dayjs: {
78+
locales: ['fr', 'en'],
79+
defaultLocale: 'fr',
80+
defaultTimezone: 'Paris',
81+
plugins: ['timezone', 'relativeTime']
82+
},
83+
pinia:{
84+
autoImports: [
85+
'defineStore'
86+
]
87+
},
7688
appConfig: {
7789
customSlots: {},
7890
},

app/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,19 @@
1717
"@pinia/nuxt": "^0.4.11",
1818
"@quasar/extras": "^1.16.6",
1919
"@vueuse/router": "^10.4.1",
20+
"bson-objectid": "^2.0.4",
2021
"cookie": "^0.5.0",
2122
"pinia": "^2.1.6",
2223
"quasar": "^2.12.6"
2324
},
2425
"devDependencies": {
2526
"@nuxt/devtools": "latest",
2627
"@types/node": "^18.17.3",
28+
"@typescript-eslint/eslint-plugin": "^6.6.0",
29+
"@typescript-eslint/parser": "^6.6.0",
2730
"@vueuse/core": "^10.4.1",
2831
"@vueuse/nuxt": "^10.4.1",
2932
"dayjs-nuxt": "^1.1.2",
30-
"@typescript-eslint/eslint-plugin": "^6.6.0",
31-
"@typescript-eslint/parser": "^6.6.0",
3233
"eslint": "^8.49.0",
3334
"nuxt": "~3.6.5",
3435
"nuxt-quasar-ui": "^2.0.5",

app/src/plugins/daysjs.plugin.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { defineNuxtPlugin } from "#app/nuxt";
2+
import timezone from 'dayjs/plugin/timezone'
3+
import relativeTime from 'dayjs/plugin/relativeTime'
4+
5+
export default defineNuxtPlugin(() => {
6+
const dayjs = useDayjs()
7+
dayjs.extend(timezone)
8+
dayjs.extend(relativeTime)
9+
})

app/src/utils/mongoId.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import ObjectId from 'bson-objectid'
2+
3+
export function generateMongoId(id: string = '') {
4+
if (id) {
5+
return new ObjectId(id)
6+
}
7+
return new ObjectId()
8+
}

yarn.lock

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3770,6 +3770,11 @@ bser@2.1.1:
37703770
dependencies:
37713771
node-int64 "^0.4.0"
37723772

3773+
bson-objectid@^2.0.4:
3774+
version "2.0.4"
3775+
resolved "https://registry.yarnpkg.com/bson-objectid/-/bson-objectid-2.0.4.tgz#339211572ef97dc98f2d68eaee7b99b7be59a089"
3776+
integrity sha512-vgnKAUzcDoa+AeyYwXCoHyF2q6u/8H46dxu5JN+4/TZeq/Dlinn0K6GvxsCLb3LHUJl0m/TLiEK31kUwtgocMQ==
3777+
37733778
bson@^5.4.0:
37743779
version "5.4.0"
37753780
resolved "https://registry.yarnpkg.com/bson/-/bson-5.4.0.tgz#0eea77276d490953ad8616b483298dbff07384c6"
@@ -4864,7 +4869,7 @@ esbuild@^0.17.5:
48644869
"@esbuild/win32-ia32" "0.17.19"
48654870
"@esbuild/win32-x64" "0.17.19"
48664871

4867-
esbuild@^0.18.10, esbuild@^0.18.11, esbuild@~0.18.20:
4872+
esbuild@^0.18.11, esbuild@~0.18.20:
48684873
version "0.18.20"
48694874
resolved "https://registry.yarnpkg.com/esbuild/-/esbuild-0.18.20.tgz#4709f5a34801b43b799ab7d6d82f7284a9b7a7a6"
48704875
integrity sha512-ceqxoedUrcayh7Y7ZX6NdbbDzGROiyVBgC4PriJThBKSVPWnnFHZAkfI1lJT8QFkOwH4qOS2SJkS4wvpGl8BpA==
@@ -8961,7 +8966,7 @@ postcss-value-parser@^4.0.0, postcss-value-parser@^4.2.0:
89618966
resolved "https://registry.yarnpkg.com/postcss-value-parser/-/postcss-value-parser-4.2.0.tgz#723c09920836ba6d3e5af019f92bc0971c02e514"
89628967
integrity sha512-1NNCs6uurfkVbeXG4S8JFT9t19m45ICnif8zWLd5oPSZ50QnwMfK+H3jv408d4jw/7Bttv5axS5IiHoLaVNHeQ==
89638968

8964-
postcss@^8.1.10, postcss@^8.4.23, postcss@^8.4.24, postcss@^8.4.27, postcss@^8.4.29:
8969+
postcss@^8.1.10, postcss@^8.4.23, postcss@^8.4.24, postcss@^8.4.29:
89658970
version "8.4.29"
89668971
resolved "https://registry.yarnpkg.com/postcss/-/postcss-8.4.29.tgz#33bc121cf3b3688d4ddef50be869b2a54185a1dd"
89678972
integrity sha512-cbI+jaqIeu/VGqXEarWkRCCffhjgXc0qjBtXpqJhTBohMUjUQnbBr0xqX3vEKudc4iviTewcJo5ajcec5+wdJw==
@@ -9485,7 +9490,7 @@ rollup-plugin-visualizer@^5.9.2:
94859490
source-map "^0.7.4"
94869491
yargs "^17.5.1"
94879492

9488-
rollup@^3.21.0, rollup@^3.27.1, rollup@^3.29.0:
9493+
rollup@^3.21.0, rollup@^3.29.0:
94899494
version "3.29.1"
94909495
resolved "https://registry.yarnpkg.com/rollup/-/rollup-3.29.1.tgz#ba53a179d46ac3cd79e162dca6ab70d93cd26f78"
94919496
integrity sha512-c+ebvQz0VIH4KhhCpDsI+Bik0eT8ZFEVZEYw0cGMVqIP8zc+gnwl7iXCamTw7vzv2MeuZFZfdx5JJIq+ehzDlg==
@@ -10732,18 +10737,7 @@ vite-plugin-vue-inspector@^3.6.0:
1073210737
magic-string "^0.30.0"
1073310738
shell-quote "^1.8.0"
1073410739

10735-
"vite@^3.0.0 || ^4.0.0", vite@^4.4.9:
10736-
version "4.4.9"
10737-
resolved "https://registry.yarnpkg.com/vite/-/vite-4.4.9.tgz#1402423f1a2f8d66fd8d15e351127c7236d29d3d"
10738-
integrity sha512-2mbUn2LlUmNASWwSCNSJ/EG2HuSRTnVNaydp6vMCm5VIqJsjMfbIWtbH2kDuwUVW5mMUKKZvGPX/rqeqVvv1XA==
10739-
dependencies:
10740-
esbuild "^0.18.10"
10741-
postcss "^8.4.27"
10742-
rollup "^3.27.1"
10743-
optionalDependencies:
10744-
fsevents "~2.3.2"
10745-
10746-
vite@~4.3.9:
10740+
vite@4.3.9, "vite@^3.0.0 || ^4.0.0", vite@^4.4.9, vite@~4.3.9:
1074710741
version "4.3.9"
1074810742
resolved "https://registry.yarnpkg.com/vite/-/vite-4.3.9.tgz#db896200c0b1aa13b37cdc35c9e99ee2fdd5f96d"
1074910743
integrity sha512-qsTNZjO9NoJNW7KnOrgYwczm0WctJ8m/yqYAMAK9Lxt4SoySUfS5S8ia9K7JHpa3KEeMfyF8LoJ3c5NeBJy6pg==

0 commit comments

Comments
 (0)