typescript-express-starter 6.1.0 → 7.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 +122 -53
- package/README.md +127 -59
- package/bin/cli.js +4 -3
- package/lib/default/.swcrc +41 -0
- package/lib/default/Dockerfile +1 -1
- package/lib/default/ecosystem.config.js +40 -24
- package/lib/default/nodemon.json +2 -2
- package/lib/default/package.json +15 -8
- package/lib/default/src/app.ts +1 -2
- package/lib/default/src/http/auth.http +12 -15
- package/lib/default/src/http/users.http +12 -16
- package/lib/default/src/index.ts +1 -0
- package/lib/default/src/middlewares/auth.middleware.ts +3 -3
- package/lib/default/src/models/users.model.ts +5 -5
- package/lib/default/src/server.ts +1 -2
- package/lib/default/src/services/auth.service.ts +5 -5
- package/lib/default/src/services/users.service.ts +3 -3
- package/lib/default/src/tests/auth.test.ts +4 -4
- package/lib/default/src/tests/users.test.ts +4 -4
- package/lib/default/src/utils/logger.ts +5 -5
- package/lib/default/tsconfig.json +2 -2
- package/lib/graphql/.dockerignore +18 -0
- package/lib/graphql/.editorconfig +9 -0
- package/lib/graphql/.env +1 -0
- package/lib/graphql/.eslintignore +1 -0
- package/lib/graphql/.eslintrc +18 -0
- package/lib/graphql/.huskyrc +5 -0
- package/lib/graphql/.lintstagedrc.json +5 -0
- package/lib/graphql/.prettierrc +8 -0
- package/lib/graphql/.swcrc +39 -0
- package/lib/graphql/.vscode/launch.json +35 -0
- package/lib/graphql/.vscode/settings.json +6 -0
- package/lib/graphql/Dockerfile +24 -0
- package/lib/graphql/Makefile +6 -0
- package/lib/graphql/docker-compose.yml +50 -0
- package/lib/graphql/ecosystem.config.js +59 -0
- package/lib/graphql/jest.config.js +12 -0
- package/lib/graphql/nginx.conf +40 -0
- package/lib/graphql/nodemon.json +12 -0
- package/lib/graphql/package.json +79 -0
- package/lib/graphql/src/app.ts +105 -0
- package/lib/graphql/src/configs/development.json +19 -0
- package/lib/graphql/src/configs/production.json +19 -0
- package/lib/graphql/src/configs/test.json +19 -0
- package/lib/graphql/src/databases/index.ts +24 -0
- package/lib/graphql/src/dtos/users.dto.ts +14 -0
- package/lib/{typeorm/src/entity → graphql/src/entities}/users.entity.ts +3 -3
- package/lib/graphql/src/exceptions/HttpException.ts +10 -0
- package/lib/graphql/src/http/auth.http +49 -0
- package/lib/graphql/src/http/users.http +78 -0
- package/lib/graphql/src/index.ts +1 -0
- package/lib/graphql/src/interfaces/auth.interface.ts +14 -0
- package/lib/graphql/src/interfaces/db.interface.ts +7 -0
- package/lib/graphql/src/interfaces/users.interface.ts +5 -0
- package/lib/graphql/src/middlewares/auth.middleware.ts +32 -0
- package/lib/graphql/src/middlewares/error.middleware.ts +17 -0
- package/lib/graphql/src/repositories/auth.repository.ts +61 -0
- package/lib/graphql/src/repositories/users.repository.ts +60 -0
- package/lib/graphql/src/resolvers/auth.resolver.ts +32 -0
- package/lib/graphql/src/resolvers/users.resolver.ts +47 -0
- package/lib/graphql/src/server.ts +14 -0
- package/lib/graphql/src/tests/auth.test.ts +52 -0
- package/lib/graphql/src/tests/index.test.ts +18 -0
- package/lib/graphql/src/tests/users.test.ts +71 -0
- package/lib/graphql/src/typedefs/users.type.ts +13 -0
- package/lib/graphql/src/utils/logger.ts +75 -0
- package/lib/graphql/src/utils/util.ts +19 -0
- package/lib/graphql/src/utils/validateEnv.ts +10 -0
- package/lib/graphql/tsconfig.json +39 -0
- package/lib/knex/.swcrc +39 -0
- package/lib/knex/Dockerfile +1 -1
- package/lib/knex/ecosystem.config.js +57 -43
- package/lib/knex/knexfile.ts +6 -6
- package/lib/knex/nodemon.json +2 -2
- package/lib/knex/package.json +14 -8
- package/lib/knex/src/app.ts +2 -3
- package/lib/knex/src/databases/index.ts +6 -6
- package/lib/knex/src/http/auth.http +12 -15
- package/lib/knex/src/http/users.http +12 -16
- package/lib/knex/src/index.ts +1 -0
- package/lib/knex/src/middlewares/auth.middleware.ts +4 -4
- package/lib/knex/src/server.ts +1 -2
- package/lib/knex/src/services/auth.service.ts +5 -5
- package/lib/knex/src/services/users.service.ts +3 -3
- package/lib/knex/src/tests/auth.test.ts +2 -2
- package/lib/knex/src/tests/index.test.ts +1 -1
- package/lib/knex/src/tests/users.test.ts +2 -2
- package/lib/knex/src/utils/logger.ts +5 -5
- package/lib/knex/tsconfig.json +2 -2
- package/lib/mongoose/.swcrc +39 -0
- package/lib/mongoose/Dockerfile +1 -1
- package/lib/mongoose/docker-compose.yml +0 -4
- package/lib/mongoose/ecosystem.config.js +42 -27
- package/lib/mongoose/nodemon.json +2 -2
- package/lib/mongoose/package.json +15 -8
- package/lib/mongoose/src/app.ts +2 -3
- package/lib/mongoose/src/configs/development.json +1 -1
- package/lib/mongoose/src/configs/production.json +1 -1
- package/lib/mongoose/src/configs/test.json +1 -1
- package/lib/mongoose/src/http/auth.http +32 -0
- package/lib/mongoose/src/http/users.http +34 -0
- package/lib/mongoose/src/index.ts +1 -0
- package/lib/mongoose/src/middlewares/auth.middleware.ts +3 -3
- package/lib/mongoose/src/server.ts +1 -2
- package/lib/mongoose/src/services/auth.service.ts +5 -5
- package/lib/mongoose/src/services/users.service.ts +3 -3
- package/lib/mongoose/src/utils/logger.ts +5 -5
- package/lib/mongoose/tsconfig.json +2 -2
- package/lib/prisma/.env +1 -1
- package/lib/prisma/.swcrc +37 -0
- package/lib/prisma/Dockerfile +1 -1
- package/lib/prisma/docker-compose.yml +1 -6
- package/lib/prisma/ecosystem.config.js +40 -24
- package/lib/prisma/nodemon.json +2 -2
- package/lib/prisma/package.json +17 -10
- package/lib/prisma/src/app.ts +2 -3
- package/lib/prisma/src/http/auth.http +12 -15
- package/lib/prisma/src/http/users.http +12 -16
- package/lib/prisma/src/index.ts +1 -0
- package/lib/prisma/src/middlewares/auth.middleware.ts +4 -4
- package/lib/prisma/src/server.ts +1 -2
- package/lib/prisma/src/services/auth.service.ts +5 -5
- package/lib/prisma/src/services/users.service.ts +3 -3
- package/lib/prisma/src/utils/logger.ts +5 -5
- package/lib/prisma/tsconfig.json +2 -2
- package/lib/routing-controllers/.swcrc +37 -0
- package/lib/routing-controllers/Dockerfile +1 -1
- package/lib/routing-controllers/ecosystem.config.js +40 -24
- package/lib/routing-controllers/nodemon.json +2 -2
- package/lib/routing-controllers/package.json +15 -9
- package/lib/routing-controllers/src/app.ts +3 -4
- package/lib/routing-controllers/src/http/auth.http +12 -15
- package/lib/routing-controllers/src/http/users.http +12 -16
- package/lib/routing-controllers/src/index.ts +1 -0
- package/lib/routing-controllers/src/middlewares/auth.middleware.ts +3 -3
- package/lib/routing-controllers/src/middlewares/validation.middleware.ts +10 -2
- package/lib/routing-controllers/src/models/users.model.ts +5 -5
- package/lib/routing-controllers/src/server.ts +1 -3
- package/lib/routing-controllers/src/services/auth.service.ts +5 -5
- package/lib/routing-controllers/src/services/users.service.ts +3 -3
- package/lib/routing-controllers/src/utils/logger.ts +5 -5
- package/lib/routing-controllers/tsconfig.json +2 -2
- package/lib/sequelize/.swcrc +39 -0
- package/lib/sequelize/Dockerfile +1 -1
- package/lib/sequelize/docker-compose.yml +1 -6
- package/lib/sequelize/ecosystem.config.js +42 -27
- package/lib/sequelize/nodemon.json +2 -2
- package/lib/sequelize/package.json +15 -8
- package/lib/sequelize/src/app.ts +1 -2
- package/lib/sequelize/src/configs/development.json +2 -2
- package/lib/sequelize/src/configs/production.json +1 -1
- package/lib/sequelize/src/configs/test.json +1 -1
- package/lib/sequelize/src/http/auth.http +32 -0
- package/lib/sequelize/src/http/users.http +34 -0
- package/lib/sequelize/src/index.ts +1 -0
- package/lib/sequelize/src/middlewares/auth.middleware.ts +4 -4
- package/lib/sequelize/src/server.ts +1 -2
- package/lib/sequelize/src/services/auth.service.ts +5 -5
- package/lib/sequelize/src/services/users.service.ts +3 -3
- package/lib/sequelize/src/utils/logger.ts +5 -5
- package/lib/sequelize/tsconfig.json +2 -2
- package/lib/starter.js +5 -9
- package/lib/typeorm/.swcrc +39 -0
- package/lib/typeorm/Dockerfile +1 -1
- package/lib/typeorm/docker-compose.yml +1 -1
- package/lib/typeorm/ecosystem.config.js +42 -27
- package/lib/typeorm/nodemon.json +2 -2
- package/lib/typeorm/package.json +15 -8
- package/lib/typeorm/src/app.ts +1 -2
- package/lib/typeorm/src/configs/development.json +1 -1
- package/lib/typeorm/src/configs/production.json +1 -1
- package/lib/typeorm/src/configs/test.json +1 -1
- package/lib/typeorm/src/databases/index.ts +5 -5
- package/lib/typeorm/src/entities/users.entity.ts +26 -0
- package/lib/typeorm/src/http/auth.http +12 -15
- package/lib/typeorm/src/http/users.http +12 -16
- package/lib/typeorm/src/index.ts +1 -0
- package/lib/typeorm/src/middlewares/auth.middleware.ts +5 -9
- package/lib/typeorm/src/server.ts +1 -2
- package/lib/typeorm/src/services/auth.service.ts +13 -17
- package/lib/typeorm/src/services/users.service.ts +16 -22
- package/lib/typeorm/src/utils/logger.ts +5 -5
- package/lib/typeorm/tsconfig.json +3 -3
- package/package.json +13 -4
|
@@ -1,25 +1,22 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import { hash } from 'bcrypt';
|
|
2
|
+
import { EntityRepository, Repository } from 'typeorm';
|
|
3
3
|
import { CreateUserDto } from '@dtos/users.dto';
|
|
4
|
-
import { UserEntity } from '@
|
|
4
|
+
import { UserEntity } from '@entities/users.entity';
|
|
5
5
|
import { HttpException } from '@exceptions/HttpException';
|
|
6
6
|
import { User } from '@interfaces/users.interface';
|
|
7
7
|
import { isEmpty } from '@utils/util';
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
@EntityRepository()
|
|
10
|
+
class UserService extends Repository<UserEntity> {
|
|
12
11
|
public async findAllUser(): Promise<User[]> {
|
|
13
|
-
const
|
|
14
|
-
const users: User[] = await userRepository.find();
|
|
12
|
+
const users: User[] = await UserEntity.find();
|
|
15
13
|
return users;
|
|
16
14
|
}
|
|
17
15
|
|
|
18
16
|
public async findUserById(userId: number): Promise<User> {
|
|
19
17
|
if (isEmpty(userId)) throw new HttpException(400, "You're not userId");
|
|
20
18
|
|
|
21
|
-
const
|
|
22
|
-
const findUser: User = await userRepository.findOne({ where: { id: userId } });
|
|
19
|
+
const findUser: User = await UserEntity.findOne({ where: { id: userId } });
|
|
23
20
|
if (!findUser) throw new HttpException(409, "You're not user");
|
|
24
21
|
|
|
25
22
|
return findUser;
|
|
@@ -28,12 +25,11 @@ class UserService {
|
|
|
28
25
|
public async createUser(userData: CreateUserDto): Promise<User> {
|
|
29
26
|
if (isEmpty(userData)) throw new HttpException(400, "You're not userData");
|
|
30
27
|
|
|
31
|
-
const
|
|
32
|
-
const findUser: User = await userRepository.findOne({ where: { email: userData.email } });
|
|
28
|
+
const findUser: User = await UserEntity.findOne({ where: { email: userData.email } });
|
|
33
29
|
if (findUser) throw new HttpException(409, `You're email ${userData.email} already exists`);
|
|
34
30
|
|
|
35
|
-
const hashedPassword = await
|
|
36
|
-
const createUserData: User = await
|
|
31
|
+
const hashedPassword = await hash(userData.password, 10);
|
|
32
|
+
const createUserData: User = await UserEntity.create({ ...userData, password: hashedPassword }).save();
|
|
37
33
|
|
|
38
34
|
return createUserData;
|
|
39
35
|
}
|
|
@@ -41,25 +37,23 @@ class UserService {
|
|
|
41
37
|
public async updateUser(userId: number, userData: CreateUserDto): Promise<User> {
|
|
42
38
|
if (isEmpty(userData)) throw new HttpException(400, "You're not userData");
|
|
43
39
|
|
|
44
|
-
const
|
|
45
|
-
const findUser: User = await userRepository.findOne({ where: { id: userId } });
|
|
40
|
+
const findUser: User = await UserEntity.findOne({ where: { id: userId } });
|
|
46
41
|
if (!findUser) throw new HttpException(409, "You're not user");
|
|
47
42
|
|
|
48
|
-
const hashedPassword = await
|
|
49
|
-
await
|
|
43
|
+
const hashedPassword = await hash(userData.password, 10);
|
|
44
|
+
await UserEntity.update(userId, { ...userData, password: hashedPassword });
|
|
50
45
|
|
|
51
|
-
const updateUser: User = await
|
|
46
|
+
const updateUser: User = await UserEntity.findOne({ where: { id: userId } });
|
|
52
47
|
return updateUser;
|
|
53
48
|
}
|
|
54
49
|
|
|
55
50
|
public async deleteUser(userId: number): Promise<User> {
|
|
56
51
|
if (isEmpty(userId)) throw new HttpException(400, "You're not userId");
|
|
57
52
|
|
|
58
|
-
const
|
|
59
|
-
const findUser: User = await userRepository.findOne({ where: { id: userId } });
|
|
53
|
+
const findUser: User = await UserEntity.findOne({ where: { id: userId } });
|
|
60
54
|
if (!findUser) throw new HttpException(409, "You're not user");
|
|
61
55
|
|
|
62
|
-
await
|
|
56
|
+
await UserEntity.delete({ id: userId });
|
|
63
57
|
return findUser;
|
|
64
58
|
}
|
|
65
59
|
}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import config from 'config';
|
|
2
|
-
import
|
|
3
|
-
import
|
|
2
|
+
import { existsSync, mkdirSync } from 'fs';
|
|
3
|
+
import { join } from 'path';
|
|
4
4
|
import winston from 'winston';
|
|
5
5
|
import winstonDaily from 'winston-daily-rotate-file';
|
|
6
6
|
|
|
7
7
|
// logs dir
|
|
8
|
-
const logDir: string =
|
|
8
|
+
const logDir: string = join(__dirname, config.get('log.dir'));
|
|
9
9
|
|
|
10
|
-
if (!
|
|
11
|
-
|
|
10
|
+
if (!existsSync(logDir)) {
|
|
11
|
+
mkdirSync(logDir);
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
// Define log format
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"pretty": true,
|
|
14
14
|
"sourceMap": true,
|
|
15
15
|
"declaration": true,
|
|
16
|
-
"outDir": "
|
|
16
|
+
"outDir": "dist",
|
|
17
17
|
"allowJs": true,
|
|
18
18
|
"noEmit": false,
|
|
19
19
|
"esModuleInterop": true,
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"@controllers/*": ["controllers/*"],
|
|
26
26
|
"@databases": ["databases"],
|
|
27
27
|
"@dtos/*": ["dtos/*"],
|
|
28
|
-
"@
|
|
28
|
+
"@entities/*": ["entities/*"],
|
|
29
29
|
"@exceptions/*": ["exceptions/*"],
|
|
30
30
|
"@interfaces/*": ["interfaces/*"],
|
|
31
31
|
"@middlewares/*": ["middlewares/*"],
|
|
@@ -35,5 +35,5 @@
|
|
|
35
35
|
}
|
|
36
36
|
},
|
|
37
37
|
"include": ["src/**/*.ts", "src/**/*.json", ".env"],
|
|
38
|
-
"exclude": ["node_modules"]
|
|
38
|
+
"exclude": ["node_modules", "src/http", "src/logs", "src/tests"]
|
|
39
39
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "typescript-express-starter",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "7.0.0",
|
|
4
4
|
"description": "Quick and Easy TypeScript Express Starter",
|
|
5
5
|
"author": "AGUMON <ljlm0402@gmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -14,7 +14,8 @@
|
|
|
14
14
|
"typeorm",
|
|
15
15
|
"knex",
|
|
16
16
|
"prisma",
|
|
17
|
-
"
|
|
17
|
+
"graphql",
|
|
18
|
+
"apollo",
|
|
18
19
|
"jest",
|
|
19
20
|
"nodemon",
|
|
20
21
|
"jsonwebtoken",
|
|
@@ -32,7 +33,8 @@
|
|
|
32
33
|
"mysql",
|
|
33
34
|
"mariadb",
|
|
34
35
|
"mongodb",
|
|
35
|
-
"postgresql"
|
|
36
|
+
"postgresql",
|
|
37
|
+
"swc"
|
|
36
38
|
],
|
|
37
39
|
"main": "bin/cli.js",
|
|
38
40
|
"bin": {
|
|
@@ -50,6 +52,13 @@
|
|
|
50
52
|
"ora": "^4.0.3"
|
|
51
53
|
},
|
|
52
54
|
"devDependencies": {},
|
|
55
|
+
"publishConfig": {
|
|
56
|
+
"access": "public"
|
|
57
|
+
},
|
|
58
|
+
"engines": {
|
|
59
|
+
"node": ">= 10.13.0",
|
|
60
|
+
"npm": ">= 6.11.0"
|
|
61
|
+
},
|
|
53
62
|
"repository": {
|
|
54
63
|
"type": "git",
|
|
55
64
|
"url": "git+https://github.com/ljlm0402/typescript-express-starter.git"
|
|
@@ -58,4 +67,4 @@
|
|
|
58
67
|
"url": "https://github.com/ljlm0402/typescript-express-starter/issues"
|
|
59
68
|
},
|
|
60
69
|
"homepage": "https://github.com/ljlm0402/typescript-express-starter#readme"
|
|
61
|
-
}
|
|
70
|
+
}
|