23 lines
681 B
JavaScript
23 lines
681 B
JavaScript
|
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}`);
|
||
|
});
|