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
package/README.kr.md
CHANGED
|
@@ -9,6 +9,12 @@
|
|
|
9
9
|
|
|
10
10
|
<h4 align="center">🚀 타입스크립트 기반의 익스프레스 보일러 플레이트 스타터 패키지</h4>
|
|
11
11
|
|
|
12
|
+
<p align ="center">
|
|
13
|
+
<a href="https://nodei.co/npm/typescript-express-starter" target="_blank">
|
|
14
|
+
<img src="https://nodei.co/npm/typescript-express-starter.png" alt="npm 정보" />
|
|
15
|
+
</a>
|
|
16
|
+
</p>
|
|
17
|
+
|
|
12
18
|
<p align="center">
|
|
13
19
|
<a href="http://npm.im/typescript-express-starter" target="_blank">
|
|
14
20
|
<img src="https://img.shields.io/npm/v/typescript-express-starter.svg" alt="npm 버전" />
|
|
@@ -46,16 +52,6 @@
|
|
|
46
52
|
- [🇺🇸 영어](https://github.com/ljlm0402/typescript-express-starter/blob/master/README.md)
|
|
47
53
|
- [🇰🇷 한국어](https://github.com/ljlm0402/typescript-express-starter/blob/master/README.kr.md)
|
|
48
54
|
|
|
49
|
-
> 번역을 도와주실 분은 [이슈](https://github.com/ljlm0402/typescript-express-starter/issues/new?assignees=ljlm0402&labels=%F0%9F%92%B1+Translations&template=translations-language---.md&title=) 남겨주시기 바랍니다. 💜
|
|
50
|
-
|
|
51
|
-
<br />
|
|
52
|
-
|
|
53
|
-
## 웹 사이트 - 프로젝트 소개 및 홍보
|
|
54
|
-
|
|
55
|
-
- [💁🏻♂️ Dylan Iqbal :: A TypeScript Express Starter App](https://bit.ly/3rrZFZ9)
|
|
56
|
-
|
|
57
|
-
> 웹 사이트 및 블로그에 소개를 원하시는 분은 [이슈](https://github.com/ljlm0402/typescript-express-starter/issues/new?assignees=ljlm0402&labels=%F0%9F%91%80+Introducetion&template=introducetion-project---.md&title=) 남겨주시기 바랍니다. 💙
|
|
58
|
-
|
|
59
55
|
<br />
|
|
60
56
|
|
|
61
57
|
## 😎 프로젝트를 소개합니다.
|
|
@@ -96,18 +92,19 @@ $ npx typescript-express-starter "project name"
|
|
|
96
92
|
|
|
97
93
|
#### 템플릿 종류
|
|
98
94
|
|
|
99
|
-
| 이름
|
|
100
|
-
|
|
|
101
|
-
| Default
|
|
102
|
-
| Routing Controllers
|
|
103
|
-
| Sequelize
|
|
104
|
-
| Mongoose
|
|
105
|
-
| TypeORM
|
|
106
|
-
| Prisma
|
|
107
|
-
| Knex
|
|
108
|
-
| GraphQL
|
|
109
|
-
| Typegoose
|
|
110
|
-
| mikro-orm
|
|
95
|
+
| 이름 | 설명 |
|
|
96
|
+
| :-------------------------------------------------------------------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
97
|
+
| Default | Express 기본 |
|
|
98
|
+
| [Routing Controllers](https://github.com/typestack/routing-controllers) | 데코레이터 사용량이 많은 구조화되고 선언적이며 아름답게 구성된 클래스 기반 컨트롤러 생성 |
|
|
99
|
+
| [Sequelize](https://github.com/sequelize/sequelize) | PostgreSQL, MySQL, MariaDB, SQLite, Microsoft SQL Server를 지원하는 Promise 패턴 기반의 Node.js ORM |
|
|
100
|
+
| [Mongoose](https://github.com/Automattic/mongoose) | Node.js와 MongoDB를 위한 ODM(Object Data Mapping) 라이브러리 |
|
|
101
|
+
| [TypeORM](https://github.com/typeorm/typeorm) | 자바스크립트, 타입스크립트과 함께 사용되어 Node.js, React Native, Expo에서 실행될 수 있는 ORM |
|
|
102
|
+
| [Prisma](https://github.com/prisma/prisma) | 데이터베이스에 데이터를 프로그래밍 언어의 객체와 매핑하여 기존에 SQL로 작성하던 데이터를 수정, 테이블 구조 변경등의 작업을 객체를 통해 프로그래밍적으로 할 수 있도록 해주는 ORM |
|
|
103
|
+
| [Knex](https://github.com/knex/knex) | 쿼리 빌더를 위한 라이브러리 |
|
|
104
|
+
| [GraphQL](https://github.com/graphql/graphql-js) | API 용 쿼리 언어이며 기존 데이터로 이러한 쿼리를 수행하기위한 런타임 |
|
|
105
|
+
| [Typegoose](https://github.com/typegoose/typegoose) | 타입스크립트 클래스를 사용하여 몽구스 모델 정의 |
|
|
106
|
+
| [Mikro ORM](https://github.com/mikro-orm/mikro-orm) | 데이터 매퍼, 작업 단위 및 아이덴티티 맵 패턴을 기반으로 하는 Node.js용 TypeScript ORM. MongoDB, MySQL, MariaDB, PostgreSQL 및 SQLite 데이터베이스를 지원 |
|
|
107
|
+
| [Sequelize Typescript](https://github.com/RobinBuschmann/sequelize-typescript) (개발중) | 데코레이터 및 Sequelize를 위한 몇 가지 기능 |
|
|
111
108
|
|
|
112
109
|
## 🛎 Script 명령어
|
|
113
110
|
|
|
@@ -238,10 +235,8 @@ VSCode Extension에서 [REST Client](https://marketplace.visualstudio.com/items?
|
|
|
238
235
|
│ └── settings.json
|
|
239
236
|
│
|
|
240
237
|
├── /src
|
|
241
|
-
│ ├── /
|
|
242
|
-
│ │
|
|
243
|
-
│ │ ├── production.json
|
|
244
|
-
│ │ └── test.json
|
|
238
|
+
│ ├── /config
|
|
239
|
+
│ │ └── index.ts
|
|
245
240
|
│ │
|
|
246
241
|
│ ├── /controllers
|
|
247
242
|
│ │ ├── auth.controller.ts
|
|
@@ -291,7 +286,6 @@ VSCode Extension에서 [REST Client](https://marketplace.visualstudio.com/items?
|
|
|
291
286
|
│ │ └── vaildateEnv.ts
|
|
292
287
|
│ │
|
|
293
288
|
│ ├── app.ts
|
|
294
|
-
│ ├── index.ts
|
|
295
289
|
│ └── server.ts
|
|
296
290
|
│
|
|
297
291
|
├── .dockerignore
|
|
@@ -375,6 +369,8 @@ VSCode Extension에서 [REST Client](https://marketplace.visualstudio.com/items?
|
|
|
375
369
|
|
|
376
370
|
- JagTheFriend [JagTheFriend](https://github.com/JagTheFriend)
|
|
377
371
|
|
|
372
|
+
- Tamzid Karim [Tamzid Karim](https://github.com/tamzidkarim)
|
|
373
|
+
|
|
378
374
|
## 💳 라이센스
|
|
379
375
|
|
|
380
376
|
[MIT](LICENSE)
|
package/README.md
CHANGED
|
@@ -9,6 +9,12 @@
|
|
|
9
9
|
|
|
10
10
|
<h4 align="center">🚀 Express RESTful API Boilerplate Using TypeScript</h4>
|
|
11
11
|
|
|
12
|
+
<p align ="center">
|
|
13
|
+
<a href="https://nodei.co/npm/typescript-express-starter" target="_blank">
|
|
14
|
+
<img src="https://nodei.co/npm/typescript-express-starter.png" alt="npm Info" />
|
|
15
|
+
</a>
|
|
16
|
+
</p>
|
|
17
|
+
|
|
12
18
|
<p align="center">
|
|
13
19
|
<a href="http://npm.im/typescript-express-starter" target="_blank">
|
|
14
20
|
<img src="https://img.shields.io/npm/v/typescript-express-starter.svg" alt="npm Version" />
|
|
@@ -46,16 +52,6 @@
|
|
|
46
52
|
- [🇺🇸 English](https://github.com/ljlm0402/typescript-express-starter/blob/master/README.md)
|
|
47
53
|
- [🇰🇷 Korean](https://github.com/ljlm0402/typescript-express-starter/blob/master/README.kr.md)
|
|
48
54
|
|
|
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
|
-
|
|
51
|
-
<br />
|
|
52
|
-
|
|
53
|
-
## Web Site - Project Introduction
|
|
54
|
-
|
|
55
|
-
- [💁🏻♂️ Dylan Iqbal :: A TypeScript Express Starter App](https://bit.ly/3rrZFZ9)
|
|
56
|
-
|
|
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
|
-
|
|
59
55
|
<br />
|
|
60
56
|
|
|
61
57
|
## 😎 Introducing The Project
|
|
@@ -100,18 +96,19 @@ Start your typescript-express-starter app in development mode at `http://localho
|
|
|
100
96
|
|
|
101
97
|
#### Template Type
|
|
102
98
|
|
|
103
|
-
| Name
|
|
104
|
-
|
|
|
105
|
-
| Default
|
|
106
|
-
| Routing Controllers
|
|
107
|
-
| Sequelize
|
|
108
|
-
| Mongoose
|
|
109
|
-
| TypeORM
|
|
110
|
-
| Prisma
|
|
111
|
-
| Knex
|
|
112
|
-
| GraphQL
|
|
113
|
-
| Typegoose
|
|
114
|
-
| mikro-orm
|
|
99
|
+
| Name | Description |
|
|
100
|
+
| :--------------------------------------------------------------------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
101
|
+
| Default | Express Default |
|
|
102
|
+
| [Routing Controllers](https://github.com/typestack/routing-controllers) | Create structured, declarative and beautifully organized class-based controllers with heavy decorators usage |
|
|
103
|
+
| [Sequelize](https://github.com/sequelize/sequelize) | Easy to use multi SQL dialect ORM for Node.js |
|
|
104
|
+
| [Mongoose](https://github.com/Automattic/mongoose) | MongoDB Object Modeling(ODM) designed to work in an asynchronous environment |
|
|
105
|
+
| [TypeORM](https://github.com/typeorm/typeorm) | An ORM that can run in Node.js and Others |
|
|
106
|
+
| [Prisma](https://github.com/prisma/prisma) | Modern Database Access for TypeScript & Node.js |
|
|
107
|
+
| [Knex](https://github.com/knex/knex) | SQL query builder for Postgres, MySQL, MariaDB, SQLite3 and Oracle |
|
|
108
|
+
| [GraphQL](https://github.com/graphql/graphql-js) | query language for APIs and a runtime for fulfilling those queries with your existing data |
|
|
109
|
+
| [Typegoose](https://github.com/typegoose/typegoose) | Define Mongoose models using TypeScript classes |
|
|
110
|
+
| [Mikro ORM](https://github.com/mikro-orm/mikro-orm) | TypeScript ORM for Node.js based on Data Mapper, Unit of Work and Identity Map patterns. Supports MongoDB, MySQL, MariaDB, PostgreSQL and SQLite databases |
|
|
111
|
+
| [Sequelize Typescript](https://github.com/RobinBuschmann/sequelize-typescript) (Develop) | Decorators and some other features for sequelize |
|
|
115
112
|
|
|
116
113
|
## 🛎 Available Commands for the Server
|
|
117
114
|
|
|
@@ -243,8 +240,8 @@ Modify `.swcrc` file to your source code.
|
|
|
243
240
|
│ └── settings.json
|
|
244
241
|
│
|
|
245
242
|
├── /src
|
|
246
|
-
│ ├── /
|
|
247
|
-
│ │
|
|
243
|
+
│ ├── /config
|
|
244
|
+
│ │ └── index.ts
|
|
248
245
|
│ │
|
|
249
246
|
│ ├── /controllers
|
|
250
247
|
│ │ ├── auth.controller.ts
|
|
@@ -294,7 +291,6 @@ Modify `.swcrc` file to your source code.
|
|
|
294
291
|
│ │ └── vaildateEnv.ts
|
|
295
292
|
│ │
|
|
296
293
|
│ ├── app.ts
|
|
297
|
-
│ ├── index.ts
|
|
298
294
|
│ └── server.ts
|
|
299
295
|
│
|
|
300
296
|
├── .dockerignore
|
|
@@ -380,6 +376,8 @@ Modify `.swcrc` file to your source code.
|
|
|
380
376
|
|
|
381
377
|
- JagTheFriend [JagTheFriend](https://github.com/JagTheFriend)
|
|
382
378
|
|
|
379
|
+
- Tamzid Karim [Tamzid Karim](https://github.com/tamzidkarim)
|
|
380
|
+
|
|
383
381
|
## 💳 License
|
|
384
382
|
|
|
385
383
|
[MIT](LICENSE)
|
package/lib/default/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/default/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",
|
|
@@ -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",
|
|
@@ -41,18 +41,15 @@
|
|
|
41
41
|
"@types/compression": "^1.7.1",
|
|
42
42
|
"@types/cookie-parser": "^1.4.2",
|
|
43
43
|
"@types/cors": "^2.8.11",
|
|
44
|
-
"@types/dotenv": "^8.2.0",
|
|
45
44
|
"@types/express": "^4.17.13",
|
|
46
|
-
"@types/helmet": "^4.0.0",
|
|
47
45
|
"@types/hpp": "^0.2.1",
|
|
48
|
-
"@types/jest": "
|
|
46
|
+
"@types/jest": "27.4.x",
|
|
49
47
|
"@types/jsonwebtoken": "^8.5.4",
|
|
50
48
|
"@types/morgan": "^1.9.3",
|
|
51
49
|
"@types/node": "^16.0.1",
|
|
52
50
|
"@types/supertest": "^2.0.11",
|
|
53
51
|
"@types/swagger-jsdoc": "^6.0.1",
|
|
54
52
|
"@types/swagger-ui-express": "^4.1.3",
|
|
55
|
-
"@types/winston": "^2.4.4",
|
|
56
53
|
"@typescript-eslint/eslint-plugin": "^4.28.2",
|
|
57
54
|
"@typescript-eslint/parser": "^4.28.2",
|
|
58
55
|
"cross-env": "^7.0.3",
|
|
@@ -60,18 +57,18 @@
|
|
|
60
57
|
"eslint-config-prettier": "^8.3.0",
|
|
61
58
|
"eslint-plugin-prettier": "^3.4.0",
|
|
62
59
|
"husky": "^7.0.1",
|
|
63
|
-
"jest": "
|
|
60
|
+
"jest": "27.4.x",
|
|
64
61
|
"lint-staged": "^11.0.0",
|
|
65
62
|
"node-config": "^0.0.2",
|
|
66
63
|
"node-gyp": "^8.1.0",
|
|
67
64
|
"nodemon": "^2.0.9",
|
|
68
65
|
"pm2": "^5.1.0",
|
|
69
66
|
"prettier": "^2.3.2",
|
|
70
|
-
"supertest": "^6.
|
|
67
|
+
"supertest": "^6.2.2",
|
|
68
|
+
"ts-jest": "^27.1.4",
|
|
69
|
+
"ts-node": "^10.4.0",
|
|
71
70
|
"tsc-alias": "^1.4.1",
|
|
72
71
|
"tsconfig-paths": "^3.10.1",
|
|
73
|
-
"
|
|
74
|
-
"ts-node": "^10.0.0",
|
|
75
|
-
"typescript": "^4.3.5"
|
|
72
|
+
"typescript": "^4.5.2"
|
|
76
73
|
}
|
|
77
74
|
}
|
|
@@ -3,7 +3,7 @@ PORT = 3000
|
|
|
3
3
|
|
|
4
4
|
# DATABASE
|
|
5
5
|
DB_HOST = localhost
|
|
6
|
-
DB_PORT =
|
|
6
|
+
DB_PORT = 5432
|
|
7
7
|
DB_USER = root
|
|
8
8
|
DB_PASSWORD = password
|
|
9
9
|
DB_DATABASE = test
|
|
@@ -16,5 +16,5 @@ LOG_FORMAT = dev
|
|
|
16
16
|
LOG_DIR = ../logs
|
|
17
17
|
|
|
18
18
|
# CORS
|
|
19
|
-
ORIGIN =
|
|
19
|
+
ORIGIN = true
|
|
20
20
|
CREDENTIALS = true
|
|
@@ -3,7 +3,7 @@ PORT = 3000
|
|
|
3
3
|
|
|
4
4
|
# DATABASE
|
|
5
5
|
DB_HOST = localhost
|
|
6
|
-
DB_PORT =
|
|
6
|
+
DB_PORT = 5432
|
|
7
7
|
DB_USER = root
|
|
8
8
|
DB_PASSWORD = password
|
|
9
9
|
DB_DATABASE = test
|
|
@@ -16,5 +16,5 @@ LOG_FORMAT = combined
|
|
|
16
16
|
LOG_DIR = ../logs
|
|
17
17
|
|
|
18
18
|
# CORS
|
|
19
|
-
ORIGIN =
|
|
19
|
+
ORIGIN = false
|
|
20
20
|
CREDENTIALS = true
|
|
@@ -3,7 +3,7 @@ PORT = 3000
|
|
|
3
3
|
|
|
4
4
|
# DATABASE
|
|
5
5
|
DB_HOST = localhost
|
|
6
|
-
DB_PORT =
|
|
6
|
+
DB_PORT = 5432
|
|
7
7
|
DB_USER = root
|
|
8
8
|
DB_PASSWORD = password
|
|
9
9
|
DB_DATABASE = test
|
|
@@ -16,5 +16,5 @@ LOG_FORMAT = dev
|
|
|
16
16
|
LOG_DIR = ../logs
|
|
17
17
|
|
|
18
18
|
# CORS
|
|
19
|
-
ORIGIN =
|
|
19
|
+
ORIGIN = true
|
|
20
20
|
CREDENTIALS = true
|
package/lib/graphql/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/graphql/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
|
-
"name": "
|
|
2
|
+
"name": "typescript-express-starter",
|
|
3
3
|
"version": "0.0.0",
|
|
4
|
-
"description": "TypeScript + GraphQL + TypeORM + Express API Server",
|
|
4
|
+
"description": "TypeScript + GraphQL + TypeORM + PostgreSQL + 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",
|
|
@@ -44,15 +44,12 @@
|
|
|
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/node": "^16.0.1",
|
|
54
52
|
"@types/supertest": "^2.0.11",
|
|
55
|
-
"@types/winston": "^2.4.4",
|
|
56
53
|
"@typescript-eslint/eslint-plugin": "^4.28.2",
|
|
57
54
|
"@typescript-eslint/parser": "^4.28.2",
|
|
58
55
|
"cross-env": "^7.0.3",
|
|
@@ -60,15 +57,15 @@
|
|
|
60
57
|
"eslint-config-prettier": "^8.3.0",
|
|
61
58
|
"eslint-plugin-prettier": "^3.4.0",
|
|
62
59
|
"husky": "^7.0.1",
|
|
63
|
-
"jest": "
|
|
60
|
+
"jest": "27.4.x",
|
|
64
61
|
"lint-staged": "^11.0.0",
|
|
65
62
|
"node-config": "^0.0.2",
|
|
66
63
|
"node-gyp": "^8.1.0",
|
|
67
64
|
"nodemon": "^2.0.9",
|
|
68
65
|
"pm2": "^5.1.0",
|
|
69
66
|
"prettier": "^2.3.2",
|
|
70
|
-
"supertest": "^6.
|
|
71
|
-
"ts-jest": "^27.
|
|
67
|
+
"supertest": "^6.2.2",
|
|
68
|
+
"ts-jest": "^27.1.4",
|
|
72
69
|
"ts-node": "^10.4.0",
|
|
73
70
|
"tsc-alias": "^1.4.1",
|
|
74
71
|
"tsconfig-paths": "^3.10.1",
|
package/lib/graphql/src/app.ts
CHANGED
|
@@ -50,9 +50,12 @@ class App {
|
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
private initializeMiddlewares() {
|
|
53
|
+
if (this.env === 'production') {
|
|
54
|
+
this.app.use(hpp());
|
|
55
|
+
this.app.use(helmet());
|
|
56
|
+
}
|
|
57
|
+
|
|
53
58
|
this.app.use(cors({ origin: ORIGIN, credentials: CREDENTIALS }));
|
|
54
|
-
this.app.use(hpp());
|
|
55
|
-
this.app.use(helmet());
|
|
56
59
|
this.app.use(compression());
|
|
57
60
|
this.app.use(express.json());
|
|
58
61
|
this.app.use(express.urlencoded({ extended: true }));
|
|
@@ -68,7 +71,7 @@ class App {
|
|
|
68
71
|
const apolloServer = new ApolloServer({
|
|
69
72
|
schema: schema,
|
|
70
73
|
plugins: [
|
|
71
|
-
|
|
74
|
+
this.env === 'production'
|
|
72
75
|
? ApolloServerPluginLandingPageProductionDefault({ footer: false })
|
|
73
76
|
: ApolloServerPluginLandingPageLocalDefault({ footer: false }),
|
|
74
77
|
],
|
|
@@ -2,4 +2,5 @@ import { config } from 'dotenv';
|
|
|
2
2
|
config({ path: `.env.${process.env.NODE_ENV || 'development'}.local` });
|
|
3
3
|
|
|
4
4
|
export const CREDENTIALS = process.env.CREDENTIALS === 'true';
|
|
5
|
-
export const
|
|
5
|
+
export const ORIGIN = process.env.ORIGIN === 'true';
|
|
6
|
+
export const { NODE_ENV, PORT, DB_HOST, DB_PORT, DB_USER, DB_PASSWORD, DB_DATABASE, SECRET_KEY, LOG_FORMAT, LOG_DIR } = process.env;
|
|
@@ -18,7 +18,7 @@ export default class AuthRepository {
|
|
|
18
18
|
if (findUser) throw new HttpException(409, `You're email ${userData.email} already exists`);
|
|
19
19
|
|
|
20
20
|
const hashedPassword = await hash(userData.password, 10);
|
|
21
|
-
const createUserData: User = await UserEntity.
|
|
21
|
+
const createUserData: User = await UserEntity.create({ ...userData, password: hashedPassword }).save();
|
|
22
22
|
|
|
23
23
|
return createUserData;
|
|
24
24
|
}
|
|
@@ -30,7 +30,7 @@ export default class UserRepository {
|
|
|
30
30
|
if (findUser) throw new HttpException(409, `You're email ${userData.email} already exists`);
|
|
31
31
|
|
|
32
32
|
const hashedPassword = await hash(userData.password, 10);
|
|
33
|
-
const createUserData: User = await UserEntity.
|
|
33
|
+
const createUserData: User = await UserEntity.create({ ...userData, password: hashedPassword }).save();
|
|
34
34
|
|
|
35
35
|
return createUserData;
|
|
36
36
|
}
|
package/lib/knex/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/knex/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",
|
|
@@ -22,12 +22,12 @@
|
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"bcrypt": "^5.0.1",
|
|
25
|
-
"class-transformer": "^0.
|
|
25
|
+
"class-transformer": "^0.5.1",
|
|
26
26
|
"class-validator": "^0.13.1",
|
|
27
27
|
"compression": "^1.7.4",
|
|
28
28
|
"cookie-parser": "^1.4.5",
|
|
29
29
|
"cors": "^2.8.5",
|
|
30
|
-
"dotenv": "^
|
|
30
|
+
"dotenv": "^10.0.0",
|
|
31
31
|
"envalid": "^7.1.0",
|
|
32
32
|
"express": "^4.17.1",
|
|
33
33
|
"helmet": "^4.6.0",
|
|
@@ -46,38 +46,35 @@
|
|
|
46
46
|
"@swc/cli": "^0.1.51",
|
|
47
47
|
"@swc/core": "^1.2.108",
|
|
48
48
|
"@types/bcrypt": "^5.0.0",
|
|
49
|
-
"@types/compression": "^1.7.
|
|
49
|
+
"@types/compression": "^1.7.1",
|
|
50
50
|
"@types/cookie-parser": "^1.4.2",
|
|
51
|
-
"@types/cors": "^2.8.
|
|
52
|
-
"@types/
|
|
53
|
-
"@types/express": "^4.17.11",
|
|
54
|
-
"@types/helmet": "^4.0.0",
|
|
51
|
+
"@types/cors": "^2.8.11",
|
|
52
|
+
"@types/express": "^4.17.13",
|
|
55
53
|
"@types/hpp": "^0.2.1",
|
|
56
|
-
"@types/jest": "
|
|
57
|
-
"@types/jsonwebtoken": "^8.5.
|
|
54
|
+
"@types/jest": "27.4.x",
|
|
55
|
+
"@types/jsonwebtoken": "^8.5.4",
|
|
58
56
|
"@types/knex": "^0.16.1",
|
|
59
|
-
"@types/morgan": "^1.9.
|
|
60
|
-
"@types/node": "^
|
|
57
|
+
"@types/morgan": "^1.9.3",
|
|
58
|
+
"@types/node": "^16.0.1",
|
|
61
59
|
"@types/supertest": "^2.0.11",
|
|
62
|
-
"@types/swagger-jsdoc": "^6.0.
|
|
63
|
-
"@types/swagger-ui-express": "^4.1.
|
|
64
|
-
"@
|
|
65
|
-
"@typescript-eslint/
|
|
66
|
-
"@typescript-eslint/parser": "^4.23.0",
|
|
60
|
+
"@types/swagger-jsdoc": "^6.0.1",
|
|
61
|
+
"@types/swagger-ui-express": "^4.1.3",
|
|
62
|
+
"@typescript-eslint/eslint-plugin": "^4.28.2",
|
|
63
|
+
"@typescript-eslint/parser": "^4.28.2",
|
|
67
64
|
"cross-env": "^7.0.3",
|
|
68
|
-
"eslint": "^7.
|
|
65
|
+
"eslint": "^7.30.0",
|
|
69
66
|
"eslint-config-prettier": "^8.3.0",
|
|
70
67
|
"eslint-plugin-prettier": "^3.4.0",
|
|
71
|
-
"husky": "^
|
|
72
|
-
"jest": "
|
|
68
|
+
"husky": "^7.0.1",
|
|
69
|
+
"jest": "27.4.x",
|
|
73
70
|
"lint-staged": "^11.0.0",
|
|
74
71
|
"node-config": "0.0.2",
|
|
75
|
-
"node-gyp": "^8.
|
|
76
|
-
"nodemon": "^2.0.
|
|
72
|
+
"node-gyp": "^8.1.0",
|
|
73
|
+
"nodemon": "^2.0.9",
|
|
77
74
|
"pm2": "^5.1.0",
|
|
78
|
-
"prettier": "^2.3.
|
|
79
|
-
"supertest": "^6.
|
|
80
|
-
"ts-jest": "^27.
|
|
75
|
+
"prettier": "^2.3.2",
|
|
76
|
+
"supertest": "^6.2.2",
|
|
77
|
+
"ts-jest": "^27.1.4",
|
|
81
78
|
"ts-node": "^10.4.0",
|
|
82
79
|
"tsc-alias": "^1.4.1",
|
|
83
80
|
"tsconfig-paths": "^3.10.1",
|