Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 'use strict';
- const dispatcher = require('./dispatcher')
- const express = require('express'),
- bodyParser = require('body-parser'),
- // morgan = require('morgan'),
- db = require('./config/db.js'),
- env = require('./config/env'),
- router = require('./router/index');
- const app = express();
- const PORT = env.PORT;
- dispatcher.start()
- // app.use(morgan('combined'));
- app.use(bodyParser.json());
- app.use((req, res, next) => {
- res.header('Content-Type', 'application/json');
- res.header("Access-Control-Allow-Origin", "*");
- next();
- });
- router(app, db);
- //drop and resync with { force: true }
- db.sequelize
- .authenticate()
- .then(()=> {
- console.log("Connection has been established successfully.");
- // event handling:
- db.sequelize.sync()
- .then(() => {
- console.log("Synced");
- })
- .catch(error => {
- console.log("Not synced : " + error);
- });
- app.listen(PORT, () => {
- console.log('Express listening on port:', PORT);
- });
- })
- .catch(err => {
- console.error("Unable to connect to the database:", err);
- });
- module.exports = app
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement