Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🌼 Update Version - v10.0.1 #221

Merged
merged 4 commits into from
Sep 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -105,3 +105,6 @@ dist

# Package-lock json file
package-lock.json

# VScode file
.vscode
6 changes: 6 additions & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,10 @@

- coder-palak [https://github.com/coder-palak](https://github.com/coder-palak)

- H2RO [https://github.com/primary-1](https://github.com/primary-1)

- Emmanuel Yeboah [https://github.com/noelzappy](https://github.com/noelzappy)

- Jonathan Felicity [https://github.com/jonathanfelicity](https://github.com/jonathanfelicity)

- Hichem Fantar [https://github.com/hichemfantar](https://github.com/hichemfantar)
5 changes: 2 additions & 3 deletions lib/graphql/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import express from 'express';
import helmet from 'helmet';
import hpp from 'hpp';
import { buildSchema } from 'type-graphql';
import { createConnection } from 'typeorm';
import { NODE_ENV, PORT, ORIGIN, CREDENTIALS } from '@config';
import { dbConnection } from '@database';
import { AuthMiddleware, AuthCheckerMiddleware } from '@middlewares/auth.middleware';
Expand Down Expand Up @@ -45,8 +44,8 @@ export class App {
return this.app;
}

private connectToDatabase() {
createConnection(dbConnection);
private async connectToDatabase() {
await dbConnection();
}

private initializeMiddlewares() {
Expand Down
42 changes: 23 additions & 19 deletions lib/graphql/src/database/index.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,26 @@
import { join } from 'path';
import { ConnectionOptions } from 'typeorm';
import { createConnection, ConnectionOptions } from 'typeorm';
import { POSTGRES_USER, POSTGRES_PASSWORD, POSTGRES_HOST, POSTGRES_PORT, POSTGRES_DB } from '@config';

export const dbConnection: ConnectionOptions = {
type: 'postgres',
username: POSTGRES_USER,
password: POSTGRES_PASSWORD,
host: POSTGRES_HOST,
port: Number(POSTGRES_PORT),
database: POSTGRES_DB,
synchronize: true,
logging: false,
entities: [join(__dirname, '../**/*.entity{.ts,.js}')],
migrations: [join(__dirname, '../**/*.migration{.ts,.js}')],
subscribers: [join(__dirname, '../**/*.subscriber{.ts,.js}')],
cli: {
entitiesDir: 'src/entities',
migrationsDir: 'src/migration',
subscribersDir: 'src/subscriber',
},
};
export const dbConnection = async () => {
const dbConfig: ConnectionOptions = {
type: 'postgres',
username: POSTGRES_USER,
password: POSTGRES_PASSWORD,
host: POSTGRES_HOST,
port: Number(POSTGRES_PORT),
database: POSTGRES_DB,
synchronize: true,
logging: false,
entities: [join(__dirname, '../**/*.entity{.ts,.js}')],
migrations: [join(__dirname, '../**/*.migration{.ts,.js}')],
subscribers: [join(__dirname, '../**/*.subscriber{.ts,.js}')],
cli: {
entitiesDir: 'src/entities',
migrationsDir: 'src/migration',
subscribersDir: 'src/subscriber',
},
};

await createConnection(dbConfig);
}
7 changes: 3 additions & 4 deletions lib/knex/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@ import express from 'express';
import helmet from 'helmet';
import hpp from 'hpp';
import morgan from 'morgan';
import { Model } from 'objection';
import swaggerJSDoc from 'swagger-jsdoc';
import swaggerUi from 'swagger-ui-express';
import { NODE_ENV, PORT, LOG_FORMAT, ORIGIN, CREDENTIALS } from '@config';
import { knex } from '@database';
import { dbConnection } from '@database';
import { Routes } from '@interfaces/routes.interface';
import { ErrorMiddleware } from '@middlewares/error.middleware';
import { logger, stream } from '@utils/logger';
Expand Down Expand Up @@ -45,8 +44,8 @@ export class App {
return this.app;
}

private connectToDatabase() {
Model.knex(knex());
private async connectToDatabase() {
await dbConnection();
}

private initializeMiddlewares() {
Expand Down
37 changes: 20 additions & 17 deletions lib/knex/src/database/index.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
import { Model } from 'objection';
import Knex from 'knex';
import { DB_USER, DB_PASSWORD, DB_HOST, DB_PORT, DB_DATABASE } from '@config';

const dbConnection = {
client: 'mysql',
connection: {
charset: 'utf8',
timezone: 'UTC',
user: DB_USER,
password: DB_PASSWORD,
host: DB_HOST,
port: DB_PORT,
database: DB_DATABASE,
},
pool: {
min: 2,
max: 10,
},
};
export const dbConnection = async () => {
const dbConfig = {
client: 'mysql',
connection: {
charset: 'utf8',
timezone: 'UTC',
user: DB_USER,
password: DB_PASSWORD,
host: DB_HOST,
port: DB_PORT,
database: DB_DATABASE,
},
pool: {
min: 2,
max: 10,
},
};

export const knex = () => Knex(dbConnection);
await Model.knex(Knex(dbConfig));
};
3 changes: 2 additions & 1 deletion lib/mikro-orm/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,9 @@ export class App {
DI.userRepository = DI.orm.em.getRepository(UserEntity);
} catch (error) {
logger.error(error);
} finally {
this.app.use((_1, _2, next) => RequestContext.create(DI.orm.em, next));
}
this.app.use((_1, _2, next) => RequestContext.create(DI.orm.em, next));
}

private initializeMiddlewares() {
Expand Down
7 changes: 1 addition & 6 deletions lib/mongoose/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import express from 'express';
import helmet from 'helmet';
import hpp from 'hpp';
import morgan from 'morgan';
import { connect, set } from 'mongoose';
import swaggerJSDoc from 'swagger-jsdoc';
import swaggerUi from 'swagger-ui-express';
import { NODE_ENV, PORT, LOG_FORMAT, ORIGIN, CREDENTIALS } from '@config';
Expand Down Expand Up @@ -46,11 +45,7 @@ export class App {
}

private async connectToDatabase() {
if (this.env !== 'production') {
set('debug', true);
}

await connect(dbConnection.url, dbConnection.options);
await dbConnection();
}

private initializeMiddlewares() {
Expand Down
25 changes: 17 additions & 8 deletions lib/mongoose/src/database/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
import { DB_HOST, DB_PORT, DB_DATABASE } from '@config';
import { connect, set } from 'mongoose';
import { NODE_ENV, DB_HOST, DB_PORT, DB_DATABASE } from '@config';

export const dbConnection = {
url: `mongodb://${DB_HOST}:${DB_PORT}/${DB_DATABASE}`,
options: {
useNewUrlParser: true,
useUnifiedTopology: true
},
};
export const dbConnection = async () => {
const dbConfig = {
url: `mongodb://${DB_HOST}:${DB_PORT}/${DB_DATABASE}`,
options: {
useNewUrlParser: true,
useUnifiedTopology: true
},
};

if (NODE_ENV !== 'production') {
set('debug', true);
}

await connect(dbConfig.url, dbConfig.options);
}
4 changes: 2 additions & 2 deletions lib/node-postgres/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ export class App {
return this.app;
}

private connectToDatabase() {
client.connect();
private async connectToDatabase() {
await client.connect();
}

private initializeMiddlewares() {
Expand Down
4 changes: 2 additions & 2 deletions lib/sequelize/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ export class App {
return this.app;
}

private connectToDatabase() {
DB.sequelize.sync({ force: false });
private async connectToDatabase() {
await DB.sequelize.sync({ force: false });
}

private initializeMiddlewares() {
Expand Down
10 changes: 3 additions & 7 deletions lib/typegoose/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import express from 'express';
import helmet from 'helmet';
import hpp from 'hpp';
import morgan from 'morgan';
import { connect, set } from 'mongoose';

import swaggerJSDoc from 'swagger-jsdoc';
import swaggerUi from 'swagger-ui-express';
import { NODE_ENV, PORT, LOG_FORMAT, ORIGIN, CREDENTIALS } from '@config';
Expand Down Expand Up @@ -45,12 +45,8 @@ class App {
return this.app;
}

private connectToDatabase() {
if (this.env !== 'production') {
set('debug', true);
}

connect(dbConnection);
private async connectToDatabase() {
await dbConnection();
}

private initializeMiddlewares() {
Expand Down
17 changes: 12 additions & 5 deletions lib/typegoose/src/database/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
import { DB_HOST, DB_PORT, DB_DATABASE } from '@config';
import { connect, set } from 'mongoose';
import { NODE_ENV, DB_HOST, DB_PORT, DB_DATABASE } from '@config';

// export const dbConnection = `mongodb://${DB_HOST}:${DB_PORT}/${DB_DATABASE}`;

export const dbConnection = {
export const dbConnection = async () => {
const dbConfing = {
url: `mongodb://${DB_HOST}:${DB_PORT}/${DB_DATABASE}`,
options: {
useNewUrlParser: true,
useUnifiedTopology: true
},
};
};

if (NODE_ENV !== 'production') {
set('debug', true);
}

await connect(dbConfing);
};
3 changes: 1 addition & 2 deletions lib/typeorm/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import morgan from 'morgan';
import compression from 'compression';
import swaggerUi from 'swagger-ui-express';
import swaggerJSDoc from 'swagger-jsdoc';
import { createConnection } from 'typeorm';
import { NODE_ENV, PORT, LOG_FORMAT, ORIGIN, CREDENTIALS } from '@config';
import { dbConnection } from '@database';
import { Routes } from '@interfaces/routes.interface';
Expand Down Expand Up @@ -46,7 +45,7 @@ export class App {
}

private async connectToDatabase() {
await createConnection(dbConnection)
await dbConnection();
}

private initializeMiddlewares() {
Expand Down
40 changes: 22 additions & 18 deletions lib/typeorm/src/database/index.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,26 @@
import { join } from 'path';
import { ConnectionOptions } from 'typeorm';
import { createConnection, ConnectionOptions } from 'typeorm';
import { DB_USER, DB_PASSWORD, DB_HOST, DB_PORT, DB_DATABASE } from '@config';

export const dbConnection: ConnectionOptions = {
type: 'postgres',
username: DB_USER,
password: DB_PASSWORD,
host: DB_HOST,
port: Number(DB_PORT),
database: DB_DATABASE,
synchronize: true,
logging: false,
entities: [join(__dirname, '../**/*.entity{.ts,.js}')],
migrations: [join(__dirname, '../**/*.migration{.ts,.js}')],
subscribers: [join(__dirname, '../**/*.subscriber{.ts,.js}')],
cli: {
entitiesDir: 'src/entities',
migrationsDir: 'src/migration',
subscribersDir: 'src/subscriber',
},
export const dbConnection = async () => {
const dbConfig: ConnectionOptions = {
type: 'postgres',
username: DB_USER,
password: DB_PASSWORD,
host: DB_HOST,
port: Number(DB_PORT),
database: DB_DATABASE,
synchronize: true,
logging: false,
entities: [join(__dirname, '../**/*.entity{.ts,.js}')],
migrations: [join(__dirname, '../**/*.migration{.ts,.js}')],
subscribers: [join(__dirname, '../**/*.subscriber{.ts,.js}')],
cli: {
entitiesDir: 'src/entities',
migrationsDir: 'src/migration',
subscribersDir: 'src/subscriber',
},
};

await createConnection(dbConfig);
};
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "typescript-express-starter",
"version": "10.0.0",
"version": "10.0.1",
"description": "Quick and Easy TypeScript Express Starter",
"author": "AGUMON <ljlm0402@gmail.com>",
"license": "MIT",
Expand Down
Loading