Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
/* eslint babel/semi: "error" */
import consoleStamp from 'console-stamp';
import { getSingleton as initApp } from './app/app';
consoleStamp(console, 'yyyy/mm/dd HH:MM:ss.l');
initApp()
.catch((e) => {
process.stderr.write(`FATAL ERROR\n`);
process.stderr.write(`${e.message}\n`);
process.stderr.write(`${e.stack}\n`);
process.exit(1);
});
import allowCORSHandler from './middlewares/allowCORS.js';
import notFoundRequest from './middlewares/notFound.js';
import logErrorsHandler from './middlewares/logErrors.js';
import errorHandler from './middlewares/serverError.js';
import * as helpers from './utils/hbsHelpers.js';
const PRODUCTION_MODE = 'production';
let { PORT = 3000 } = process.env;
const { HOST = 'localhost', TITLE, PID_FILE } = process.env;
const PING = 'ping';
const app = express();
consoleStamp(console, { pattern: 'dd/mmm/yyyy:HH:MM:ss o' });
logger.token('date', () => moment().format('DD/MMM/YYYY:HH:mm:ss ZZ'));
app.use(logger('common'));
app.use(bodyParser.json());
//Defining middleware to serve static files
app.use('/static', express.static(path.join(__dirname, '../public')));
// Use Handlebars as my main render engine
app.engine(
'handlebars',
exphbs({
defaultLayout: 'main',
helpers,
})
);
import notFoundRequest from './middlewares/notFound.js';
import logErrorsHandler from './middlewares/logErrors.js';
import errorHandler from './middlewares/serverError.js';
import db from './store/db.js';
let { port = 3000 } = config;
const {
ip = 'localhost',
apiPrefix = 'api',
apiVersion = 'v1'
} = config;
const app = express();
consoleStamp(console, { pattern: 'dd/mmm/yyyy:HH:MM:ss o' });
logger.token('date', () => moment().format('DD/MMM/YYYY:HH:mm:ss ZZ'));
app.use(logger('common'));
app.use(bodyParser.json());
app.use('/*', allowCORSHandler);
app.use(`${apiPrefix}/*`, authRequest);
app.use([apiPrefix + apiVersion, apiPrefix], routes);
app.use(notFoundRequest);
app.use(logErrorsHandler);
app.use(errorHandler);
// connect to mongodb
db.connect();