This file contains hidden or 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 { expect } from 'chai'; | |
import { agent as request } from 'supertest'; | |
import 'mocha'; | |
import App from '../src/index'; | |
describe('baseRoute', () => { | |
it('should GET', async () => { | |
const res = await request(App).get('/'); | |
// we check the status |
This file contains hidden or 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
const { createLogger, transports } = require('winston'); | |
const defaultLevel = process.env.LOG_LEVEL || 'info'; | |
const options = { | |
exitOnError: false, | |
level: defaultLevel | |
}; | |
const logger = new createLogger(options); |
This file contains hidden or 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
// cluster mode for production env | |
module.exports = { | |
apps: [ | |
{ | |
...require('./pm2.config'), | |
instances: 2, // can be max or any number of processes the cpu can handle | |
exec_mode: "cluster", | |
env: { | |
"PORT": 8080, | |
"NODE_ENV": "production" |
This file contains hidden or 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
module.exports = { | |
apps: [ | |
{ | |
// we load the common config | |
...require('./pm2.config'), | |
// we set environment variables | |
env: { | |
"PORT": 3000, | |
"NODE_ENV": "development" | |
} |
This file contains hidden or 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
module.exports = { | |
name: "api-rest", | |
script: 'build/main.bundle.js', | |
watch: true, | |
ignore_watch: ["node_modules"], | |
// new feature; increase restart delay each time after every crash or non reachable db per example | |
exp_backoff_restart_delay: 100, | |
//combine multiple err/out logs in one file for each | |
combine_logs: true, | |
//calls combine logs |
This file contains hidden or 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
"scripts": { | |
"_comment_" : "clean our build folder and all logs", | |
"clean": "rimraf ./build/* && rimraf ./logs/*", | |
"_comment_" : "lint all source code", | |
"lint": "tslint -c tslint.json 'src/**/*.ts'", | |
"_comment_" : "build will clean, lint then will call webpack with watch enabled to check and transpile", | |
"build": "yarn clean && yarn lint && webpack --watch", | |
"_comment_" : "start the build in development mode", | |
"start:dev": "NODE_ENV=development yarn build", | |
"_comment_" : "will be called by webpack when build is done to run pm2 with our development config", |
This file contains hidden or 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 * as bodyParser from 'body-parser'; | |
import * as express from 'express'; | |
// Creates and configures an ExpressJS web server. | |
class App { | |
// ref to Express instance | |
express: express.Application; | |
// Run configuration methods on the Express instance. | |
constructor() { |
This file contains hidden or 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 * as http from 'http'; | |
import logger from '../utils/winston-logger'; | |
import App from '../index'; | |
const server = http.createServer(App); | |
const normalizePort = (val: number|string): number|string|boolean => { | |
const normolizedPort = (typeof val === 'string') ? parseInt(val, 10) : val; | |
if (isNaN(normolizedPort)) { |
This file contains hidden or 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
const path = require('path'); | |
// this package handles all the external packages | |
const nodeExternals = require('webpack-node-externals'); | |
// help running shell commands with webpack before and after the build process | |
const WebpackShellPlugin = require('webpack-shell-plugin'); | |
// used to do the typechecking in a seperate process so the transpiling will be handled only by tsloader. | |
// speed up compilation of code | |
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin'); | |
const { |
This file contains hidden or 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
Show hidden characters
{ | |
"defaultSeverity": "warning", | |
"project": "./tsconfig.json", | |
"extends": [ | |
"tslint-eslint-rules" | |
], | |
"rulesDirectory": [ | |
"node_modules/codelyzer", | |
"node_modules/tslint-origin-ordered-imports-rule/dist", | |
"node_modules/tslint-consistent-codestyle/rules", |
NewerOlder