typescript-express-starter 8.1.3 → 9.1.0
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/README.kr.md +23 -27
- package/README.md +23 -25
- package/lib/default/Makefile +26 -3
- package/lib/default/package.json +9 -12
- package/lib/graphql/.env.development.local +2 -2
- package/lib/graphql/.env.production.local +2 -2
- package/lib/graphql/.env.test.local +2 -2
- package/lib/graphql/Makefile +26 -3
- package/lib/graphql/package.json +8 -11
- package/lib/graphql/src/app.ts +6 -3
- package/lib/graphql/src/config/index.ts +2 -1
- package/lib/graphql/src/entities/users.entity.ts +1 -1
- package/lib/graphql/src/repositories/auth.repository.ts +1 -1
- package/lib/graphql/src/repositories/users.repository.ts +1 -1
- package/lib/knex/Makefile +26 -3
- package/lib/knex/package.json +23 -26
- package/lib/mikro-orm/.dockerignore +18 -0
- package/lib/mikro-orm/.editorconfig +9 -0
- package/lib/mikro-orm/.env.development.local +18 -0
- package/lib/mikro-orm/.env.production.local +18 -0
- package/lib/mikro-orm/.env.test.local +18 -0
- package/lib/mikro-orm/.eslintignore +1 -0
- package/lib/mikro-orm/.eslintrc +18 -0
- package/lib/mikro-orm/.huskyrc +5 -0
- package/lib/mikro-orm/.lintstagedrc.json +5 -0
- package/lib/mikro-orm/.prettierrc +8 -0
- package/lib/mikro-orm/.swcrc +41 -0
- package/lib/mikro-orm/.vscode/launch.json +35 -0
- package/lib/mikro-orm/.vscode/settings.json +6 -0
- package/lib/mikro-orm/Dockerfile +24 -0
- package/lib/mikro-orm/Makefile +29 -0
- package/lib/mikro-orm/docker-compose.yml +46 -0
- package/lib/mikro-orm/ecosystem.config.js +57 -0
- package/lib/mikro-orm/jest.config.js +12 -0
- package/lib/mikro-orm/nginx.conf +40 -0
- package/lib/mikro-orm/nodemon.json +12 -0
- package/lib/mikro-orm/package.json +77 -0
- package/lib/mikro-orm/src/app.ts +98 -0
- package/lib/mikro-orm/src/config/index.ts +5 -0
- package/lib/mikro-orm/src/controllers/auth.controller.ts +46 -0
- package/lib/mikro-orm/src/controllers/index.controller.ts +13 -0
- package/lib/mikro-orm/src/controllers/users.controller.ts +65 -0
- package/lib/mikro-orm/src/databases/index.ts +19 -0
- package/lib/mikro-orm/src/dtos/users.dto.ts +9 -0
- package/lib/mikro-orm/src/entities/base.entity.ts +16 -0
- package/lib/mikro-orm/src/entities/users.entity.ts +17 -0
- package/lib/mikro-orm/src/exceptions/HttpException.ts +10 -0
- package/lib/mikro-orm/src/http/auth.http +32 -0
- package/lib/mikro-orm/src/http/users.http +34 -0
- package/lib/mikro-orm/src/interfaces/auth.interface.ts +15 -0
- package/lib/mikro-orm/src/interfaces/routes.interface.ts +6 -0
- package/lib/mikro-orm/src/interfaces/users.interface.ts +5 -0
- package/lib/mikro-orm/src/middlewares/auth.middleware.ts +32 -0
- package/lib/mikro-orm/src/middlewares/error.middleware.ts +17 -0
- package/lib/mikro-orm/src/middlewares/validation.middleware.ts +25 -0
- package/lib/mikro-orm/src/routes/auth.route.ts +24 -0
- package/lib/mikro-orm/src/routes/index.route.ts +19 -0
- package/lib/mikro-orm/src/routes/users.route.ts +25 -0
- package/lib/mikro-orm/src/server.ts +11 -0
- package/lib/mikro-orm/src/services/auth.service.ts +63 -0
- package/lib/mikro-orm/src/services/users.service.ts +68 -0
- package/lib/mikro-orm/src/tests/auth.test.ts +66 -0
- package/lib/mikro-orm/src/tests/index.test.ts +18 -0
- package/lib/mikro-orm/src/tests/users.test.ts +70 -0
- package/lib/mikro-orm/src/utils/logger.ts +65 -0
- package/lib/mikro-orm/src/utils/util.ts +19 -0
- package/lib/mikro-orm/src/utils/validateEnv.ts +10 -0
- package/lib/mikro-orm/swagger.yaml +122 -0
- package/lib/mikro-orm/tsconfig.json +41 -0
- package/lib/mongoose/Makefile +26 -3
- package/lib/mongoose/package.json +7 -10
- package/lib/prisma/Makefile +26 -3
- package/lib/prisma/package.json +7 -10
- package/lib/routing-controllers/Makefile +26 -3
- package/lib/routing-controllers/package.json +8 -10
- package/lib/sequelize/Makefile +26 -3
- package/lib/sequelize/package.json +7 -10
- package/lib/starter.js +30 -8
- package/lib/typegoose/Makefile +26 -3
- package/lib/typegoose/package.json +6 -9
- package/lib/typeorm/Makefile +26 -3
- package/lib/typeorm/package.json +6 -9
- package/package.json +6 -15
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import request from 'supertest';
|
|
2
|
+
import App from '../app';
|
|
3
|
+
import { DI } from '../databases';
|
|
4
|
+
import { CreateUserDto } from '../dtos/users.dto';
|
|
5
|
+
import UsersRoute from '../routes/users.route';
|
|
6
|
+
|
|
7
|
+
const usersRoute = new UsersRoute();
|
|
8
|
+
|
|
9
|
+
const app = new App([usersRoute]);
|
|
10
|
+
|
|
11
|
+
let userId: string;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
** MikroORM Seeding
|
|
15
|
+
** https://mikro-orm.io/docs/seeding#use-in-tests
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
beforeAll(async () => {
|
|
19
|
+
await new Promise<void>(resolve => setTimeout(() => resolve(), 500));
|
|
20
|
+
|
|
21
|
+
await DI.orm.getSchemaGenerator().refreshDatabase();
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
afterAll(async () => {
|
|
25
|
+
await DI.orm.close();
|
|
26
|
+
await new Promise<void>(resolve => setTimeout(() => resolve(), 500));
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
describe('Testing Users', () => {
|
|
30
|
+
describe('[GET] /users', () => {
|
|
31
|
+
it('response fineAll Users', async () => {
|
|
32
|
+
return request(app.getServer()).get(`${usersRoute.path}`).expect(200);
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
describe('[POST] /users', () => {
|
|
37
|
+
it('response Create User', async () => {
|
|
38
|
+
const userData: CreateUserDto = {
|
|
39
|
+
email: 'test@email.com',
|
|
40
|
+
password: 'q1w2e3r4',
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
const { body } = await request(app.getServer()).post(`${usersRoute.path}`).send(userData).expect(201);
|
|
44
|
+
userId = body.data.id;
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
describe('[GET] /users/:id', () => {
|
|
49
|
+
it('response findOne User', async () => {
|
|
50
|
+
return await request(app.getServer()).get(`${usersRoute.path}/${userId}`).expect(200);
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
describe('[PUT] /users/:id', () => {
|
|
55
|
+
it('response Update User', async () => {
|
|
56
|
+
const userData: CreateUserDto = {
|
|
57
|
+
email: 'test1@email.com',
|
|
58
|
+
password: 'q1w2e3r4',
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
return await request(app.getServer()).put(`${usersRoute.path}/${userId}`).send(userData).expect(200);
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
describe('[DELETE] /users/:id', () => {
|
|
66
|
+
it('response Delete User', async () => {
|
|
67
|
+
return request(app.getServer()).delete(`${usersRoute.path}/${userId}`).expect(200);
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
});
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { existsSync, mkdirSync } from 'fs';
|
|
2
|
+
import { join } from 'path';
|
|
3
|
+
import winston from 'winston';
|
|
4
|
+
import winstonDaily from 'winston-daily-rotate-file';
|
|
5
|
+
import { LOG_DIR } from '@config';
|
|
6
|
+
|
|
7
|
+
// logs dir
|
|
8
|
+
const logDir: string = join(__dirname, LOG_DIR);
|
|
9
|
+
|
|
10
|
+
if (!existsSync(logDir)) {
|
|
11
|
+
mkdirSync(logDir);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// Define log format
|
|
15
|
+
const logFormat = winston.format.printf(({ timestamp, level, message }) => `${timestamp} ${level}: ${message}`);
|
|
16
|
+
|
|
17
|
+
/*
|
|
18
|
+
* Log Level
|
|
19
|
+
* error: 0, warn: 1, info: 2, http: 3, verbose: 4, debug: 5, silly: 6
|
|
20
|
+
*/
|
|
21
|
+
const logger = winston.createLogger({
|
|
22
|
+
format: winston.format.combine(
|
|
23
|
+
winston.format.timestamp({
|
|
24
|
+
format: 'YYYY-MM-DD HH:mm:ss',
|
|
25
|
+
}),
|
|
26
|
+
logFormat,
|
|
27
|
+
),
|
|
28
|
+
transports: [
|
|
29
|
+
// debug log setting
|
|
30
|
+
new winstonDaily({
|
|
31
|
+
level: 'debug',
|
|
32
|
+
datePattern: 'YYYY-MM-DD',
|
|
33
|
+
dirname: logDir + '/debug', // log file /logs/debug/*.log in save
|
|
34
|
+
filename: `%DATE%.log`,
|
|
35
|
+
maxFiles: 30, // 30 Days saved
|
|
36
|
+
json: false,
|
|
37
|
+
zippedArchive: true,
|
|
38
|
+
}),
|
|
39
|
+
// error log setting
|
|
40
|
+
new winstonDaily({
|
|
41
|
+
level: 'error',
|
|
42
|
+
datePattern: 'YYYY-MM-DD',
|
|
43
|
+
dirname: logDir + '/error', // log file /logs/error/*.log in save
|
|
44
|
+
filename: `%DATE%.log`,
|
|
45
|
+
maxFiles: 30, // 30 Days saved
|
|
46
|
+
handleExceptions: true,
|
|
47
|
+
json: false,
|
|
48
|
+
zippedArchive: true,
|
|
49
|
+
}),
|
|
50
|
+
],
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
logger.add(
|
|
54
|
+
new winston.transports.Console({
|
|
55
|
+
format: winston.format.combine(winston.format.splat(), winston.format.colorize()),
|
|
56
|
+
}),
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
const stream = {
|
|
60
|
+
write: (message: string) => {
|
|
61
|
+
logger.info(message.substring(0, message.lastIndexOf('\n')));
|
|
62
|
+
},
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
export { logger, stream };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @method isEmpty
|
|
3
|
+
* @param {String | Number | Object} value
|
|
4
|
+
* @returns {Boolean} true & false
|
|
5
|
+
* @description this value is Empty Check
|
|
6
|
+
*/
|
|
7
|
+
export const isEmpty = (value: string | number | object): boolean => {
|
|
8
|
+
if (value === null) {
|
|
9
|
+
return true;
|
|
10
|
+
} else if (typeof value !== 'number' && value === '') {
|
|
11
|
+
return true;
|
|
12
|
+
} else if (typeof value === 'undefined' || value === undefined) {
|
|
13
|
+
return true;
|
|
14
|
+
} else if (value !== null && typeof value === 'object' && !Object.keys(value).length) {
|
|
15
|
+
return true;
|
|
16
|
+
} else {
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
};
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
tags:
|
|
2
|
+
- name: users
|
|
3
|
+
description: users API
|
|
4
|
+
|
|
5
|
+
paths:
|
|
6
|
+
# [GET] users
|
|
7
|
+
/users:
|
|
8
|
+
get:
|
|
9
|
+
tags:
|
|
10
|
+
- users
|
|
11
|
+
summary: Find All Users
|
|
12
|
+
responses:
|
|
13
|
+
200:
|
|
14
|
+
description: 'OK'
|
|
15
|
+
500:
|
|
16
|
+
description: 'Server Error'
|
|
17
|
+
|
|
18
|
+
# [POST] users
|
|
19
|
+
post:
|
|
20
|
+
tags:
|
|
21
|
+
- users
|
|
22
|
+
summary: Add User
|
|
23
|
+
parameters:
|
|
24
|
+
- name: body
|
|
25
|
+
in: body
|
|
26
|
+
description: user Data
|
|
27
|
+
required: true
|
|
28
|
+
schema:
|
|
29
|
+
$ref: '#/definitions/users'
|
|
30
|
+
responses:
|
|
31
|
+
201:
|
|
32
|
+
description: 'Created'
|
|
33
|
+
400:
|
|
34
|
+
description: 'Bad Request'
|
|
35
|
+
409:
|
|
36
|
+
description: 'Conflict'
|
|
37
|
+
500:
|
|
38
|
+
description: 'Server Error'
|
|
39
|
+
|
|
40
|
+
# [GET] users/id
|
|
41
|
+
/users/{id}:
|
|
42
|
+
get:
|
|
43
|
+
tags:
|
|
44
|
+
- users
|
|
45
|
+
summary: Find User By Id
|
|
46
|
+
parameters:
|
|
47
|
+
- name: id
|
|
48
|
+
in: path
|
|
49
|
+
description: User Id
|
|
50
|
+
required: true
|
|
51
|
+
responses:
|
|
52
|
+
200:
|
|
53
|
+
description: 'OK'
|
|
54
|
+
409:
|
|
55
|
+
description: 'Conflict'
|
|
56
|
+
500:
|
|
57
|
+
description: 'Server Error'
|
|
58
|
+
|
|
59
|
+
# [PUT] users/id
|
|
60
|
+
put:
|
|
61
|
+
tags:
|
|
62
|
+
- users
|
|
63
|
+
summary: Update User By Id
|
|
64
|
+
parameters:
|
|
65
|
+
- name: id
|
|
66
|
+
in: path
|
|
67
|
+
description: user Id
|
|
68
|
+
required: true
|
|
69
|
+
- name: body
|
|
70
|
+
in: body
|
|
71
|
+
description: user Data
|
|
72
|
+
required: true
|
|
73
|
+
schema:
|
|
74
|
+
$ref: '#/definitions/users'
|
|
75
|
+
responses:
|
|
76
|
+
200:
|
|
77
|
+
description: 'OK'
|
|
78
|
+
400:
|
|
79
|
+
description: 'Bad Request'
|
|
80
|
+
409:
|
|
81
|
+
description: 'Conflict'
|
|
82
|
+
500:
|
|
83
|
+
description: 'Server Error'
|
|
84
|
+
|
|
85
|
+
# [DELETE] users/id
|
|
86
|
+
delete:
|
|
87
|
+
tags:
|
|
88
|
+
- users
|
|
89
|
+
summary: Delete User By Id
|
|
90
|
+
parameters:
|
|
91
|
+
- name: id
|
|
92
|
+
in: path
|
|
93
|
+
description: user Id
|
|
94
|
+
required: true
|
|
95
|
+
responses:
|
|
96
|
+
200:
|
|
97
|
+
description: 'OK'
|
|
98
|
+
409:
|
|
99
|
+
description: 'Conflict'
|
|
100
|
+
500:
|
|
101
|
+
description: 'Server Error'
|
|
102
|
+
|
|
103
|
+
# definitions
|
|
104
|
+
definitions:
|
|
105
|
+
users:
|
|
106
|
+
type: object
|
|
107
|
+
required:
|
|
108
|
+
- email
|
|
109
|
+
- password
|
|
110
|
+
properties:
|
|
111
|
+
id:
|
|
112
|
+
description: user Id
|
|
113
|
+
email:
|
|
114
|
+
type: string
|
|
115
|
+
description: user Email
|
|
116
|
+
password:
|
|
117
|
+
type: string
|
|
118
|
+
description: user Password
|
|
119
|
+
|
|
120
|
+
schemes:
|
|
121
|
+
- https
|
|
122
|
+
- http
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compileOnSave": false,
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"target": "es2017",
|
|
5
|
+
"lib": ["es2017", "esnext.asynciterable"],
|
|
6
|
+
"typeRoots": ["node_modules/@types"],
|
|
7
|
+
"allowSyntheticDefaultImports": true,
|
|
8
|
+
"experimentalDecorators": true,
|
|
9
|
+
"emitDecoratorMetadata": true,
|
|
10
|
+
"forceConsistentCasingInFileNames": true,
|
|
11
|
+
"moduleResolution": "node",
|
|
12
|
+
"module": "commonjs",
|
|
13
|
+
"pretty": true,
|
|
14
|
+
"sourceMap": true,
|
|
15
|
+
"declaration": true,
|
|
16
|
+
"outDir": "dist",
|
|
17
|
+
"allowJs": true,
|
|
18
|
+
"noEmit": false,
|
|
19
|
+
"esModuleInterop": true,
|
|
20
|
+
"resolveJsonModule": true,
|
|
21
|
+
"importHelpers": true,
|
|
22
|
+
"baseUrl": "src",
|
|
23
|
+
"paths": {
|
|
24
|
+
"@/*": ["*"],
|
|
25
|
+
"@config": ["config"],
|
|
26
|
+
"@controllers/*": ["controllers/*"],
|
|
27
|
+
"@databases": ["databases"],
|
|
28
|
+
"@dtos/*": ["dtos/*"],
|
|
29
|
+
"@entities/*": ["entities/*"],
|
|
30
|
+
"@exceptions/*": ["exceptions/*"],
|
|
31
|
+
"@interfaces/*": ["interfaces/*"],
|
|
32
|
+
"@middlewares/*": ["middlewares/*"],
|
|
33
|
+
"@models/*": ["models/*"],
|
|
34
|
+
"@routes/*": ["routes/*"],
|
|
35
|
+
"@services/*": ["services/*"],
|
|
36
|
+
"@utils/*": ["utils/*"]
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
"include": ["src/**/*.ts", "src/**/*.json", ".env"],
|
|
40
|
+
"exclude": ["node_modules", "src/http", "src/logs", "src/tests"]
|
|
41
|
+
}
|
package/lib/mongoose/Makefile
CHANGED
|
@@ -1,6 +1,29 @@
|
|
|
1
|
+
# app name should be overridden.
|
|
2
|
+
# ex) production-stage: make build APP_NAME=<APP_NAME>
|
|
3
|
+
# ex) development-stage: make build-dev APP_NAME=<APP_NAME>
|
|
4
|
+
|
|
5
|
+
APP_NAME = typescript-express
|
|
6
|
+
APP_NAME := $(APP_NAME)
|
|
7
|
+
|
|
8
|
+
.PHONY: build
|
|
9
|
+
# Build the container image - Dvelopment
|
|
10
|
+
build-dev:
|
|
11
|
+
docker build -t ${APP_NAME}\
|
|
12
|
+
--target development-build-stage\
|
|
13
|
+
-f Dockerfile .
|
|
14
|
+
|
|
15
|
+
# Build the container image - Production
|
|
1
16
|
build:
|
|
2
|
-
docker build -t ${
|
|
17
|
+
docker build -t ${APP_NAME}\
|
|
18
|
+
--target production-build-stage\
|
|
19
|
+
-f Dockerfile .
|
|
20
|
+
|
|
21
|
+
# Clean the container image
|
|
3
22
|
clean:
|
|
4
|
-
docker rmi -f ${
|
|
23
|
+
docker rmi -f ${APP_NAME}
|
|
24
|
+
|
|
25
|
+
# Run the container image
|
|
5
26
|
run:
|
|
6
|
-
docker run -d -p
|
|
27
|
+
docker run -d -it -p 3000:3000 ${APP_NAME}
|
|
28
|
+
|
|
29
|
+
all: build
|
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
"scripts": {
|
|
8
8
|
"start": "npm run build && cross-env NODE_ENV=production node dist/server.js",
|
|
9
9
|
"dev": "cross-env NODE_ENV=development nodemon",
|
|
10
|
-
"build": "
|
|
11
|
-
"build:
|
|
10
|
+
"build": "swc src -d dist --source-maps --copy-files",
|
|
11
|
+
"build:tsc": "tsc && tsc-alias",
|
|
12
12
|
"test": "jest --forceExit --detectOpenHandles",
|
|
13
13
|
"lint": "eslint --ignore-path .gitignore --ext .ts src/",
|
|
14
14
|
"lint:fix": "npm run lint -- --fix",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
19
|
"bcrypt": "^5.0.1",
|
|
20
|
-
"class-transformer": "^0.
|
|
20
|
+
"class-transformer": "^0.5.1",
|
|
21
21
|
"class-validator": "^0.13.1",
|
|
22
22
|
"compression": "^1.7.4",
|
|
23
23
|
"cookie-parser": "^1.4.5",
|
|
@@ -42,11 +42,9 @@
|
|
|
42
42
|
"@types/compression": "^1.7.1",
|
|
43
43
|
"@types/cookie-parser": "^1.4.2",
|
|
44
44
|
"@types/cors": "^2.8.11",
|
|
45
|
-
"@types/dotenv": "^8.2.0",
|
|
46
45
|
"@types/express": "^4.17.13",
|
|
47
|
-
"@types/helmet": "^4.0.0",
|
|
48
46
|
"@types/hpp": "^0.2.1",
|
|
49
|
-
"@types/jest": "
|
|
47
|
+
"@types/jest": "27.4.x",
|
|
50
48
|
"@types/jsonwebtoken": "^8.5.4",
|
|
51
49
|
"@types/mongoose": "^5.10.1",
|
|
52
50
|
"@types/morgan": "^1.9.3",
|
|
@@ -54,7 +52,6 @@
|
|
|
54
52
|
"@types/supertest": "^2.0.11",
|
|
55
53
|
"@types/swagger-jsdoc": "^6.0.1",
|
|
56
54
|
"@types/swagger-ui-express": "^4.1.3",
|
|
57
|
-
"@types/winston": "^2.4.4",
|
|
58
55
|
"@typescript-eslint/eslint-plugin": "^4.28.2",
|
|
59
56
|
"@typescript-eslint/parser": "^4.28.2",
|
|
60
57
|
"cross-env": "^7.0.3",
|
|
@@ -62,15 +59,15 @@
|
|
|
62
59
|
"eslint-config-prettier": "^8.3.0",
|
|
63
60
|
"eslint-plugin-prettier": "^3.4.0",
|
|
64
61
|
"husky": "^7.0.1",
|
|
65
|
-
"jest": "
|
|
62
|
+
"jest": "27.4.x",
|
|
66
63
|
"lint-staged": "^11.0.0",
|
|
67
64
|
"node-config": "^0.0.2",
|
|
68
65
|
"node-gyp": "^8.1.0",
|
|
69
66
|
"nodemon": "^2.0.9",
|
|
70
67
|
"pm2": "^5.1.0",
|
|
71
68
|
"prettier": "^2.3.2",
|
|
72
|
-
"supertest": "^6.
|
|
73
|
-
"ts-jest": "^27.
|
|
69
|
+
"supertest": "^6.2.2",
|
|
70
|
+
"ts-jest": "^27.1.4",
|
|
74
71
|
"ts-node": "^10.4.0",
|
|
75
72
|
"tsc-alias": "^1.4.1",
|
|
76
73
|
"tsconfig-paths": "^3.10.1",
|
package/lib/prisma/Makefile
CHANGED
|
@@ -1,6 +1,29 @@
|
|
|
1
|
+
# app name should be overridden.
|
|
2
|
+
# ex) production-stage: make build APP_NAME=<APP_NAME>
|
|
3
|
+
# ex) development-stage: make build-dev APP_NAME=<APP_NAME>
|
|
4
|
+
|
|
5
|
+
APP_NAME = typescript-express
|
|
6
|
+
APP_NAME := $(APP_NAME)
|
|
7
|
+
|
|
8
|
+
.PHONY: build
|
|
9
|
+
# Build the container image - Dvelopment
|
|
10
|
+
build-dev:
|
|
11
|
+
docker build -t ${APP_NAME}\
|
|
12
|
+
--target development-build-stage\
|
|
13
|
+
-f Dockerfile .
|
|
14
|
+
|
|
15
|
+
# Build the container image - Production
|
|
1
16
|
build:
|
|
2
|
-
docker build -t ${
|
|
17
|
+
docker build -t ${APP_NAME}\
|
|
18
|
+
--target production-build-stage\
|
|
19
|
+
-f Dockerfile .
|
|
20
|
+
|
|
21
|
+
# Clean the container image
|
|
3
22
|
clean:
|
|
4
|
-
docker rmi -f ${
|
|
23
|
+
docker rmi -f ${APP_NAME}
|
|
24
|
+
|
|
25
|
+
# Run the container image
|
|
5
26
|
run:
|
|
6
|
-
docker run -d -p
|
|
27
|
+
docker run -d -it -p 3000:3000 ${APP_NAME}
|
|
28
|
+
|
|
29
|
+
all: build
|
package/lib/prisma/package.json
CHANGED
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
"scripts": {
|
|
8
8
|
"start": "npm run build && cross-env NODE_ENV=production node dist/server.js",
|
|
9
9
|
"dev": "cross-env NODE_ENV=development nodemon",
|
|
10
|
-
"build": "
|
|
11
|
-
"build:
|
|
10
|
+
"build": "swc src -d dist --source-maps --copy-files",
|
|
11
|
+
"build:tsc": "tsc && tsc-alias",
|
|
12
12
|
"test": "jest --forceExit --detectOpenHandles",
|
|
13
13
|
"lint": "eslint --ignore-path .gitignore --ext .ts src/",
|
|
14
14
|
"lint:fix": "npm run lint -- --fix",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"@prisma/client": "^3.7.0",
|
|
26
26
|
"bcrypt": "^5.0.1",
|
|
27
|
-
"class-transformer": "^0.
|
|
27
|
+
"class-transformer": "^0.5.1",
|
|
28
28
|
"class-validator": "^0.13.1",
|
|
29
29
|
"compression": "^1.7.4",
|
|
30
30
|
"cookie-parser": "^1.4.5",
|
|
@@ -48,18 +48,15 @@
|
|
|
48
48
|
"@types/compression": "^1.7.1",
|
|
49
49
|
"@types/cookie-parser": "^1.4.2",
|
|
50
50
|
"@types/cors": "^2.8.11",
|
|
51
|
-
"@types/dotenv": "^8.2.0",
|
|
52
51
|
"@types/express": "^4.17.13",
|
|
53
|
-
"@types/helmet": "^4.0.0",
|
|
54
52
|
"@types/hpp": "^0.2.1",
|
|
55
|
-
"@types/jest": "
|
|
53
|
+
"@types/jest": "27.4.x",
|
|
56
54
|
"@types/jsonwebtoken": "^8.5.4",
|
|
57
55
|
"@types/morgan": "^1.9.3",
|
|
58
56
|
"@types/node": "^16.0.1",
|
|
59
57
|
"@types/supertest": "^2.0.11",
|
|
60
58
|
"@types/swagger-jsdoc": "^6.0.1",
|
|
61
59
|
"@types/swagger-ui-express": "^4.1.3",
|
|
62
|
-
"@types/winston": "^2.4.4",
|
|
63
60
|
"@typescript-eslint/eslint-plugin": "^4.28.2",
|
|
64
61
|
"@typescript-eslint/parser": "^4.28.2",
|
|
65
62
|
"cross-env": "^7.0.3",
|
|
@@ -67,7 +64,7 @@
|
|
|
67
64
|
"eslint-config-prettier": "^8.3.0",
|
|
68
65
|
"eslint-plugin-prettier": "^3.4.0",
|
|
69
66
|
"husky": "^7.0.1",
|
|
70
|
-
"jest": "
|
|
67
|
+
"jest": "27.4.x",
|
|
71
68
|
"lint-staged": "^11.0.0",
|
|
72
69
|
"node-config": "^0.0.2",
|
|
73
70
|
"node-gyp": "^8.1.0",
|
|
@@ -75,8 +72,8 @@
|
|
|
75
72
|
"pm2": "^5.1.0",
|
|
76
73
|
"prettier": "^2.3.2",
|
|
77
74
|
"prisma": "^3.7.0",
|
|
78
|
-
"supertest": "^6.
|
|
79
|
-
"ts-jest": "^27.
|
|
75
|
+
"supertest": "^6.2.2",
|
|
76
|
+
"ts-jest": "^27.1.4",
|
|
80
77
|
"ts-node": "^10.4.0",
|
|
81
78
|
"tsc-alias": "^1.4.1",
|
|
82
79
|
"tsconfig-paths": "^3.10.1",
|
|
@@ -1,6 +1,29 @@
|
|
|
1
|
+
# app name should be overridden.
|
|
2
|
+
# ex) production-stage: make build APP_NAME=<APP_NAME>
|
|
3
|
+
# ex) development-stage: make build-dev APP_NAME=<APP_NAME>
|
|
4
|
+
|
|
5
|
+
APP_NAME = typescript-express
|
|
6
|
+
APP_NAME := $(APP_NAME)
|
|
7
|
+
|
|
8
|
+
.PHONY: build
|
|
9
|
+
# Build the container image - Dvelopment
|
|
10
|
+
build-dev:
|
|
11
|
+
docker build -t ${APP_NAME}\
|
|
12
|
+
--target development-build-stage\
|
|
13
|
+
-f Dockerfile .
|
|
14
|
+
|
|
15
|
+
# Build the container image - Production
|
|
1
16
|
build:
|
|
2
|
-
docker build -t ${
|
|
17
|
+
docker build -t ${APP_NAME}\
|
|
18
|
+
--target production-build-stage\
|
|
19
|
+
-f Dockerfile .
|
|
20
|
+
|
|
21
|
+
# Clean the container image
|
|
3
22
|
clean:
|
|
4
|
-
docker rmi -f ${
|
|
23
|
+
docker rmi -f ${APP_NAME}
|
|
24
|
+
|
|
25
|
+
# Run the container image
|
|
5
26
|
run:
|
|
6
|
-
docker run -d -p
|
|
27
|
+
docker run -d -it -p 3000:3000 ${APP_NAME}
|
|
28
|
+
|
|
29
|
+
all: build
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "typescript-express-starter",
|
|
3
3
|
"version": "0.0.0",
|
|
4
|
-
"description": "TypeScript +
|
|
4
|
+
"description": "TypeScript + Routing Controllers + Express API Server",
|
|
5
5
|
"author": "",
|
|
6
6
|
"license": "ISC",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"start": "npm run build && cross-env NODE_ENV=production node dist/server.js",
|
|
9
9
|
"dev": "cross-env NODE_ENV=development nodemon",
|
|
10
|
-
"build": "
|
|
11
|
-
"build:
|
|
10
|
+
"build": "swc src -d dist --source-maps --copy-files",
|
|
11
|
+
"build:tsc": "tsc && tsc-alias",
|
|
12
12
|
"test": "jest --forceExit --detectOpenHandles",
|
|
13
13
|
"lint": "eslint --ignore-path .gitignore --ext .ts src/",
|
|
14
14
|
"lint:fix": "npm run lint -- --fix",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
19
|
"bcrypt": "^5.0.1",
|
|
20
|
-
"class-transformer": "^0.
|
|
20
|
+
"class-transformer": "^0.5.1",
|
|
21
21
|
"class-validator": "^0.13.1",
|
|
22
22
|
"class-validator-jsonschema": "^3.0.2",
|
|
23
23
|
"compression": "^1.7.4",
|
|
@@ -44,17 +44,14 @@
|
|
|
44
44
|
"@types/compression": "^1.7.1",
|
|
45
45
|
"@types/cookie-parser": "^1.4.2",
|
|
46
46
|
"@types/cors": "^2.8.11",
|
|
47
|
-
"@types/dotenv": "^8.2.0",
|
|
48
47
|
"@types/express": "^4.17.13",
|
|
49
|
-
"@types/helmet": "^4.0.0",
|
|
50
48
|
"@types/hpp": "^0.2.1",
|
|
51
|
-
"@types/jest": "
|
|
49
|
+
"@types/jest": "27.4.x",
|
|
52
50
|
"@types/jsonwebtoken": "^8.5.4",
|
|
53
51
|
"@types/morgan": "^1.9.3",
|
|
54
52
|
"@types/node": "^16.0.1",
|
|
55
53
|
"@types/supertest": "^2.0.11",
|
|
56
54
|
"@types/swagger-ui-express": "^4.1.3",
|
|
57
|
-
"@types/winston": "^2.4.4",
|
|
58
55
|
"@typescript-eslint/eslint-plugin": "^4.28.2",
|
|
59
56
|
"@typescript-eslint/parser": "^4.28.2",
|
|
60
57
|
"cross-env": "^7.0.3",
|
|
@@ -62,14 +59,15 @@
|
|
|
62
59
|
"eslint-config-prettier": "^8.3.0",
|
|
63
60
|
"eslint-plugin-prettier": "^3.4.0",
|
|
64
61
|
"husky": "^7.0.1",
|
|
65
|
-
"jest": "
|
|
62
|
+
"jest": "27.4.x",
|
|
66
63
|
"lint-staged": "^11.0.0",
|
|
67
64
|
"node-config": "^0.0.2",
|
|
68
65
|
"node-gyp": "^8.1.0",
|
|
69
66
|
"nodemon": "^2.0.9",
|
|
70
67
|
"pm2": "^5.1.0",
|
|
71
68
|
"prettier": "^2.3.2",
|
|
72
|
-
"
|
|
69
|
+
"supertest": "^6.2.2",
|
|
70
|
+
"ts-jest": "^27.1.4",
|
|
73
71
|
"ts-node": "^10.4.0",
|
|
74
72
|
"tsc-alias": "^1.4.1",
|
|
75
73
|
"tsconfig-paths": "^3.10.1",
|
package/lib/sequelize/Makefile
CHANGED
|
@@ -1,6 +1,29 @@
|
|
|
1
|
+
# app name should be overridden.
|
|
2
|
+
# ex) production-stage: make build APP_NAME=<APP_NAME>
|
|
3
|
+
# ex) development-stage: make build-dev APP_NAME=<APP_NAME>
|
|
4
|
+
|
|
5
|
+
APP_NAME = typescript-express
|
|
6
|
+
APP_NAME := $(APP_NAME)
|
|
7
|
+
|
|
8
|
+
.PHONY: build
|
|
9
|
+
# Build the container image - Dvelopment
|
|
10
|
+
build-dev:
|
|
11
|
+
docker build -t ${APP_NAME}\
|
|
12
|
+
--target development-build-stage\
|
|
13
|
+
-f Dockerfile .
|
|
14
|
+
|
|
15
|
+
# Build the container image - Production
|
|
1
16
|
build:
|
|
2
|
-
docker build -t ${
|
|
17
|
+
docker build -t ${APP_NAME}\
|
|
18
|
+
--target production-build-stage\
|
|
19
|
+
-f Dockerfile .
|
|
20
|
+
|
|
21
|
+
# Clean the container image
|
|
3
22
|
clean:
|
|
4
|
-
docker rmi -f ${
|
|
23
|
+
docker rmi -f ${APP_NAME}
|
|
24
|
+
|
|
25
|
+
# Run the container image
|
|
5
26
|
run:
|
|
6
|
-
docker run -d -p
|
|
27
|
+
docker run -d -it -p 3000:3000 ${APP_NAME}
|
|
28
|
+
|
|
29
|
+
all: build
|