create-aomex 0.0.79 → 0.0.81
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 +1 -1
- package/templates/docker-compose.yml +13 -4
- package/templates/src/cli.ts +3 -3
- package/templates/src/routers/user.router.ts +2 -2
- package/templates/src/services/cache.service.ts +1 -1
- package/templates/src/services/prisma.ts +2 -10
- package/templates/src/web.ts +11 -6
- package/templates/tsconfig.json +1 -9
package/package.json
CHANGED
|
@@ -2,17 +2,26 @@ services:
|
|
|
2
2
|
mysql:
|
|
3
3
|
image: mysql:8.4
|
|
4
4
|
environment:
|
|
5
|
-
MYSQL_ROOT_PASSWORD:
|
|
5
|
+
MYSQL_ROOT_PASSWORD: "abcde"
|
|
6
6
|
# 修改后需要同步修改.env里的参数
|
|
7
|
-
MYSQL_DATABASE:
|
|
7
|
+
MYSQL_DATABASE: "{{projectName}}"
|
|
8
8
|
volumes:
|
|
9
9
|
- ./volumes/mysql:/var/lib/mysql
|
|
10
10
|
ports:
|
|
11
11
|
- 3306:3306
|
|
12
|
-
command: --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
|
|
12
|
+
command: --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci --skip-log-bin
|
|
13
13
|
healthcheck:
|
|
14
14
|
test:
|
|
15
|
-
[
|
|
15
|
+
[
|
|
16
|
+
"CMD",
|
|
17
|
+
"mysqladmin",
|
|
18
|
+
"ping",
|
|
19
|
+
"-h",
|
|
20
|
+
"localhost",
|
|
21
|
+
"-u",
|
|
22
|
+
"root",
|
|
23
|
+
"-p$$MYSQL_ROOT_PASSWORD",
|
|
24
|
+
]
|
|
16
25
|
interval: 5s
|
|
17
26
|
timeout: 3s
|
|
18
27
|
retries: 10
|
package/templates/src/cli.ts
CHANGED
|
@@ -4,9 +4,9 @@ import { destroyServices } from '@aomex/common';
|
|
|
4
4
|
import { commanders, ConsoleApp } from '@aomex/console';
|
|
5
5
|
import { crons } from '@aomex/cron';
|
|
6
6
|
import { openapi } from '@aomex/openapi';
|
|
7
|
-
import { configs } from '
|
|
8
|
-
import { services } from '
|
|
9
|
-
import { logger } from '
|
|
7
|
+
import { configs } from '@/configs';
|
|
8
|
+
import { services } from '@/services';
|
|
9
|
+
import { logger } from '@/services/logger';
|
|
10
10
|
|
|
11
11
|
const app = new ConsoleApp({
|
|
12
12
|
language: 'zh_CN',
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { rule } from '@aomex/common';
|
|
2
2
|
import { body, response, Router } from '@aomex/web';
|
|
3
|
-
import { services } from '
|
|
4
|
-
import { prismaInput, prismaOutput } from '
|
|
3
|
+
import { services } from '@/services';
|
|
4
|
+
import { prismaInput, prismaOutput } from '@/generated/aomex/prisma';
|
|
5
5
|
|
|
6
6
|
export const router = new Router({
|
|
7
7
|
prefix: '/users',
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Service } from '@aomex/common';
|
|
2
2
|
import { Caching } from '@aomex/cache';
|
|
3
3
|
import { redisAdapter } from '@aomex/cache-redis-adapter';
|
|
4
|
-
import { configs } from '
|
|
4
|
+
import { configs } from '@/configs';
|
|
5
5
|
|
|
6
6
|
export const cache = new Caching(redisAdapter(configs.redis));
|
|
7
7
|
|
|
@@ -1,16 +1,8 @@
|
|
|
1
|
-
import { PrismaClient } from '
|
|
1
|
+
import { PrismaClient } from '@/generated/prisma/client';
|
|
2
2
|
import * as runtime from '@prisma/client/runtime/client';
|
|
3
|
-
|
|
4
3
|
import { PrismaMariaDb } from '@prisma/adapter-mariadb';
|
|
5
4
|
|
|
6
|
-
const
|
|
7
|
-
const adapter = new PrismaMariaDb({
|
|
8
|
-
host: config.hostname,
|
|
9
|
-
port: parseInt(config.port),
|
|
10
|
-
user: config.username,
|
|
11
|
-
password: config.password,
|
|
12
|
-
database: config.pathname.slice(1),
|
|
13
|
-
});
|
|
5
|
+
const adapter = new PrismaMariaDb(process.env['DATABASE_URL']!);
|
|
14
6
|
|
|
15
7
|
export const prisma = new PrismaClient({
|
|
16
8
|
adapter,
|
package/templates/src/web.ts
CHANGED
|
@@ -4,10 +4,10 @@ import { compress } from '@aomex/compress';
|
|
|
4
4
|
import { etag } from '@aomex/etag';
|
|
5
5
|
import { helmet } from '@aomex/helmet';
|
|
6
6
|
import { responseTime } from '@aomex/response-time';
|
|
7
|
-
import { swagger } from '
|
|
8
|
-
import { slowTrace } from '
|
|
9
|
-
import { httpLogger } from '
|
|
10
|
-
import { logger } from '
|
|
7
|
+
import { swagger } from '@/middleware/swagger.md';
|
|
8
|
+
import { slowTrace } from '@/middleware/slow-trace.md';
|
|
9
|
+
import { httpLogger } from '@/middleware/http-logger.md';
|
|
10
|
+
import { logger } from '@/services/logger';
|
|
11
11
|
import cluster from 'node:cluster';
|
|
12
12
|
import { cpus } from 'node:os';
|
|
13
13
|
|
|
@@ -38,11 +38,16 @@ if (cluster.isWorker) {
|
|
|
38
38
|
message: ctx.response.body,
|
|
39
39
|
};
|
|
40
40
|
});
|
|
41
|
-
app
|
|
41
|
+
app
|
|
42
|
+
.http({
|
|
43
|
+
// 对应 nginx 的 keepalive_timeout
|
|
44
|
+
keepAliveTimeout: 60_000,
|
|
45
|
+
})
|
|
46
|
+
.listen(process.env['PORT'] || 3000);
|
|
42
47
|
}
|
|
43
48
|
|
|
44
49
|
if (cluster.isPrimary) {
|
|
45
|
-
for (let i = cpus().length; i-- > 0; ) {
|
|
50
|
+
for (let i = Math.max(5, Math.min(2, cpus().length)); i-- > 0; ) {
|
|
46
51
|
cluster.fork();
|
|
47
52
|
}
|
|
48
53
|
|
package/templates/tsconfig.json
CHANGED
|
@@ -34,15 +34,7 @@
|
|
|
34
34
|
"resolveJsonModule": true,
|
|
35
35
|
"typeRoots": ["./typings", "node_modules/@types"],
|
|
36
36
|
"paths": {
|
|
37
|
-
"
|
|
38
|
-
"@configs/*": ["./src/configs/*"],
|
|
39
|
-
"@middleware/*": ["./src/middleware/*"],
|
|
40
|
-
"@services": ["./src/services/index.ts"],
|
|
41
|
-
"@services/*": ["./src/services/*"],
|
|
42
|
-
"@constants/*": ["./src/constants/*"],
|
|
43
|
-
"@models/*": ["./src/models/*"],
|
|
44
|
-
"@utils/*": ["./src/utils/*"],
|
|
45
|
-
"@generated/*": ["./src/generated/*"]
|
|
37
|
+
"@/*": ["./src/*"]
|
|
46
38
|
}
|
|
47
39
|
}
|
|
48
40
|
}
|