basic-expressjs/index.js

23 lines
681 B
JavaScript
Raw Permalink Normal View History

2021-09-15 18:47:11 +00:00
const app = require('express')();
const bodyParser = require('body-parser');
const multer = require('multer');
const upload = multer();
const { config } = require('./config/index');
const { logErrors, wrapErrors, errorHandler } = require('./utils/middleware/errorHandlers');
const notFoundHandler = require('./utils/middleware/notFoundHandler');
const moviesApi = require('./routes/movies.js');
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
moviesApi(app);
app.use(notFoundHandler);
app.use(logErrors);
app.use(wrapErrors);
app.use(errorHandler);
app.listen(config.port, () => {
console.log(`listening http://localhost:${config.port}`);
});