1- const bodyParser = require ( 'body-parser' ) ;
2- const express = require ( 'express' ) ;
3- const fs = require ( 'fs' ) ;
4- const yaml = require ( 'js-yaml' ) ;
5- const logger = require ( 'morgan' ) ;
6- const mongoose = require ( 'mongoose' ) ;
7- const path = require ( 'path' ) ;
8- const swaggerUi = require ( 'swagger-ui-express' ) ;
9-
10- const config = require ( './config' ) ;
11- const moviesApi = require ( './routes/movies' ) ;
12- const peopleApi = require ( './routes/people' ) ;
13- const adminRoutes = require ( './routes/admin' ) ;
14- const unrestRoutes = require ( './unrest/routes' ) ;
1+ import bodyParser from 'body-parser' ;
2+ import express from 'express' ;
3+ import fs from 'fs' ;
4+ import yaml from 'js-yaml' ;
5+ import logger from 'morgan' ;
6+ import mongoose from 'mongoose' ;
7+ import path from 'path' ;
8+ import swaggerUi from 'swagger-ui-express' ;
9+
10+ import * as config from './config.js' ;
11+ import moviesApi from './routes/movies.js' ;
12+ import peopleApi from './routes/people.js' ;
13+ import adminRoutes from './routes/admin.js' ;
14+ import unrestRoutes from './unrest/routes.js' ;
1515
1616// Connect to the database (can be overriden from environment)
1717mongoose . connect ( config . databaseUrl ) ;
@@ -23,7 +23,7 @@ if (config.debug) {
2323}
2424
2525// View engine setup
26- app . set ( 'views' , path . join ( __dirname , 'views' ) ) ;
26+ app . set ( 'views' , path . join ( config . projectRoot , 'views' ) ) ;
2727app . set ( 'view engine' , 'pug' ) ;
2828
2929// General middlewares
@@ -41,7 +41,7 @@ openApiDocument.servers[0].url = `${config.baseUrl}/api`;
4141app . use ( '/swagger' , swaggerUi . serve , swaggerUi . setup ( openApiDocument ) ) ;
4242
4343// Serve the apiDoc documentation on /.
44- app . use ( express . static ( path . join ( __dirname , 'docs' ) ) ) ;
44+ app . use ( express . static ( path . join ( config . projectRoot , 'docs' ) ) ) ;
4545
4646// REST API routes
4747app . use ( '/api/movies' , moviesApi ) ;
@@ -94,4 +94,4 @@ app.use(function (err, req, res, next) {
9494 res . render ( 'error' ) ;
9595} ) ;
9696
97- module . exports = app ;
97+ export default app ;
0 commit comments