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.
Files changed (55) hide show
  1. package/README.kr.md +8 -4
  2. package/README.md +8 -4
  3. package/lib/typegoose/.dockerignore +18 -0
  4. package/lib/typegoose/.editorconfig +9 -0
  5. package/lib/typegoose/.env.development.local +18 -0
  6. package/lib/typegoose/.env.production.local +18 -0
  7. package/lib/typegoose/.env.test.local +18 -0
  8. package/lib/typegoose/.eslintignore +1 -0
  9. package/lib/typegoose/.eslintrc +18 -0
  10. package/lib/typegoose/.huskyrc +5 -0
  11. package/lib/typegoose/.lintstagedrc.json +5 -0
  12. package/lib/typegoose/.prettierrc +8 -0
  13. package/lib/typegoose/.swcrc +40 -0
  14. package/lib/typegoose/.vscode/launch.json +35 -0
  15. package/lib/typegoose/.vscode/settings.json +6 -0
  16. package/lib/typegoose/Dockerfile +24 -0
  17. package/lib/typegoose/Makefile +6 -0
  18. package/lib/typegoose/docker-compose.yml +46 -0
  19. package/lib/typegoose/ecosystem.config.js +57 -0
  20. package/lib/typegoose/jest.config.js +12 -0
  21. package/lib/typegoose/nginx.conf +40 -0
  22. package/lib/typegoose/nodemon.json +12 -0
  23. package/lib/typegoose/package.json +80 -0
  24. package/lib/typegoose/src/app.ts +93 -0
  25. package/lib/typegoose/src/config/index.ts +5 -0
  26. package/lib/typegoose/src/controllers/auth.controller.ts +46 -0
  27. package/lib/typegoose/src/controllers/index.controller.ts +13 -0
  28. package/lib/typegoose/src/controllers/users.controller.ts +65 -0
  29. package/lib/typegoose/src/databases/index.ts +3 -0
  30. package/lib/typegoose/src/dtos/users.dto.ts +9 -0
  31. package/lib/typegoose/src/exceptions/HttpException.ts +10 -0
  32. package/lib/typegoose/src/http/auth.http +32 -0
  33. package/lib/typegoose/src/http/users.http +34 -0
  34. package/lib/typegoose/src/interfaces/auth.interface.ts +15 -0
  35. package/lib/typegoose/src/interfaces/routes.interface.ts +6 -0
  36. package/lib/typegoose/src/interfaces/users.interface.ts +5 -0
  37. package/lib/typegoose/src/middlewares/auth.middleware.ts +32 -0
  38. package/lib/typegoose/src/middlewares/error.middleware.ts +17 -0
  39. package/lib/typegoose/src/middlewares/validation.middleware.ts +25 -0
  40. package/lib/typegoose/src/models/users.model.ts +18 -0
  41. package/lib/typegoose/src/routes/auth.route.ts +24 -0
  42. package/lib/typegoose/src/routes/index.route.ts +19 -0
  43. package/lib/typegoose/src/routes/users.route.ts +25 -0
  44. package/lib/typegoose/src/server.ts +11 -0
  45. package/lib/typegoose/src/services/auth.service.ts +61 -0
  46. package/lib/typegoose/src/services/users.service.ts +64 -0
  47. package/lib/typegoose/src/tests/auth.test.ts +83 -0
  48. package/lib/typegoose/src/tests/index.test.ts +18 -0
  49. package/lib/typegoose/src/tests/users.test.ts +133 -0
  50. package/lib/typegoose/src/utils/logger.ts +65 -0
  51. package/lib/typegoose/src/utils/util.ts +19 -0
  52. package/lib/typegoose/src/utils/validateEnv.ts +10 -0
  53. package/lib/typegoose/swagger.yaml +122 -0
  54. package/lib/typegoose/tsconfig.json +40 -0
  55. 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 | Postgres, MySQL, MariaDB, SQLite, Microsoft SQL Server๋ฅผ ์ง€์›ํ•˜๋Š” Promise ํŒจํ„ด ๊ธฐ๋ฐ˜์˜ Node.js ORM |
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 run test` ์•„๋‹ˆ๋ฉด `Test typescript-express-starter` VS Code ๋กœ
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
  ![](https://img.shields.io/badge/-ESLint-4B32C3?style=for-the-badge&logo=ESLint&logoColor=fff)
133
134
  ![](https://img.shields.io/badge/-Prettier-F7B93E?style=for-the-badge&logo=Prettier&logoColor=000)
134
135
  ![](https://img.shields.io/badge/-Jest-C21325?style=for-the-badge&logo=Jest&logoColor=fff)
136
+ ![](https://img.shields.io/badge/-SWC-FFFFFF?style=for-the-badge&logo=swc&logoColor=FBE1A6)
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 | Desc |
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 run test` or `Test typescript-express-starter` in VS Code
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
  ![](https://img.shields.io/badge/-ESLint-4B32C3?style=for-the-badge&logo=ESLint&logoColor=fff)
137
138
  ![](https://img.shields.io/badge/-Prettier-F7B93E?style=for-the-badge&logo=Prettier&logoColor=000)
138
139
  ![](https://img.shields.io/badge/-Jest-C21325?style=for-the-badge&logo=Jest&logoColor=fff)
140
+ ![](https://img.shields.io/badge/-SWC-FFFFFF?style=for-the-badge&logo=swc&logoColor=FBE1A6)
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
+ # compiled output
2
+ .vscode
3
+ /node_modules
4
+
5
+ # code formatter
6
+ .eslintrc
7
+ .eslintignore
8
+ .editorconfig
9
+ .huskyrc
10
+ .lintstagedrc.json
11
+ .prettierrc
12
+
13
+ # test
14
+ jest.config.js
15
+
16
+ # docker
17
+ Dockerfile
18
+ docker-compose.yml
@@ -0,0 +1,9 @@
1
+ root = true
2
+
3
+ [*]
4
+ indent_style = space
5
+ indent_size = 2
6
+ end_of_line = lf
7
+ charset = utf-8
8
+ trim_trailing_whitespace = true
9
+ insert_final_newline = true
@@ -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 = dev
14
+ LOG_DIR = ../logs
15
+
16
+ # CORS
17
+ ORIGIN = *
18
+ CREDENTIALS = true
@@ -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,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 = dev
14
+ LOG_DIR = ../logs
15
+
16
+ # CORS
17
+ ORIGIN = *
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,5 @@
1
+ {
2
+ "hooks": {
3
+ "pre-commit": "lint-staged"
4
+ }
5
+ }
@@ -0,0 +1,5 @@
1
+ {
2
+ "*.ts": [
3
+ "npm run lint"
4
+ ]
5
+ }
@@ -0,0 +1,8 @@
1
+ {
2
+ "printWidth": 150,
3
+ "tabWidth": 2,
4
+ "singleQuote": true,
5
+ "trailingComma": "all",
6
+ "semi": true,
7
+ "arrowParens": "avoid"
8
+ }
@@ -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,6 @@
1
+ {
2
+ "editor.codeActionsOnSave": {
3
+ "source.fixAll.eslint": true
4
+ },
5
+ "editor.formatOnSave": false
6
+ }
@@ -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,6 @@
1
+ build:
2
+ docker build -t ${tag} .
3
+ clean:
4
+ docker rmi -f ${tag}
5
+ run:
6
+ docker run -d -p ${port}:${port} --name ${name} ${tag}
@@ -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,12 @@
1
+ {
2
+ "watch": [
3
+ "src",
4
+ ".env"
5
+ ],
6
+ "ext": "js,ts,json",
7
+ "ignore": [
8
+ "src/logs/*",
9
+ "src/**/*.{spec,test}.ts"
10
+ ],
11
+ "exec": "ts-node -r tsconfig-paths/register --transpile-only src/server.ts"
12
+ }
@@ -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
+ }