create-aomex 0.0.21 → 0.0.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +16 -16
- package/templates/README.md +1 -0
- package/templates/src/cli.ts +1 -1
- package/templates/src/i18n/index.ts +10 -0
- package/templates/src/i18n/locales/en-us.ts +6 -0
- package/templates/src/i18n/locales/index.ts +7 -0
- package/templates/src/i18n/locales/zh-cn.ts +18 -0
- package/templates/src/routers/hello.router.ts +2 -1
- package/templates/src/web.ts +7 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-aomex",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.23",
|
|
4
4
|
"repository": "git@github.com:aomex/create-aomex.git",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -31,26 +31,26 @@
|
|
|
31
31
|
"bin": "dist/index.js",
|
|
32
32
|
"packageManager": "pnpm@9.4.0",
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@aomex/console": "^3.2.
|
|
35
|
-
"@aomex/core": "^3.2.
|
|
34
|
+
"@aomex/console": "^3.2.3",
|
|
35
|
+
"@aomex/core": "^3.2.3",
|
|
36
36
|
"@inquirer/prompts": "^6.0.1",
|
|
37
37
|
"lodash.kebabcase": "^4.1.1",
|
|
38
38
|
"yargs-parser": "^21.1.1"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
|
-
"@aomex/async-trace": "^3.2.
|
|
42
|
-
"@aomex/cache": "^3.2.
|
|
43
|
-
"@aomex/cache-redis-adapter": "^3.2.
|
|
44
|
-
"@aomex/compress": "^3.2.
|
|
45
|
-
"@aomex/cors": "^3.2.
|
|
46
|
-
"@aomex/cron": "^3.2.
|
|
47
|
-
"@aomex/etag": "^3.2.
|
|
48
|
-
"@aomex/helmet": "^3.2.
|
|
49
|
-
"@aomex/http-logger": "^3.2.
|
|
50
|
-
"@aomex/openapi": "^3.2.
|
|
51
|
-
"@aomex/response-time": "^3.2.
|
|
52
|
-
"@aomex/swagger-ui": "^3.2.
|
|
53
|
-
"@aomex/web": "^3.2.
|
|
41
|
+
"@aomex/async-trace": "^3.2.3",
|
|
42
|
+
"@aomex/cache": "^3.2.3",
|
|
43
|
+
"@aomex/cache-redis-adapter": "^3.2.3",
|
|
44
|
+
"@aomex/compress": "^3.2.3",
|
|
45
|
+
"@aomex/cors": "^3.2.3",
|
|
46
|
+
"@aomex/cron": "^3.2.3",
|
|
47
|
+
"@aomex/etag": "^3.2.3",
|
|
48
|
+
"@aomex/helmet": "^3.2.3",
|
|
49
|
+
"@aomex/http-logger": "^3.2.3",
|
|
50
|
+
"@aomex/openapi": "^3.2.3",
|
|
51
|
+
"@aomex/response-time": "^3.2.3",
|
|
52
|
+
"@aomex/swagger-ui": "^3.2.3",
|
|
53
|
+
"@aomex/web": "^3.2.3",
|
|
54
54
|
"@prisma/client": "^5.17.0",
|
|
55
55
|
"@types/lodash.kebabcase": "^4.1.9",
|
|
56
56
|
"@types/node": "^20.14.12",
|
package/templates/README.md
CHANGED
package/templates/src/cli.ts
CHANGED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { I18n } from '@aomex/core';
|
|
2
|
+
|
|
3
|
+
export const zh = I18n.define({
|
|
4
|
+
hello: I18n.message('你好,世界。{{count}}', {
|
|
5
|
+
count: {
|
|
6
|
+
type: 'plural',
|
|
7
|
+
plural: {
|
|
8
|
+
'1': '这是你第一次访问',
|
|
9
|
+
'2-4': '你表现的很熟练',
|
|
10
|
+
'n': '你是个老司机',
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
}),
|
|
14
|
+
button: {
|
|
15
|
+
ok: '确定',
|
|
16
|
+
cancel: '取消',
|
|
17
|
+
},
|
|
18
|
+
});
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { rule } from '@aomex/core';
|
|
2
2
|
import { response, Router } from '@aomex/web';
|
|
3
3
|
import { hello } from '@middleware/hello.middleware';
|
|
4
|
+
import { i18n } from '../i18n';
|
|
4
5
|
|
|
5
6
|
export const router = new Router();
|
|
6
7
|
|
|
@@ -13,6 +14,6 @@ router.get('/', {
|
|
|
13
14
|
}),
|
|
14
15
|
],
|
|
15
16
|
action: (ctx) => {
|
|
16
|
-
ctx.send(
|
|
17
|
+
ctx.send(`${i18n.t('hello', { count: ctx.visitCount })}`);
|
|
17
18
|
},
|
|
18
19
|
});
|
package/templates/src/web.ts
CHANGED
|
@@ -8,10 +8,16 @@ import { responseTime } from '@aomex/response-time';
|
|
|
8
8
|
import { traceMiddleware } from '@aomex/async-trace';
|
|
9
9
|
import { swaggerUI } from '@aomex/swagger-ui';
|
|
10
10
|
import { generateOpenapi } from '@aomex/openapi';
|
|
11
|
+
import { I18n, middleware } from '@aomex/core';
|
|
11
12
|
|
|
12
13
|
export const app = new WebApp({
|
|
13
|
-
|
|
14
|
+
language: 'zh_CN',
|
|
14
15
|
mount: [
|
|
16
|
+
middleware.web((ctx, next) => {
|
|
17
|
+
// 动态选择i18n语言包
|
|
18
|
+
const language = ctx.request.accept.language()[0] || 'zh_CN';
|
|
19
|
+
return I18n.provider(language, next);
|
|
20
|
+
}),
|
|
15
21
|
httpLogger(),
|
|
16
22
|
responseTime,
|
|
17
23
|
traceMiddleware('生命周期', async (_record) => {
|