This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Setup the winston logger. | |
* | |
* Documentation: https://github.com/winstonjs/winston | |
*/ | |
import { createLogger, format, transports } from 'winston'; | |
// Import Functions | |
const { File, Console } = transports; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import "reflect-metadata"; | |
import {createConnection} from "typeorm"; | |
import { Tedis} from "tedis"; | |
// import {User} from "../entities/User"; | |
import logger from '@shared/Logger'; | |
async function intializeDB(): Promise<void> { | |
await createConnection() | |
logger.info('Database successfully initialized'); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {Entity, PrimaryGeneratedColumn, Column} from "typeorm"; | |
@Entity() | |
export class User { | |
@PrimaryGeneratedColumn() | |
id: number; | |
@Column() | |
firstName: string; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import "reflect-metadata"; | |
import {createConnection} from "typeorm"; | |
import logger from '@shared/Logger'; | |
async function intializeDB(): Promise<void> { | |
await createConnection() | |
logger.info('Database successfully initialized'); | |
} | |
// Export express instance |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"synchronize": true, | |
"logging": false, | |
"entities": [ | |
"src/entities/**/*.ts" | |
], | |
"migrations": [ | |
"src/migration/**/*.ts" | |
], | |
"subscribers": [ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Print API errors | |
// eslint-disable-next-line @typescript-eslint/no-unused-vars | |
app.use((err: Error, req: Request, res: Response, next: NextFunction) => { | |
logger.error(err.message, err); | |
return res.status(BAD_REQUEST).json({ | |
error: err.message, | |
}); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import './LoadEnv'; // Must be the first import | |
import app from '@server'; | |
// Start the server | |
const port = Number(process.env.PORT || 3000); | |
app.listen(port, () => { | |
logger.info('Express server started on port: ' + port); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import cookieParser from 'cookie-parser'; | |
import express, { Request, Response, NextFunction } from 'express'; | |
import { BAD_REQUEST } from 'http-status-codes'; | |
import BaseRouter from './routes'; | |
// Init express | |
const app = express(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "my-app", | |
"version": "0.0.0", | |
"scripts": { | |
"build": "node build.js", | |
"start": "node index.js", | |
"lint": "eslint . --ext .ts", | |
}, | |
"dependencies": { | |
"@types/redis": "^2.8.22", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "my-app", | |
"version": "0.0.0", | |
"scripts": { | |
"build": "node build.js", | |
"start": "node index.js", | |
}, | |
"dependencies": { | |
"@types/redis": "^2.8.22", | |
"command-line-args": "^5.1.1", |
NewerOlder