typescript-express-starter 7.0.0 โ 8.0.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 +8 -4
- package/README.md +8 -4
- package/lib/typegoose/.dockerignore +18 -0
- package/lib/typegoose/.editorconfig +9 -0
- package/lib/typegoose/.env.development.local +18 -0
- package/lib/typegoose/.env.production.local +18 -0
- package/lib/typegoose/.env.test.local +18 -0
- package/lib/typegoose/.eslintignore +1 -0
- package/lib/typegoose/.eslintrc +18 -0
- package/lib/typegoose/.huskyrc +5 -0
- package/lib/typegoose/.lintstagedrc.json +5 -0
- package/lib/typegoose/.prettierrc +8 -0
- package/lib/typegoose/.swcrc +40 -0
- package/lib/typegoose/.vscode/launch.json +35 -0
- package/lib/typegoose/.vscode/settings.json +6 -0
- package/lib/typegoose/Dockerfile +24 -0
- package/lib/typegoose/Makefile +6 -0
- package/lib/typegoose/docker-compose.yml +46 -0
- package/lib/typegoose/ecosystem.config.js +57 -0
- package/lib/typegoose/jest.config.js +12 -0
- package/lib/typegoose/nginx.conf +40 -0
- package/lib/typegoose/nodemon.json +12 -0
- package/lib/typegoose/package.json +80 -0
- package/lib/typegoose/src/app.ts +93 -0
- package/lib/typegoose/src/config/index.ts +5 -0
- package/lib/typegoose/src/controllers/auth.controller.ts +46 -0
- package/lib/typegoose/src/controllers/index.controller.ts +13 -0
- package/lib/typegoose/src/controllers/users.controller.ts +65 -0
- package/lib/typegoose/src/databases/index.ts +3 -0
- package/lib/typegoose/src/dtos/users.dto.ts +9 -0
- package/lib/typegoose/src/exceptions/HttpException.ts +10 -0
- package/lib/typegoose/src/http/auth.http +32 -0
- package/lib/typegoose/src/http/users.http +34 -0
- package/lib/typegoose/src/interfaces/auth.interface.ts +15 -0
- package/lib/typegoose/src/interfaces/routes.interface.ts +6 -0
- package/lib/typegoose/src/interfaces/users.interface.ts +5 -0
- package/lib/typegoose/src/middlewares/auth.middleware.ts +32 -0
- package/lib/typegoose/src/middlewares/error.middleware.ts +17 -0
- package/lib/typegoose/src/middlewares/validation.middleware.ts +25 -0
- package/lib/typegoose/src/models/users.model.ts +18 -0
- package/lib/typegoose/src/routes/auth.route.ts +24 -0
- package/lib/typegoose/src/routes/index.route.ts +19 -0
- package/lib/typegoose/src/routes/users.route.ts +25 -0
- package/lib/typegoose/src/server.ts +11 -0
- package/lib/typegoose/src/services/auth.service.ts +61 -0
- package/lib/typegoose/src/services/users.service.ts +64 -0
- package/lib/typegoose/src/tests/auth.test.ts +83 -0
- package/lib/typegoose/src/tests/index.test.ts +18 -0
- package/lib/typegoose/src/tests/users.test.ts +133 -0
- package/lib/typegoose/src/utils/logger.ts +65 -0
- package/lib/typegoose/src/utils/util.ts +19 -0
- package/lib/typegoose/src/utils/validateEnv.ts +10 -0
- package/lib/typegoose/swagger.yaml +122 -0
- package/lib/typegoose/tsconfig.json +40 -0
- package/package.json +2 -1
package/README.kr.md
CHANGED
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
- [๐บ๐ธ ์์ด](https://github.com/ljlm0402/typescript-express-starter/blob/master/README.md)
|
|
47
47
|
- [๐ฐ๐ท ํ๊ตญ์ด](https://github.com/ljlm0402/typescript-express-starter/blob/master/README.kr.md)
|
|
48
48
|
|
|
49
|
-
> ๋ฒ์ญ์ ๋์์ฃผ์ค ๋ถ์ ์ด์ ๋จ๊ฒจ์ฃผ์๊ธฐ ๋ฐ๋๋๋ค. ๐
|
|
49
|
+
> ๋ฒ์ญ์ ๋์์ฃผ์ค ๋ถ์ [์ด์](https://github.com/ljlm0402/typescript-express-starter/issues/new?assignees=ljlm0402&labels=%F0%9F%92%B1+Translations&template=translations-language---.md&title=) ๋จ๊ฒจ์ฃผ์๊ธฐ ๋ฐ๋๋๋ค. ๐
|
|
50
50
|
|
|
51
51
|
<br />
|
|
52
52
|
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
|
|
55
55
|
- [๐๐ปโโ๏ธ Dylan Iqbal :: A TypeScript Express Starter App](https://bit.ly/3rrZFZ9)
|
|
56
56
|
|
|
57
|
-
> ์น ์ฌ์ดํธ ๋ฐ ๋ธ๋ก๊ทธ์ ์๊ฐ๋ฅผ ์ํ์๋ ๋ถ์ ์ด์ ๋จ๊ฒจ์ฃผ์๊ธฐ ๋ฐ๋๋๋ค. ๐
|
|
57
|
+
> ์น ์ฌ์ดํธ ๋ฐ ๋ธ๋ก๊ทธ์ ์๊ฐ๋ฅผ ์ํ์๋ ๋ถ์ [์ด์](https://github.com/ljlm0402/typescript-express-starter/issues/new?assignees=ljlm0402&labels=%F0%9F%91%80+Introducetion&template=introducetion-project---.md&title=) ๋จ๊ฒจ์ฃผ์๊ธฐ ๋ฐ๋๋๋ค. ๐
|
|
58
58
|
|
|
59
59
|
<br />
|
|
60
60
|
|
|
@@ -100,18 +100,19 @@ $ npx typescript-express-starter "project name"
|
|
|
100
100
|
| :------------------ | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
101
101
|
| Default | Express ๊ธฐ๋ณธ |
|
|
102
102
|
| Routing Controllers | ๋ฐ์ฝ๋ ์ดํฐ ์ฌ์ฉ๋์ด ๋ง์ ๊ตฌ์กฐํ๋๊ณ ์ ์ธ์ ์ด๋ฉฐ ์๋ฆ๋ต๊ฒ ๊ตฌ์ฑ๋ ํด๋์ค ๊ธฐ๋ฐ ์ปจํธ๋กค๋ฌ ์์ฑ |
|
|
103
|
-
| Sequelize |
|
|
103
|
+
| Sequelize | PostgreSQL, MySQL, MariaDB, SQLite, Microsoft SQL Server๋ฅผ ์ง์ํ๋ Promise ํจํด ๊ธฐ๋ฐ์ Node.js ORM |
|
|
104
104
|
| Mongoose | Node.js์ MongoDB๋ฅผ ์ํ ODM(Object Data Mapping) ๋ผ์ด๋ธ๋ฌ๋ฆฌ |
|
|
105
105
|
| TypeORM | ์๋ฐ์คํฌ๋ฆฝํธ, ํ์
์คํฌ๋ฆฝํธ๊ณผ ํจ๊ป ์ฌ์ฉ๋์ด Node.js, React Native, Expo์์ ์คํ๋ ์ ์๋ ORM |
|
|
106
106
|
| Prisma | ๋ฐ์ดํฐ๋ฒ ์ด์ค์ ๋ฐ์ดํฐ๋ฅผ ํ๋ก๊ทธ๋๋ฐ ์ธ์ด์ ๊ฐ์ฒด์ ๋งคํํ์ฌ ๊ธฐ์กด์ SQL๋ก ์์ฑํ๋ ๋ฐ์ดํฐ๋ฅผ ์์ , ํ
์ด๋ธ ๊ตฌ์กฐ ๋ณ๊ฒฝ๋ฑ์ ์์
์ ๊ฐ์ฒด๋ฅผ ํตํด ํ๋ก๊ทธ๋๋ฐ์ ์ผ๋ก ํ ์ ์๋๋ก ํด์ฃผ๋ ORM |
|
|
107
107
|
| Knex | ์ฟผ๋ฆฌ ๋น๋๋ฅผ ์ํ ๋ผ์ด๋ธ๋ฌ๋ฆฌ |
|
|
108
108
|
| GraphQL | API ์ฉ ์ฟผ๋ฆฌ ์ธ์ด์ด๋ฉฐ ๊ธฐ์กด ๋ฐ์ดํฐ๋ก ์ด๋ฌํ ์ฟผ๋ฆฌ๋ฅผ ์ํํ๊ธฐ์ํ ๋ฐํ์ |
|
|
109
|
+
| Typegoose | ํ์
์คํฌ๋ฆฝํธ ํด๋์ค๋ฅผ ์ฌ์ฉํ์ฌ ๋ชฝ๊ตฌ์ค ๋ชจ๋ธ ์ ์ |
|
|
109
110
|
|
|
110
111
|
## ๐ Script ๋ช
๋ น์ด
|
|
111
112
|
|
|
112
113
|
- ํ๋ก๋์
๋ชจ๋ ์คํ : `npm run start` ์๋๋ฉด `Start typescript-express-starter` VS Code ๋ก
|
|
113
114
|
- ๊ฐ๋ฐ ๋ชจ๋ ์คํ : `npm run dev` ์๋๋ฉด `Dev typescript-express-starter` VS Code ๋ก
|
|
114
|
-
- ๋จ์ ํ
์คํธ : `npm
|
|
115
|
+
- ๋จ์ ํ
์คํธ : `npm test` ์๋๋ฉด `Test typescript-express-starter` VS Code ๋ก
|
|
115
116
|
- ์ฝ๋ ํฌ๋งทํฐ ๊ฒ์ฌ : `npm run lint` ์๋๋ฉด `Lint typescript-express-starter` VS Code ๋ก
|
|
116
117
|
- ์ฝ๋ ํฌ๋งทํฐ ์ ์ฉ : `npm run lint:fix` ์๋๋ฉด `Lint:Fix typescript-express-starter` VS Code ๋ก
|
|
117
118
|
|
|
@@ -132,6 +133,7 @@ $ npx typescript-express-starter "project name"
|
|
|
132
133
|

|
|
133
134
|

|
|
134
135
|

|
|
136
|
+

|
|
135
137
|
|
|
136
138
|
- Utilities
|
|
137
139
|
|
|
@@ -366,6 +368,8 @@ VSCode Extension์์ [REST Client](https://marketplace.visualstudio.com/items?
|
|
|
366
368
|
|
|
367
369
|
- Dustin Newbold [https://github.com/dustinnewbold](https://github.com/dustinnewbold)
|
|
368
370
|
|
|
371
|
+
- WhatIfWeDigDeeper [https://github.com/WhatIfWeDigDeeper](https://github.com/WhatIfWeDigDeeper)
|
|
372
|
+
|
|
369
373
|
## ๐ณ ๋ผ์ด์ผ์ค
|
|
370
374
|
|
|
371
375
|
[MIT](LICENSE)
|
package/README.md
CHANGED
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
- [๐บ๐ธ English](https://github.com/ljlm0402/typescript-express-starter/blob/master/README.md)
|
|
47
47
|
- [๐ฐ๐ท Korean](https://github.com/ljlm0402/typescript-express-starter/blob/master/README.kr.md)
|
|
48
48
|
|
|
49
|
-
> Want to translate to your own language? please open an issue ๐
|
|
49
|
+
> Want to translate to your own language? please open an [issue](https://github.com/ljlm0402/typescript-express-starter/issues/new?assignees=ljlm0402&labels=%F0%9F%92%B1+Translations&template=translations-language---.md&title=) ๐
|
|
50
50
|
|
|
51
51
|
<br />
|
|
52
52
|
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
|
|
55
55
|
- [๐๐ปโโ๏ธ Dylan Iqbal :: A TypeScript Express Starter App](https://bit.ly/3rrZFZ9)
|
|
56
56
|
|
|
57
|
-
> Want to be featured on your blog or site? please open an issue ๐
|
|
57
|
+
> Want to be featured on your blog or site? please open an [issue](https://github.com/ljlm0402/typescript-express-starter/issues/new?assignees=ljlm0402&labels=%F0%9F%91%80+Introducetion&template=introducetion-project---.md&title=) ๐
|
|
58
58
|
|
|
59
59
|
<br />
|
|
60
60
|
|
|
@@ -100,7 +100,7 @@ Start your typescript-express-starter app in development mode at `http://localho
|
|
|
100
100
|
|
|
101
101
|
#### Template Type
|
|
102
102
|
|
|
103
|
-
| Name |
|
|
103
|
+
| Name | Description |
|
|
104
104
|
| :------------------ | :----------------------------------------------------------------------------------------------------------- |
|
|
105
105
|
| Default | Express Default |
|
|
106
106
|
| Routing Controllers | Create structured, declarative and beautifully organized class-based controllers with heavy decorators usage |
|
|
@@ -110,12 +110,13 @@ Start your typescript-express-starter app in development mode at `http://localho
|
|
|
110
110
|
| Prisma | Modern Database Access for TypeScript & Node.js |
|
|
111
111
|
| Knex | SQL query builder for Postgres, MySQL, MariaDB, SQLite3 and Oracle |
|
|
112
112
|
| GraphQL | query language for APIs and a runtime for fulfilling those queries with your existing data |
|
|
113
|
+
| Typegoose | Define Mongoose models using TypeScript classes |
|
|
113
114
|
|
|
114
115
|
## ๐ Available Commands for the Server
|
|
115
116
|
|
|
116
117
|
- Run the Server in production mode : `npm run start` or `Start typescript-express-starter` in VS Code
|
|
117
118
|
- Run the Server in development mode : `npm run dev` or `Dev typescript-express-starter` in VS Code
|
|
118
|
-
- Run all unit-tests : `npm
|
|
119
|
+
- Run all unit-tests : `npm test` or `Test typescript-express-starter` in VS Code
|
|
119
120
|
- Check for linting errors : `npm run lint` or `Lint typescript-express-starter` in VS Code
|
|
120
121
|
- Fix for linting : `npm run lint:fix` or `Lint:Fix typescript-express-starter` in VS Code
|
|
121
122
|
|
|
@@ -136,6 +137,7 @@ Start your typescript-express-starter app in development mode at `http://localho
|
|
|
136
137
|

|
|
137
138
|

|
|
138
139
|

|
|
140
|
+

|
|
139
141
|
|
|
140
142
|
- Utilities
|
|
141
143
|
|
|
@@ -371,6 +373,8 @@ Modify `.swcrc` file to your source code.
|
|
|
371
373
|
|
|
372
374
|
- Dustin Newbold [https://github.com/dustinnewbold](https://github.com/dustinnewbold)
|
|
373
375
|
|
|
376
|
+
- WhatIfWeDigDeeper [https://github.com/WhatIfWeDigDeeper](https://github.com/WhatIfWeDigDeeper)
|
|
377
|
+
|
|
374
378
|
## ๐ณ License
|
|
375
379
|
|
|
376
380
|
[MIT](LICENSE)
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# PORT
|
|
2
|
+
PORT = 3000
|
|
3
|
+
|
|
4
|
+
# DATABASE
|
|
5
|
+
DB_HOST = localhost
|
|
6
|
+
DB_PORT = 27017
|
|
7
|
+
DB_DATABASE = test
|
|
8
|
+
|
|
9
|
+
# TOKEN
|
|
10
|
+
SECRET_KEY = secretKey
|
|
11
|
+
|
|
12
|
+
# LOG
|
|
13
|
+
LOG_FORMAT = combined
|
|
14
|
+
LOG_DIR = ../logs
|
|
15
|
+
|
|
16
|
+
# CORS
|
|
17
|
+
ORIGIN = your.domain.com
|
|
18
|
+
CREDENTIALS = true
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/dist
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"parser": "@typescript-eslint/parser",
|
|
3
|
+
"extends": ["prettier", "plugin:@typescript-eslint/recommended", "plugin:prettier/recommended"],
|
|
4
|
+
"parserOptions": {
|
|
5
|
+
"ecmaVersion": 2018,
|
|
6
|
+
"sourceType": "module"
|
|
7
|
+
},
|
|
8
|
+
"rules": {
|
|
9
|
+
"@typescript-eslint/explicit-member-accessibility": 0,
|
|
10
|
+
"@typescript-eslint/explicit-function-return-type": 0,
|
|
11
|
+
"@typescript-eslint/no-parameter-properties": 0,
|
|
12
|
+
"@typescript-eslint/interface-name-prefix": 0,
|
|
13
|
+
"@typescript-eslint/explicit-module-boundary-types": 0,
|
|
14
|
+
"@typescript-eslint/no-explicit-any": "off",
|
|
15
|
+
"@typescript-eslint/ban-types": "off",
|
|
16
|
+
"@typescript-eslint/no-var-requires": "off"
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"jsc": {
|
|
3
|
+
"parser": {
|
|
4
|
+
"syntax": "typescript",
|
|
5
|
+
"tsx": false,
|
|
6
|
+
"dynamicImport": true,
|
|
7
|
+
"decorators": true
|
|
8
|
+
},
|
|
9
|
+
"transform": {
|
|
10
|
+
"legacyDecorator": true,
|
|
11
|
+
"decoratorMetadata": true
|
|
12
|
+
},
|
|
13
|
+
"target": "es2017",
|
|
14
|
+
"externalHelpers": false,
|
|
15
|
+
"keepClassNames": true,
|
|
16
|
+
"loose": false,
|
|
17
|
+
"minify": {
|
|
18
|
+
"compress": false,
|
|
19
|
+
"mangle": false
|
|
20
|
+
},
|
|
21
|
+
"baseUrl": "src",
|
|
22
|
+
"paths": {
|
|
23
|
+
"@/*": ["*"],
|
|
24
|
+
"@config": ["config"],
|
|
25
|
+
"@controllers/*": ["controllers/*"],
|
|
26
|
+
"@databases": ["databases"],
|
|
27
|
+
"@dtos/*": ["dtos/*"],
|
|
28
|
+
"@exceptions/*": ["exceptions/*"],
|
|
29
|
+
"@interfaces/*": ["interfaces/*"],
|
|
30
|
+
"@middlewares/*": ["middlewares/*"],
|
|
31
|
+
"@models/*": ["models/*"],
|
|
32
|
+
"@routes/*": ["routes/*"],
|
|
33
|
+
"@services/*": ["services/*"],
|
|
34
|
+
"@utils/*": ["utils/*"]
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
"module": {
|
|
38
|
+
"type": "commonjs"
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": "0.2.0",
|
|
3
|
+
"configurations": [
|
|
4
|
+
{
|
|
5
|
+
"type": "node-terminal",
|
|
6
|
+
"request": "launch",
|
|
7
|
+
"name": "Dev typescript-express-starter",
|
|
8
|
+
"command": "npm run dev"
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
"type": "node-terminal",
|
|
12
|
+
"request": "launch",
|
|
13
|
+
"name": "Start typescript-express-starter",
|
|
14
|
+
"command": "npm run start"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"type": "node-terminal",
|
|
18
|
+
"request": "launch",
|
|
19
|
+
"name": "Test typescript-express-starter",
|
|
20
|
+
"command": "npm run test"
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"type": "node-terminal",
|
|
24
|
+
"request": "launch",
|
|
25
|
+
"name": "Lint typescript-express-starter",
|
|
26
|
+
"command": "npm run lint"
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"type": "node-terminal",
|
|
30
|
+
"request": "launch",
|
|
31
|
+
"name": "Lint:Fix typescript-express-starter",
|
|
32
|
+
"command": "npm run lint:fix"
|
|
33
|
+
}
|
|
34
|
+
]
|
|
35
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# Common build stage
|
|
2
|
+
FROM node:14.14.0-alpine3.12 as common-build-stage
|
|
3
|
+
|
|
4
|
+
COPY . ./app
|
|
5
|
+
|
|
6
|
+
WORKDIR /app
|
|
7
|
+
|
|
8
|
+
RUN npm install
|
|
9
|
+
|
|
10
|
+
EXPOSE 3000
|
|
11
|
+
|
|
12
|
+
# Development build stage
|
|
13
|
+
FROM common-build-stage as development-build-stage
|
|
14
|
+
|
|
15
|
+
ENV NODE_ENV development
|
|
16
|
+
|
|
17
|
+
CMD ["npm", "run", "dev"]
|
|
18
|
+
|
|
19
|
+
# Production build stage
|
|
20
|
+
FROM common-build-stage as production-build-stage
|
|
21
|
+
|
|
22
|
+
ENV NODE_ENV production
|
|
23
|
+
|
|
24
|
+
CMD ["npm", "run", "start"]
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
version: '3.7'
|
|
2
|
+
|
|
3
|
+
services:
|
|
4
|
+
proxy:
|
|
5
|
+
image: nginx:alpine
|
|
6
|
+
container_name: proxy
|
|
7
|
+
ports:
|
|
8
|
+
- '80:80'
|
|
9
|
+
volumes:
|
|
10
|
+
- ./nginx.conf:/etc/nginx/nginx.conf
|
|
11
|
+
restart: 'unless-stopped'
|
|
12
|
+
networks:
|
|
13
|
+
- backend
|
|
14
|
+
server:
|
|
15
|
+
build:
|
|
16
|
+
context: ./
|
|
17
|
+
target: development-build-stage
|
|
18
|
+
dockerfile: Dockerfile
|
|
19
|
+
container_name: server
|
|
20
|
+
ports:
|
|
21
|
+
- '3000:3000'
|
|
22
|
+
volumes:
|
|
23
|
+
- ./:/app
|
|
24
|
+
- /app/node_modules
|
|
25
|
+
restart: 'unless-stopped'
|
|
26
|
+
networks:
|
|
27
|
+
- backend
|
|
28
|
+
links:
|
|
29
|
+
- mongo
|
|
30
|
+
depends_on:
|
|
31
|
+
- mongo
|
|
32
|
+
mongo:
|
|
33
|
+
image: mvertes/alpine-mongo
|
|
34
|
+
container_name: mongo
|
|
35
|
+
ports:
|
|
36
|
+
- '27017:27017'
|
|
37
|
+
networks:
|
|
38
|
+
- backend
|
|
39
|
+
|
|
40
|
+
networks:
|
|
41
|
+
backend:
|
|
42
|
+
driver: bridge
|
|
43
|
+
|
|
44
|
+
volumes:
|
|
45
|
+
data:
|
|
46
|
+
driver: local
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description pm2 configuration file.
|
|
3
|
+
* @example
|
|
4
|
+
* production mode :: pm2 start ecosystem.config.js --only prod
|
|
5
|
+
* development mode :: pm2 start ecosystem.config.js --only dev
|
|
6
|
+
*/
|
|
7
|
+
module.exports = {
|
|
8
|
+
apps: [
|
|
9
|
+
{
|
|
10
|
+
name: 'prod', // pm2 start App name
|
|
11
|
+
script: 'dist/server.js',
|
|
12
|
+
exec_mode: 'cluster', // 'cluster' or 'fork'
|
|
13
|
+
instance_var: 'INSTANCE_ID', // instance variable
|
|
14
|
+
instances: 2, // pm2 instance count
|
|
15
|
+
autorestart: true, // auto restart if process crash
|
|
16
|
+
watch: false, // files change automatic restart
|
|
17
|
+
ignore_watch: ['node_modules', 'logs'], // ignore files change
|
|
18
|
+
max_memory_restart: '1G', // restart if process use more than 1G memory
|
|
19
|
+
merge_logs: true, // if true, stdout and stderr will be merged and sent to pm2 log
|
|
20
|
+
output: './logs/access.log', // pm2 log file
|
|
21
|
+
error: './logs/error.log', // pm2 error log file
|
|
22
|
+
env: { // environment variable
|
|
23
|
+
PORT: 3000,
|
|
24
|
+
NODE_ENV: 'production',
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
name: 'dev', // pm2 start App name
|
|
29
|
+
script: 'ts-node', // ts-node
|
|
30
|
+
args: '-r tsconfig-paths/register --transpile-only src/server.ts', // ts-node args
|
|
31
|
+
exec_mode: 'cluster', // 'cluster' or 'fork'
|
|
32
|
+
instance_var: 'INSTANCE_ID', // instance variable
|
|
33
|
+
instances: 2, // pm2 instance count
|
|
34
|
+
autorestart: true, // auto restart if process crash
|
|
35
|
+
watch: false, // files change automatic restart
|
|
36
|
+
ignore_watch: ['node_modules', 'logs'], // ignore files change
|
|
37
|
+
max_memory_restart: '1G', // restart if process use more than 1G memory
|
|
38
|
+
merge_logs: true, // if true, stdout and stderr will be merged and sent to pm2 log
|
|
39
|
+
output: './logs/access.log', // pm2 log file
|
|
40
|
+
error: './logs/error.log', // pm2 error log file
|
|
41
|
+
env: { // environment variable
|
|
42
|
+
PORT: 3000,
|
|
43
|
+
NODE_ENV: 'development',
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
],
|
|
47
|
+
deploy: {
|
|
48
|
+
production: {
|
|
49
|
+
user: 'user',
|
|
50
|
+
host: '0.0.0.0',
|
|
51
|
+
ref: 'origin/master',
|
|
52
|
+
repo: 'git@github.com:repo.git',
|
|
53
|
+
path: 'dist/server.js',
|
|
54
|
+
'post-deploy': 'npm install && npm run build && pm2 reload ecosystem.config.js --only prod',
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
const { pathsToModuleNameMapper } = require('ts-jest/utils');
|
|
2
|
+
const { compilerOptions } = require('./tsconfig.json');
|
|
3
|
+
|
|
4
|
+
module.exports = {
|
|
5
|
+
preset: 'ts-jest',
|
|
6
|
+
testEnvironment: 'node',
|
|
7
|
+
roots: ['<rootDir>/src'],
|
|
8
|
+
transform: {
|
|
9
|
+
'^.+\\.tsx?$': 'ts-jest',
|
|
10
|
+
},
|
|
11
|
+
moduleNameMapper: pathsToModuleNameMapper(compilerOptions.paths, { prefix: '<rootDir>/src' }),
|
|
12
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
user nginx;
|
|
2
|
+
worker_processes 1;
|
|
3
|
+
|
|
4
|
+
error_log /var/log/nginx/error.log warn;
|
|
5
|
+
pid /var/run/nginx.pid;
|
|
6
|
+
|
|
7
|
+
events {
|
|
8
|
+
worker_connections 1024;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
http {
|
|
12
|
+
include /etc/nginx/mime.types;
|
|
13
|
+
default_type application/octet-stream;
|
|
14
|
+
|
|
15
|
+
upstream api-server {
|
|
16
|
+
server server:3000;
|
|
17
|
+
keepalive 100;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
server {
|
|
21
|
+
listen 80;
|
|
22
|
+
server_name localhost;
|
|
23
|
+
|
|
24
|
+
location / {
|
|
25
|
+
proxy_http_version 1.1;
|
|
26
|
+
proxy_pass http://api-server;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
|
|
32
|
+
'$status $body_bytes_sent "$http_referer" '
|
|
33
|
+
'"$http_user_agent" "$http_x_forwarded_for"';
|
|
34
|
+
|
|
35
|
+
access_log /var/log/nginx/access.log main;
|
|
36
|
+
|
|
37
|
+
sendfile on;
|
|
38
|
+
keepalive_timeout 65;
|
|
39
|
+
include /etc/nginx/conf.d/*.conf;
|
|
40
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "typegoose",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"description": "TypeScript + Mongoose + MongoDB + Express API Server",
|
|
5
|
+
"author": "",
|
|
6
|
+
"license": "ISC",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"start": "npm run build && cross-env NODE_ENV=production node dist/server.js",
|
|
9
|
+
"dev": "cross-env NODE_ENV=development nodemon",
|
|
10
|
+
"build": "swc src -d dist --source-maps --copy-files",
|
|
11
|
+
"build:tsc": "tsc && tsc-alias",
|
|
12
|
+
"test": "jest --forceExit --detectOpenHandles",
|
|
13
|
+
"lint": "eslint --ignore-path .gitignore --ext .ts src/",
|
|
14
|
+
"lint:fix": "npm run lint -- --fix",
|
|
15
|
+
"deploy:prod": "npm run build && pm2 start ecosystem.config.js --only prod",
|
|
16
|
+
"deploy:dev": "pm2 start ecosystem.config.js --only dev"
|
|
17
|
+
},
|
|
18
|
+
"dependencies": {
|
|
19
|
+
"@typegoose/typegoose": "^9.4.0",
|
|
20
|
+
"bcrypt": "^5.0.1",
|
|
21
|
+
"class-transformer": "^0.5.1",
|
|
22
|
+
"class-validator": "^0.13.1",
|
|
23
|
+
"compression": "^1.7.4",
|
|
24
|
+
"cookie-parser": "^1.4.5",
|
|
25
|
+
"cors": "^2.8.5",
|
|
26
|
+
"dotenv": "^10.0.0",
|
|
27
|
+
"envalid": "^7.1.0",
|
|
28
|
+
"express": "^4.17.1",
|
|
29
|
+
"helmet": "^4.6.0",
|
|
30
|
+
"hpp": "^0.2.3",
|
|
31
|
+
"jsonwebtoken": "^8.5.1",
|
|
32
|
+
"mongoose": "~6.1.3",
|
|
33
|
+
"morgan": "^1.10.0",
|
|
34
|
+
"swagger-jsdoc": "^6.0.0",
|
|
35
|
+
"swagger-ui-express": "^4.1.6",
|
|
36
|
+
"winston": "^3.3.3",
|
|
37
|
+
"winston-daily-rotate-file": "^4.5.5"
|
|
38
|
+
},
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"@swc/cli": "^0.1.51",
|
|
41
|
+
"@swc/core": "^1.2.108",
|
|
42
|
+
"@types/bcrypt": "^5.0.0",
|
|
43
|
+
"@types/compression": "^1.7.1",
|
|
44
|
+
"@types/cookie-parser": "^1.4.2",
|
|
45
|
+
"@types/cors": "^2.8.11",
|
|
46
|
+
"@types/dotenv": "^8.2.0",
|
|
47
|
+
"@types/express": "^4.17.13",
|
|
48
|
+
"@types/helmet": "^4.0.0",
|
|
49
|
+
"@types/hpp": "^0.2.1",
|
|
50
|
+
"@types/jest": "^26.0.24",
|
|
51
|
+
"@types/jsonwebtoken": "^8.5.4",
|
|
52
|
+
"@types/mongoose": "^5.10.1",
|
|
53
|
+
"@types/morgan": "^1.9.3",
|
|
54
|
+
"@types/node": "^16.0.1",
|
|
55
|
+
"@types/supertest": "^2.0.11",
|
|
56
|
+
"@types/swagger-jsdoc": "^6.0.1",
|
|
57
|
+
"@types/swagger-ui-express": "^4.1.3",
|
|
58
|
+
"@types/winston": "^2.4.4",
|
|
59
|
+
"@typescript-eslint/eslint-plugin": "^4.28.2",
|
|
60
|
+
"@typescript-eslint/parser": "^4.28.2",
|
|
61
|
+
"cross-env": "^7.0.3",
|
|
62
|
+
"eslint": "^7.30.0",
|
|
63
|
+
"eslint-config-prettier": "^8.3.0",
|
|
64
|
+
"eslint-plugin-prettier": "^3.4.0",
|
|
65
|
+
"husky": "^7.0.1",
|
|
66
|
+
"jest": "^27.0.6",
|
|
67
|
+
"lint-staged": "^11.0.0",
|
|
68
|
+
"node-config": "^0.0.2",
|
|
69
|
+
"node-gyp": "^8.1.0",
|
|
70
|
+
"nodemon": "^2.0.9",
|
|
71
|
+
"pm2": "^5.1.0",
|
|
72
|
+
"prettier": "^2.3.2",
|
|
73
|
+
"supertest": "^6.1.3",
|
|
74
|
+
"ts-jest": "^27.0.7",
|
|
75
|
+
"ts-node": "^10.4.0",
|
|
76
|
+
"tsc-alias": "^1.4.1",
|
|
77
|
+
"tsconfig-paths": "^3.10.1",
|
|
78
|
+
"typescript": "^4.5.2"
|
|
79
|
+
}
|
|
80
|
+
}
|