typescript-express-starter 10.0.0 → 10.0.1
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/CONTRIBUTORS.md +8 -0
- package/lib/default/Makefile +1 -1
- package/lib/graphql/Makefile +1 -1
- package/lib/graphql/src/app.ts +2 -3
- package/lib/graphql/src/database/index.ts +23 -19
- package/lib/knex/Makefile +2 -2
- package/lib/knex/src/app.ts +3 -4
- package/lib/knex/src/database/index.ts +20 -17
- package/lib/mikro-orm/Makefile +2 -2
- package/lib/mikro-orm/src/app.ts +2 -1
- package/lib/mongoose/Makefile +2 -2
- package/lib/mongoose/src/app.ts +2 -7
- package/lib/mongoose/src/database/index.ts +17 -8
- package/lib/node-postgres/Makefile +1 -1
- package/lib/node-postgres/src/app.ts +2 -2
- package/lib/prisma/Makefile +2 -2
- package/lib/prisma/src/routes/users.route.ts +1 -1
- package/lib/routing-controllers/Makefile +1 -1
- package/lib/sequelize/.sequelizerc +8 -0
- package/lib/sequelize/Makefile +2 -2
- package/lib/sequelize/package.json +3 -1
- package/lib/sequelize/src/app.ts +2 -2
- package/lib/sequelize/src/config/sequelize-cli.js +15 -0
- package/lib/typegoose/Makefile +2 -2
- package/lib/typegoose/src/app.ts +4 -8
- package/lib/typegoose/src/database/index.ts +12 -5
- package/lib/typeorm/Makefile +1 -1
- package/lib/typeorm/src/app.ts +2 -3
- package/lib/typeorm/src/database/index.ts +22 -18
- package/lib/typeorm/src/test/auth.test.ts +1 -1
- package/lib/typeorm/src/test/users.test.ts +1 -1
- package/package.json +1 -1
- package/.vscode/configurationCache.log +0 -1
- package/.vscode/dryrun.log +0 -6
- package/.vscode/settings.json +0 -3
- package/.vscode/targets.log +0 -239
- /package/lib/default/src/exceptions/{httpException.ts → HttpException.ts} +0 -0
- /package/lib/graphql/src/exceptions/{httpException.ts → HttpException.ts} +0 -0
- /package/lib/knex/src/exceptions/{httpException.ts → HttpException.ts} +0 -0
- /package/lib/mikro-orm/src/exceptions/{httpException.ts → HttpException.ts} +0 -0
- /package/lib/mongoose/src/exceptions/{httpException.ts → HttpException.ts} +0 -0
- /package/lib/prisma/src/exceptions/{httpException.ts → HttpException.ts} +0 -0
- /package/lib/routing-controllers/src/exceptions/{httpException.ts → HttpException.ts} +0 -0
- /package/lib/sequelize/src/exceptions/{httpException.ts → HttpException.ts} +0 -0
- /package/lib/typegoose/src/exceptions/{httpException.ts → HttpException.ts} +0 -0
- /package/lib/typeorm/src/exceptions/{httpException.ts → HttpException.ts} +0 -0
package/CONTRIBUTORS.md
CHANGED
|
@@ -59,3 +59,11 @@
|
|
|
59
59
|
- Markus Laubscher [https://github.com/markuslaubscher](https://github.com/markuslaubscher)
|
|
60
60
|
|
|
61
61
|
- coder-palak [https://github.com/coder-palak](https://github.com/coder-palak)
|
|
62
|
+
|
|
63
|
+
- H2RO [https://github.com/primary-1](https://github.com/primary-1)
|
|
64
|
+
|
|
65
|
+
- Emmanuel Yeboah [https://github.com/noelzappy](https://github.com/noelzappy)
|
|
66
|
+
|
|
67
|
+
- Jonathan Felicity [https://github.com/jonathanfelicity](https://github.com/jonathanfelicity)
|
|
68
|
+
|
|
69
|
+
- Hichem Fantar [https://github.com/hichemfantar](https://github.com/hichemfantar)
|
package/lib/default/Makefile
CHANGED
|
@@ -25,7 +25,7 @@ build: ## Build the container image - Production
|
|
|
25
25
|
docker build -t ${APP_NAME}\
|
|
26
26
|
-f Dockerfile.prod .
|
|
27
27
|
|
|
28
|
-
build-dev: ## Build the container image -
|
|
28
|
+
build-dev: ## Build the container image - Development
|
|
29
29
|
docker build -t ${APP_NAME}\
|
|
30
30
|
-f Dockerfile.dev .
|
|
31
31
|
|
package/lib/graphql/Makefile
CHANGED
|
@@ -25,7 +25,7 @@ build: ## Build the container image - Production
|
|
|
25
25
|
docker build -t ${APP_NAME}\
|
|
26
26
|
-f Dockerfile.prod .
|
|
27
27
|
|
|
28
|
-
build-dev: ## Build the container image -
|
|
28
|
+
build-dev: ## Build the container image - Development
|
|
29
29
|
docker build -t ${APP_NAME}\
|
|
30
30
|
-f Dockerfile.dev .
|
|
31
31
|
|
package/lib/graphql/src/app.ts
CHANGED
|
@@ -8,7 +8,6 @@ import express from 'express';
|
|
|
8
8
|
import helmet from 'helmet';
|
|
9
9
|
import hpp from 'hpp';
|
|
10
10
|
import { buildSchema } from 'type-graphql';
|
|
11
|
-
import { createConnection } from 'typeorm';
|
|
12
11
|
import { NODE_ENV, PORT, ORIGIN, CREDENTIALS } from '@config';
|
|
13
12
|
import { dbConnection } from '@database';
|
|
14
13
|
import { AuthMiddleware, AuthCheckerMiddleware } from '@middlewares/auth.middleware';
|
|
@@ -45,8 +44,8 @@ export class App {
|
|
|
45
44
|
return this.app;
|
|
46
45
|
}
|
|
47
46
|
|
|
48
|
-
private connectToDatabase() {
|
|
49
|
-
|
|
47
|
+
private async connectToDatabase() {
|
|
48
|
+
await dbConnection();
|
|
50
49
|
}
|
|
51
50
|
|
|
52
51
|
private initializeMiddlewares() {
|
|
@@ -1,22 +1,26 @@
|
|
|
1
1
|
import { join } from 'path';
|
|
2
|
-
import { ConnectionOptions } from 'typeorm';
|
|
2
|
+
import { createConnection, ConnectionOptions } from 'typeorm';
|
|
3
3
|
import { POSTGRES_USER, POSTGRES_PASSWORD, POSTGRES_HOST, POSTGRES_PORT, POSTGRES_DB } from '@config';
|
|
4
4
|
|
|
5
|
-
export const dbConnection
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
5
|
+
export const dbConnection = async () => {
|
|
6
|
+
const dbConfig: ConnectionOptions = {
|
|
7
|
+
type: 'postgres',
|
|
8
|
+
username: POSTGRES_USER,
|
|
9
|
+
password: POSTGRES_PASSWORD,
|
|
10
|
+
host: POSTGRES_HOST,
|
|
11
|
+
port: Number(POSTGRES_PORT),
|
|
12
|
+
database: POSTGRES_DB,
|
|
13
|
+
synchronize: true,
|
|
14
|
+
logging: false,
|
|
15
|
+
entities: [join(__dirname, '../**/*.entity{.ts,.js}')],
|
|
16
|
+
migrations: [join(__dirname, '../**/*.migration{.ts,.js}')],
|
|
17
|
+
subscribers: [join(__dirname, '../**/*.subscriber{.ts,.js}')],
|
|
18
|
+
cli: {
|
|
19
|
+
entitiesDir: 'src/entities',
|
|
20
|
+
migrationsDir: 'src/migration',
|
|
21
|
+
subscribersDir: 'src/subscriber',
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
await createConnection(dbConfig);
|
|
26
|
+
}
|
package/lib/knex/Makefile
CHANGED
|
@@ -25,7 +25,7 @@ build: ## Build the container image - Production
|
|
|
25
25
|
docker build -t ${APP_NAME}\
|
|
26
26
|
-f Dockerfile.prod .
|
|
27
27
|
|
|
28
|
-
build-dev: ## Build the container image -
|
|
28
|
+
build-dev: ## Build the container image - Development
|
|
29
29
|
docker build -t ${APP_NAME}\
|
|
30
30
|
-f Dockerfile.dev .
|
|
31
31
|
|
|
@@ -43,4 +43,4 @@ remove: ## Remove the volumes
|
|
|
43
43
|
|
|
44
44
|
#-- Database
|
|
45
45
|
db: ## Start the local database MySQL
|
|
46
|
-
docker-compose up -d mysql
|
|
46
|
+
docker-compose up -d mysql
|
package/lib/knex/src/app.ts
CHANGED
|
@@ -6,11 +6,10 @@ import express from 'express';
|
|
|
6
6
|
import helmet from 'helmet';
|
|
7
7
|
import hpp from 'hpp';
|
|
8
8
|
import morgan from 'morgan';
|
|
9
|
-
import { Model } from 'objection';
|
|
10
9
|
import swaggerJSDoc from 'swagger-jsdoc';
|
|
11
10
|
import swaggerUi from 'swagger-ui-express';
|
|
12
11
|
import { NODE_ENV, PORT, LOG_FORMAT, ORIGIN, CREDENTIALS } from '@config';
|
|
13
|
-
import {
|
|
12
|
+
import { dbConnection } from '@database';
|
|
14
13
|
import { Routes } from '@interfaces/routes.interface';
|
|
15
14
|
import { ErrorMiddleware } from '@middlewares/error.middleware';
|
|
16
15
|
import { logger, stream } from '@utils/logger';
|
|
@@ -45,8 +44,8 @@ export class App {
|
|
|
45
44
|
return this.app;
|
|
46
45
|
}
|
|
47
46
|
|
|
48
|
-
private connectToDatabase() {
|
|
49
|
-
|
|
47
|
+
private async connectToDatabase() {
|
|
48
|
+
await dbConnection();
|
|
50
49
|
}
|
|
51
50
|
|
|
52
51
|
private initializeMiddlewares() {
|
|
@@ -1,21 +1,24 @@
|
|
|
1
|
+
import { Model } from 'objection';
|
|
1
2
|
import Knex from 'knex';
|
|
2
3
|
import { DB_USER, DB_PASSWORD, DB_HOST, DB_PORT, DB_DATABASE } from '@config';
|
|
3
4
|
|
|
4
|
-
const dbConnection = {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
5
|
+
export const dbConnection = async () => {
|
|
6
|
+
const dbConfig = {
|
|
7
|
+
client: 'mysql',
|
|
8
|
+
connection: {
|
|
9
|
+
charset: 'utf8',
|
|
10
|
+
timezone: 'UTC',
|
|
11
|
+
user: DB_USER,
|
|
12
|
+
password: DB_PASSWORD,
|
|
13
|
+
host: DB_HOST,
|
|
14
|
+
port: DB_PORT,
|
|
15
|
+
database: DB_DATABASE,
|
|
16
|
+
},
|
|
17
|
+
pool: {
|
|
18
|
+
min: 2,
|
|
19
|
+
max: 10,
|
|
20
|
+
},
|
|
21
|
+
};
|
|
20
22
|
|
|
21
|
-
|
|
23
|
+
await Model.knex(Knex(dbConfig));
|
|
24
|
+
};
|
package/lib/mikro-orm/Makefile
CHANGED
|
@@ -25,7 +25,7 @@ build: ## Build the container image - Production
|
|
|
25
25
|
docker build -t ${APP_NAME}\
|
|
26
26
|
-f Dockerfile.prod .
|
|
27
27
|
|
|
28
|
-
build-dev: ## Build the container image -
|
|
28
|
+
build-dev: ## Build the container image - Development
|
|
29
29
|
docker build -t ${APP_NAME}\
|
|
30
30
|
-f Dockerfile.dev .
|
|
31
31
|
|
|
@@ -43,4 +43,4 @@ remove: ## Remove the volumes
|
|
|
43
43
|
|
|
44
44
|
#-- Database
|
|
45
45
|
db: ## Start the local database MongoDB
|
|
46
|
-
docker-compose up -d mongo
|
|
46
|
+
docker-compose up -d mongo
|
package/lib/mikro-orm/src/app.ts
CHANGED
|
@@ -53,8 +53,9 @@ export class App {
|
|
|
53
53
|
DI.userRepository = DI.orm.em.getRepository(UserEntity);
|
|
54
54
|
} catch (error) {
|
|
55
55
|
logger.error(error);
|
|
56
|
+
} finally {
|
|
57
|
+
this.app.use((_1, _2, next) => RequestContext.create(DI.orm.em, next));
|
|
56
58
|
}
|
|
57
|
-
this.app.use((_1, _2, next) => RequestContext.create(DI.orm.em, next));
|
|
58
59
|
}
|
|
59
60
|
|
|
60
61
|
private initializeMiddlewares() {
|
package/lib/mongoose/Makefile
CHANGED
|
@@ -25,7 +25,7 @@ build: ## Build the container image - Production
|
|
|
25
25
|
docker build -t ${APP_NAME}\
|
|
26
26
|
-f Dockerfile.prod .
|
|
27
27
|
|
|
28
|
-
build-dev: ## Build the container image -
|
|
28
|
+
build-dev: ## Build the container image - Development
|
|
29
29
|
docker build -t ${APP_NAME}\
|
|
30
30
|
-f Dockerfile.dev .
|
|
31
31
|
|
|
@@ -43,4 +43,4 @@ remove: ## Remove the volumes
|
|
|
43
43
|
|
|
44
44
|
#-- Database
|
|
45
45
|
db: ## Start the local database MongoDB
|
|
46
|
-
docker-compose up -d mongo
|
|
46
|
+
docker-compose up -d mongo
|
package/lib/mongoose/src/app.ts
CHANGED
|
@@ -6,11 +6,10 @@ import express from 'express';
|
|
|
6
6
|
import helmet from 'helmet';
|
|
7
7
|
import hpp from 'hpp';
|
|
8
8
|
import morgan from 'morgan';
|
|
9
|
-
import { connect, set } from 'mongoose';
|
|
10
9
|
import swaggerJSDoc from 'swagger-jsdoc';
|
|
11
10
|
import swaggerUi from 'swagger-ui-express';
|
|
12
11
|
import { NODE_ENV, PORT, LOG_FORMAT, ORIGIN, CREDENTIALS } from '@config';
|
|
13
|
-
import { dbConnection } from '@
|
|
12
|
+
import { dbConnection } from '@database';
|
|
14
13
|
import { Routes } from '@interfaces/routes.interface';
|
|
15
14
|
import { ErrorMiddleware } from '@middlewares/error.middleware';
|
|
16
15
|
import { logger, stream } from '@utils/logger';
|
|
@@ -46,11 +45,7 @@ export class App {
|
|
|
46
45
|
}
|
|
47
46
|
|
|
48
47
|
private async connectToDatabase() {
|
|
49
|
-
|
|
50
|
-
set('debug', true);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
await connect(dbConnection.url, dbConnection.options);
|
|
48
|
+
await dbConnection();
|
|
54
49
|
}
|
|
55
50
|
|
|
56
51
|
private initializeMiddlewares() {
|
|
@@ -1,9 +1,18 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { connect, set } from 'mongoose';
|
|
2
|
+
import { NODE_ENV, DB_HOST, DB_PORT, DB_DATABASE } from '@config';
|
|
2
3
|
|
|
3
|
-
export const dbConnection = {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
4
|
+
export const dbConnection = async () => {
|
|
5
|
+
const dbConfig = {
|
|
6
|
+
url: `mongodb://${DB_HOST}:${DB_PORT}/${DB_DATABASE}`,
|
|
7
|
+
options: {
|
|
8
|
+
useNewUrlParser: true,
|
|
9
|
+
useUnifiedTopology: true
|
|
10
|
+
},
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
if (NODE_ENV !== 'production') {
|
|
14
|
+
set('debug', true);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
await connect(dbConfig.url, dbConfig.options);
|
|
18
|
+
}
|
|
@@ -25,7 +25,7 @@ build: ## Build the container image - Production
|
|
|
25
25
|
docker build -t ${APP_NAME}\
|
|
26
26
|
-f Dockerfile.prod .
|
|
27
27
|
|
|
28
|
-
build-dev: ## Build the container image -
|
|
28
|
+
build-dev: ## Build the container image - Development
|
|
29
29
|
docker build -t ${APP_NAME}\
|
|
30
30
|
-f Dockerfile.dev .
|
|
31
31
|
|
package/lib/prisma/Makefile
CHANGED
|
@@ -25,7 +25,7 @@ build: ## Build the container image - Production
|
|
|
25
25
|
docker build -t ${APP_NAME}\
|
|
26
26
|
-f Dockerfile.prod .
|
|
27
27
|
|
|
28
|
-
build-dev: ## Build the container image -
|
|
28
|
+
build-dev: ## Build the container image - Development
|
|
29
29
|
docker build -t ${APP_NAME}\
|
|
30
30
|
-f Dockerfile.dev .
|
|
31
31
|
|
|
@@ -43,4 +43,4 @@ remove: ## Remove the volumes
|
|
|
43
43
|
|
|
44
44
|
#-- Database
|
|
45
45
|
db: ## Start the local database MySQL
|
|
46
|
-
docker-compose up -d mysql
|
|
46
|
+
docker-compose up -d mysql
|
|
@@ -7,7 +7,7 @@ import { ValidationMiddleware } from '@middlewares/validation.middleware';
|
|
|
7
7
|
export class UserRoute implements Routes {
|
|
8
8
|
public path = '/users';
|
|
9
9
|
public router = Router();
|
|
10
|
-
public user = new
|
|
10
|
+
public user = new UserController();
|
|
11
11
|
|
|
12
12
|
constructor() {
|
|
13
13
|
this.initializeRoutes();
|
|
@@ -25,7 +25,7 @@ build: ## Build the container image - Production
|
|
|
25
25
|
docker build -t ${APP_NAME}\
|
|
26
26
|
-f Dockerfile.prod .
|
|
27
27
|
|
|
28
|
-
build-dev: ## Build the container image -
|
|
28
|
+
build-dev: ## Build the container image - Development
|
|
29
29
|
docker build -t ${APP_NAME}\
|
|
30
30
|
-f Dockerfile.dev .
|
|
31
31
|
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
const path = require('path');
|
|
2
|
+
|
|
3
|
+
module.exports = {
|
|
4
|
+
config: path.resolve('src', 'config', 'sequelize-cli.js'),
|
|
5
|
+
'models-path': path.resolve('src', 'models'),
|
|
6
|
+
'seeders-path': path.resolve('src', 'database', 'seeders'),
|
|
7
|
+
'migrations-path': path.resolve('src', 'database', 'migrations'),
|
|
8
|
+
};
|
package/lib/sequelize/Makefile
CHANGED
|
@@ -25,7 +25,7 @@ build: ## Build the container image - Production
|
|
|
25
25
|
docker build -t ${APP_NAME}\
|
|
26
26
|
-f Dockerfile.prod .
|
|
27
27
|
|
|
28
|
-
build-dev: ## Build the container image -
|
|
28
|
+
build-dev: ## Build the container image - Development
|
|
29
29
|
docker build -t ${APP_NAME}\
|
|
30
30
|
-f Dockerfile.dev .
|
|
31
31
|
|
|
@@ -43,4 +43,4 @@ remove: ## Remove the volumes
|
|
|
43
43
|
|
|
44
44
|
#-- Database
|
|
45
45
|
db: ## Start the local database MySQL
|
|
46
|
-
docker-compose up -d mysql
|
|
46
|
+
docker-compose up -d mysql
|
|
@@ -13,7 +13,9 @@
|
|
|
13
13
|
"lint": "eslint --ignore-path .gitignore --ext .ts src/",
|
|
14
14
|
"lint:fix": "npm run lint -- --fix",
|
|
15
15
|
"deploy:prod": "npm run build && pm2 start ecosystem.config.js --only prod",
|
|
16
|
-
"deploy:dev": "pm2 start ecosystem.config.js --only dev"
|
|
16
|
+
"deploy:dev": "pm2 start ecosystem.config.js --only dev",
|
|
17
|
+
"migration:generate": "sequelize migration:generate --name",
|
|
18
|
+
"migration:run": "sequelize db:migrate"
|
|
17
19
|
},
|
|
18
20
|
"dependencies": {
|
|
19
21
|
"bcrypt": "^5.0.1",
|
package/lib/sequelize/src/app.ts
CHANGED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
const { config } = require("dotenv");
|
|
2
|
+
config({ path: `.env.${process.env.NODE_ENV || "development"}.local` });
|
|
3
|
+
|
|
4
|
+
const { DB_HOST, DB_PORT, DB_USER, DB_PASSWORD, DB_DATABASE } = process.env;
|
|
5
|
+
|
|
6
|
+
module.exports = {
|
|
7
|
+
username: DB_USER,
|
|
8
|
+
password: DB_PASSWORD,
|
|
9
|
+
database: DB_DATABASE,
|
|
10
|
+
port: DB_PORT,
|
|
11
|
+
host: DB_HOST,
|
|
12
|
+
dialect: "mysql",
|
|
13
|
+
migrationStorageTableName: "sequelize_migrations",
|
|
14
|
+
seederStorageTableName: "sequelize_seeds",
|
|
15
|
+
};
|
package/lib/typegoose/Makefile
CHANGED
|
@@ -25,7 +25,7 @@ build: ## Build the container image - Production
|
|
|
25
25
|
docker build -t ${APP_NAME}\
|
|
26
26
|
-f Dockerfile.prod .
|
|
27
27
|
|
|
28
|
-
build-dev: ## Build the container image -
|
|
28
|
+
build-dev: ## Build the container image - Development
|
|
29
29
|
docker build -t ${APP_NAME}\
|
|
30
30
|
-f Dockerfile.dev .
|
|
31
31
|
|
|
@@ -43,4 +43,4 @@ remove: ## Remove the volumes
|
|
|
43
43
|
|
|
44
44
|
#-- Database
|
|
45
45
|
db: ## Start the local database MongoDB
|
|
46
|
-
docker-compose up -d mongo
|
|
46
|
+
docker-compose up -d mongo
|
package/lib/typegoose/src/app.ts
CHANGED
|
@@ -6,11 +6,11 @@ import express from 'express';
|
|
|
6
6
|
import helmet from 'helmet';
|
|
7
7
|
import hpp from 'hpp';
|
|
8
8
|
import morgan from 'morgan';
|
|
9
|
-
|
|
9
|
+
|
|
10
10
|
import swaggerJSDoc from 'swagger-jsdoc';
|
|
11
11
|
import swaggerUi from 'swagger-ui-express';
|
|
12
12
|
import { NODE_ENV, PORT, LOG_FORMAT, ORIGIN, CREDENTIALS } from '@config';
|
|
13
|
-
import { dbConnection } from '@
|
|
13
|
+
import { dbConnection } from '@database';
|
|
14
14
|
import { Routes } from '@interfaces/routes.interface';
|
|
15
15
|
import { ErrorMiddleware } from '@middlewares/error.middleware';
|
|
16
16
|
import { logger, stream } from '@utils/logger';
|
|
@@ -45,12 +45,8 @@ class App {
|
|
|
45
45
|
return this.app;
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
private connectToDatabase() {
|
|
49
|
-
|
|
50
|
-
set('debug', true);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
connect(dbConnection);
|
|
48
|
+
private async connectToDatabase() {
|
|
49
|
+
await dbConnection();
|
|
54
50
|
}
|
|
55
51
|
|
|
56
52
|
private initializeMiddlewares() {
|
|
@@ -1,11 +1,18 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { connect, set } from 'mongoose';
|
|
2
|
+
import { NODE_ENV, DB_HOST, DB_PORT, DB_DATABASE } from '@config';
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export const dbConnection = {
|
|
4
|
+
export const dbConnection = async () => {
|
|
5
|
+
const dbConfing = {
|
|
6
6
|
url: `mongodb://${DB_HOST}:${DB_PORT}/${DB_DATABASE}`,
|
|
7
7
|
options: {
|
|
8
8
|
useNewUrlParser: true,
|
|
9
9
|
useUnifiedTopology: true
|
|
10
10
|
},
|
|
11
|
-
};
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
if (NODE_ENV !== 'production') {
|
|
14
|
+
set('debug', true);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
await connect(dbConfing);
|
|
18
|
+
};
|
package/lib/typeorm/Makefile
CHANGED
|
@@ -25,7 +25,7 @@ build: ## Build the container image - Production
|
|
|
25
25
|
docker build -t ${APP_NAME}\
|
|
26
26
|
-f Dockerfile.prod .
|
|
27
27
|
|
|
28
|
-
build-dev: ## Build the container image -
|
|
28
|
+
build-dev: ## Build the container image - Development
|
|
29
29
|
docker build -t ${APP_NAME}\
|
|
30
30
|
-f Dockerfile.dev .
|
|
31
31
|
|
package/lib/typeorm/src/app.ts
CHANGED
|
@@ -8,9 +8,8 @@ import morgan from 'morgan';
|
|
|
8
8
|
import compression from 'compression';
|
|
9
9
|
import swaggerUi from 'swagger-ui-express';
|
|
10
10
|
import swaggerJSDoc from 'swagger-jsdoc';
|
|
11
|
-
import { createConnection } from 'typeorm';
|
|
12
11
|
import { NODE_ENV, PORT, LOG_FORMAT, ORIGIN, CREDENTIALS } from '@config';
|
|
13
|
-
import { dbConnection } from '@
|
|
12
|
+
import { dbConnection } from '@database';
|
|
14
13
|
import { Routes } from '@interfaces/routes.interface';
|
|
15
14
|
import { ErrorMiddleware } from '@middlewares/error.middleware';
|
|
16
15
|
import { logger, stream } from '@utils/logger';
|
|
@@ -46,7 +45,7 @@ export class App {
|
|
|
46
45
|
}
|
|
47
46
|
|
|
48
47
|
private async connectToDatabase() {
|
|
49
|
-
await
|
|
48
|
+
await dbConnection();
|
|
50
49
|
}
|
|
51
50
|
|
|
52
51
|
private initializeMiddlewares() {
|
|
@@ -1,22 +1,26 @@
|
|
|
1
1
|
import { join } from 'path';
|
|
2
|
-
import { ConnectionOptions } from 'typeorm';
|
|
2
|
+
import { createConnection, ConnectionOptions } from 'typeorm';
|
|
3
3
|
import { DB_USER, DB_PASSWORD, DB_HOST, DB_PORT, DB_DATABASE } from '@config';
|
|
4
4
|
|
|
5
|
-
export const dbConnection
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
5
|
+
export const dbConnection = async () => {
|
|
6
|
+
const dbConfig: ConnectionOptions = {
|
|
7
|
+
type: 'postgres',
|
|
8
|
+
username: DB_USER,
|
|
9
|
+
password: DB_PASSWORD,
|
|
10
|
+
host: DB_HOST,
|
|
11
|
+
port: Number(DB_PORT),
|
|
12
|
+
database: DB_DATABASE,
|
|
13
|
+
synchronize: true,
|
|
14
|
+
logging: false,
|
|
15
|
+
entities: [join(__dirname, '../**/*.entity{.ts,.js}')],
|
|
16
|
+
migrations: [join(__dirname, '../**/*.migration{.ts,.js}')],
|
|
17
|
+
subscribers: [join(__dirname, '../**/*.subscriber{.ts,.js}')],
|
|
18
|
+
cli: {
|
|
19
|
+
entitiesDir: 'src/entities',
|
|
20
|
+
migrationsDir: 'src/migration',
|
|
21
|
+
subscribersDir: 'src/subscriber',
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
await createConnection(dbConfig);
|
|
22
26
|
};
|
|
@@ -2,7 +2,7 @@ import bcrypt from 'bcrypt';
|
|
|
2
2
|
import request from 'supertest';
|
|
3
3
|
import { createConnection, getConnection, Repository } from 'typeorm';
|
|
4
4
|
import { App } from '@/app';
|
|
5
|
-
import { dbConnection } from '@
|
|
5
|
+
import { dbConnection } from '@database';
|
|
6
6
|
import { CreateUserDto } from '@dtos/users.dto';
|
|
7
7
|
import { UserEntity } from '@entities/users.entity';
|
|
8
8
|
import { AuthRoute } from '@routes/auth.route';
|
|
@@ -2,7 +2,7 @@ import bcrypt from 'bcrypt';
|
|
|
2
2
|
import request from 'supertest';
|
|
3
3
|
import { createConnection, getConnection, Repository } from 'typeorm';
|
|
4
4
|
import { App } from '@/app';
|
|
5
|
-
import { dbConnection } from '@
|
|
5
|
+
import { dbConnection } from '@database';
|
|
6
6
|
import { CreateUserDto } from '@dtos/users.dto';
|
|
7
7
|
import { UserEntity } from '@entities/users.entity';
|
|
8
8
|
import { UserRoute } from '@routes/users.route';
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"buildTargets":[],"launchTargets":[],"customConfigurationProvider":{"workspaceBrowse":{"browsePath":[],"compilerArgs":[]},"fileIndex":[]}}
|
package/.vscode/dryrun.log
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
make --dry-run --always-make --keep-going --print-directory
|
|
2
|
-
make: Entering directory `/Users/apple/Desktop/typescript-express-starter'
|
|
3
|
-
make: Leaving directory `/Users/apple/Desktop/typescript-express-starter'
|
|
4
|
-
|
|
5
|
-
make: *** No targets specified and no makefile found. Stop.
|
|
6
|
-
|
package/.vscode/settings.json
DELETED
package/.vscode/targets.log
DELETED
|
@@ -1,239 +0,0 @@
|
|
|
1
|
-
make all --print-data-base --no-builtin-variables --no-builtin-rules --question
|
|
2
|
-
# GNU Make 3.81
|
|
3
|
-
# Copyright (C) 2006 Free Software Foundation, Inc.
|
|
4
|
-
# This is free software; see the source for copying conditions.
|
|
5
|
-
# There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
|
|
6
|
-
# PARTICULAR PURPOSE.
|
|
7
|
-
|
|
8
|
-
# This program built for i386-apple-darwin11.3.0
|
|
9
|
-
|
|
10
|
-
# Make data base, printed on Fri Mar 24 19:28:49 2023
|
|
11
|
-
|
|
12
|
-
# Variables
|
|
13
|
-
|
|
14
|
-
# automatic
|
|
15
|
-
<D = $(patsubst %/,%,$(dir $<))
|
|
16
|
-
# automatic
|
|
17
|
-
?F = $(notdir $?)
|
|
18
|
-
# automatic
|
|
19
|
-
?D = $(patsubst %/,%,$(dir $?))
|
|
20
|
-
# automatic
|
|
21
|
-
@D = $(patsubst %/,%,$(dir $@))
|
|
22
|
-
# automatic
|
|
23
|
-
@F = $(notdir $@)
|
|
24
|
-
# makefile
|
|
25
|
-
CURDIR := /Users/apple/Desktop/typescript-express-starter
|
|
26
|
-
# makefile
|
|
27
|
-
SHELL = /bin/sh
|
|
28
|
-
# environment
|
|
29
|
-
DIRHISTORY_SIZE = 30
|
|
30
|
-
# environment
|
|
31
|
-
VSCODE_NLS_CONFIG = {"locale":"ko","availableLanguages":{"*":"ko"},"_languagePackId":"b3b68156b1235a81de12cdcf8511976c.ko","_translationsConfigFile":"/Users/apple/Library/Application Support/Code/clp/b3b68156b1235a81de12cdcf8511976c.ko/tcf.json","_cacheRoot":"/Users/apple/Library/Application Support/Code/clp/b3b68156b1235a81de12cdcf8511976c.ko","_resolvedLanguagePackCoreLocation":"/Users/apple/Library/Application Support/Code/clp/b3b68156b1235a81de12cdcf8511976c.ko/e2816fe719a4026ffa1ee0189dc89bdfdbafb164","_corruptedFile":"/Users/apple/Library/Application Support/Code/clp/b3b68156b1235a81de12cdcf8511976c.ko/corrupted.info","_languagePackSupport":true}
|
|
32
|
-
# environment
|
|
33
|
-
_ = /usr/bin/make
|
|
34
|
-
# makefile
|
|
35
|
-
MAKEFILE_LIST :=
|
|
36
|
-
# environment
|
|
37
|
-
AUTOJUMP_SOURCED = 1
|
|
38
|
-
# environment
|
|
39
|
-
__CFBundleIdentifier = com.microsoft.VSCode
|
|
40
|
-
# environment
|
|
41
|
-
VSCODE_CWD = /
|
|
42
|
-
# environment
|
|
43
|
-
PATH = /Users/apple/.nvm/versions/node/v18.14.0/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin:/Users/apple/Library/Android/sdk/emulator:/Users/apple/Library/Android/sdk/tools:/Users/apple/Library/Android/sdk/tools/bin:/Users/apple/Library/Android/sdk/platform-tools
|
|
44
|
-
# environment
|
|
45
|
-
LSCOLORS = Gxfxcxdxbxegedabagacad
|
|
46
|
-
# environment
|
|
47
|
-
NVM_BIN = /Users/apple/.nvm/versions/node/v18.14.0/bin
|
|
48
|
-
# environment
|
|
49
|
-
ELECTRON_RUN_AS_NODE = 1
|
|
50
|
-
# environment
|
|
51
|
-
ANDROID_HOME = /Users/apple/Library/Android/sdk
|
|
52
|
-
# default
|
|
53
|
-
.FEATURES := target-specific order-only second-expansion else-if archives jobserver check-symlink
|
|
54
|
-
# environment
|
|
55
|
-
SSH_AUTH_SOCK = /private/tmp/com.apple.launchd.9yEYVgrd9t/Listeners
|
|
56
|
-
# automatic
|
|
57
|
-
%F = $(notdir $%)
|
|
58
|
-
# environment
|
|
59
|
-
PWD = /Users/apple/Desktop/typescript-express-starter
|
|
60
|
-
# environment
|
|
61
|
-
ORIGINAL_XDG_CURRENT_DESKTOP = undefined
|
|
62
|
-
# environment
|
|
63
|
-
VSCODE_AMD_ENTRYPOINT = vs/workbench/api/node/extensionHostProcess
|
|
64
|
-
# environment
|
|
65
|
-
HOME = /Users/apple
|
|
66
|
-
# default
|
|
67
|
-
MAKEFILEPATH := /Applications/Xcode.app/Contents/Developer/Makefiles
|
|
68
|
-
# environment
|
|
69
|
-
VSCODE_CODE_CACHE_PATH = /Users/apple/Library/Application Support/Code/CachedData/e2816fe719a4026ffa1ee0189dc89bdfdbafb164
|
|
70
|
-
# environment
|
|
71
|
-
LOGNAME = apple
|
|
72
|
-
# environment
|
|
73
|
-
APPLICATION_INSIGHTS_NO_DIAGNOSTIC_CHANNEL = 1
|
|
74
|
-
# environment
|
|
75
|
-
NVM_CD_FLAGS = -q
|
|
76
|
-
# environment
|
|
77
|
-
ZSH = /Users/apple/.oh-my-zsh
|
|
78
|
-
# environment
|
|
79
|
-
VSCODE_HANDLES_UNCAUGHT_ERRORS = true
|
|
80
|
-
# automatic
|
|
81
|
-
^D = $(patsubst %/,%,$(dir $^))
|
|
82
|
-
# environment
|
|
83
|
-
XPC_FLAGS = 0x0
|
|
84
|
-
# default
|
|
85
|
-
MAKE = $(MAKE_COMMAND)
|
|
86
|
-
# default
|
|
87
|
-
MAKECMDGOALS := all
|
|
88
|
-
# environment
|
|
89
|
-
SHLVL = 1
|
|
90
|
-
# default
|
|
91
|
-
MAKE_VERSION := 3.81
|
|
92
|
-
# environment
|
|
93
|
-
USER = apple
|
|
94
|
-
# makefile
|
|
95
|
-
.DEFAULT_GOAL :=
|
|
96
|
-
# environment
|
|
97
|
-
LESS = -R
|
|
98
|
-
# automatic
|
|
99
|
-
%D = $(patsubst %/,%,$(dir $%))
|
|
100
|
-
# default
|
|
101
|
-
MAKE_COMMAND := /Applications/Xcode.app/Contents/Developer/usr/bin/make
|
|
102
|
-
# default
|
|
103
|
-
.VARIABLES :=
|
|
104
|
-
# environment
|
|
105
|
-
TMPDIR = /var/folders/jv/r5t84rds1jg4pjvrhbp90r1m0000gn/T/
|
|
106
|
-
# automatic
|
|
107
|
-
*F = $(notdir $*)
|
|
108
|
-
# environment
|
|
109
|
-
VSCODE_IPC_HOOK = /Users/apple/Library/Application Support/Code/1.75.0-main.sock
|
|
110
|
-
# environment
|
|
111
|
-
MallocNanoZone = 0
|
|
112
|
-
# makefile
|
|
113
|
-
MAKEFLAGS = Rrqp
|
|
114
|
-
# environment
|
|
115
|
-
MFLAGS = -Rrqp
|
|
116
|
-
# automatic
|
|
117
|
-
*D = $(patsubst %/,%,$(dir $*))
|
|
118
|
-
# environment
|
|
119
|
-
NVM_DIR = /Users/apple/.nvm
|
|
120
|
-
# environment
|
|
121
|
-
XPC_SERVICE_NAME = application.com.microsoft.VSCode.82480513.82480519
|
|
122
|
-
# automatic
|
|
123
|
-
+D = $(patsubst %/,%,$(dir $+))
|
|
124
|
-
# automatic
|
|
125
|
-
+F = $(notdir $+)
|
|
126
|
-
# environment
|
|
127
|
-
__CF_USER_TEXT_ENCODING = 0x1F5:0x3:0x33
|
|
128
|
-
# environment
|
|
129
|
-
COMMAND_MODE = unix2003
|
|
130
|
-
# default
|
|
131
|
-
MAKEFILES :=
|
|
132
|
-
# automatic
|
|
133
|
-
<F = $(notdir $<)
|
|
134
|
-
# environment
|
|
135
|
-
PAGER = less
|
|
136
|
-
# environment
|
|
137
|
-
LC_ALL = C
|
|
138
|
-
# automatic
|
|
139
|
-
^F = $(notdir $^)
|
|
140
|
-
# default
|
|
141
|
-
SUFFIXES :=
|
|
142
|
-
# default
|
|
143
|
-
.INCLUDE_DIRS = /usr/local/include
|
|
144
|
-
# environment
|
|
145
|
-
MAKELEVEL := 0
|
|
146
|
-
# environment
|
|
147
|
-
AUTOJUMP_ERROR_PATH = /Users/apple/Library/autojump/errors.log
|
|
148
|
-
# environment
|
|
149
|
-
LANG = C
|
|
150
|
-
# environment
|
|
151
|
-
VSCODE_PID = 2752
|
|
152
|
-
# variable set hash-table stats:
|
|
153
|
-
# Load=69/1024=7%, Rehash=0, Collisions=1/90=1%
|
|
154
|
-
|
|
155
|
-
# Pattern-specific Variable Values
|
|
156
|
-
|
|
157
|
-
# No pattern-specific variable values.
|
|
158
|
-
|
|
159
|
-
# Directories
|
|
160
|
-
|
|
161
|
-
# . (device 16777225, inode 22080805): 17 files, no impossibilities.
|
|
162
|
-
|
|
163
|
-
# 17 files, no impossibilities in 1 directories.
|
|
164
|
-
|
|
165
|
-
# Implicit Rules
|
|
166
|
-
|
|
167
|
-
# No implicit rules.
|
|
168
|
-
|
|
169
|
-
# Files
|
|
170
|
-
|
|
171
|
-
# Not a target:
|
|
172
|
-
all:
|
|
173
|
-
# Command-line target.
|
|
174
|
-
# Implicit rule search has been done.
|
|
175
|
-
# File does not exist.
|
|
176
|
-
# File has not been updated.
|
|
177
|
-
# variable set hash-table stats:
|
|
178
|
-
# Load=0/32=0%, Rehash=0, Collisions=0/0=0%
|
|
179
|
-
|
|
180
|
-
# Not a target:
|
|
181
|
-
.SUFFIXES:
|
|
182
|
-
# Implicit rule search has not been done.
|
|
183
|
-
# Modification time never checked.
|
|
184
|
-
# File has not been updated.
|
|
185
|
-
|
|
186
|
-
# Not a target:
|
|
187
|
-
Makefile:
|
|
188
|
-
# A default, MAKEFILES, or -include/sinclude makefile.
|
|
189
|
-
# Implicit rule search has been done.
|
|
190
|
-
# File does not exist.
|
|
191
|
-
# File has been updated.
|
|
192
|
-
# Failed to be updated.
|
|
193
|
-
# variable set hash-table stats:
|
|
194
|
-
# Load=0/32=0%, Rehash=0, Collisions=0/0=0%
|
|
195
|
-
|
|
196
|
-
# Not a target:
|
|
197
|
-
makefile:
|
|
198
|
-
# A default, MAKEFILES, or -include/sinclude makefile.
|
|
199
|
-
# Implicit rule search has been done.
|
|
200
|
-
# File does not exist.
|
|
201
|
-
# File has been updated.
|
|
202
|
-
# Failed to be updated.
|
|
203
|
-
# variable set hash-table stats:
|
|
204
|
-
# Load=0/32=0%, Rehash=0, Collisions=0/0=0%
|
|
205
|
-
|
|
206
|
-
# Not a target:
|
|
207
|
-
.DEFAULT:
|
|
208
|
-
# Implicit rule search has not been done.
|
|
209
|
-
# Modification time never checked.
|
|
210
|
-
# File has not been updated.
|
|
211
|
-
|
|
212
|
-
# Not a target:
|
|
213
|
-
GNUmakefile:
|
|
214
|
-
# A default, MAKEFILES, or -include/sinclude makefile.
|
|
215
|
-
# Implicit rule search has been done.
|
|
216
|
-
# File does not exist.
|
|
217
|
-
# File has been updated.
|
|
218
|
-
# Failed to be updated.
|
|
219
|
-
# variable set hash-table stats:
|
|
220
|
-
# Load=0/32=0%, Rehash=0, Collisions=0/0=0%
|
|
221
|
-
|
|
222
|
-
# files hash-table stats:
|
|
223
|
-
# Load=6/1024=1%, Rehash=0, Collisions=0/17=0%
|
|
224
|
-
# VPATH Search Paths
|
|
225
|
-
|
|
226
|
-
# No `vpath' search paths.
|
|
227
|
-
|
|
228
|
-
# No general (`VPATH' variable) search path.
|
|
229
|
-
|
|
230
|
-
# # of strings in strcache: 0
|
|
231
|
-
# # of strcache buffers: 0
|
|
232
|
-
# strcache size: total = 0 / max = 0 / min = 4096 / avg = 0
|
|
233
|
-
# strcache free: total = 0 / max = 0 / min = 4096 / avg = 0
|
|
234
|
-
|
|
235
|
-
# Finished Make data base on Fri Mar 24 19:28:49 2023
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
make: *** No rule to make target `all'. Stop.
|
|
239
|
-
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|