Substantial refactoring of code structure
This commit is contained in:
13
app.mjs
13
app.mjs
@@ -1,12 +1,10 @@
|
||||
import 'dotenv/config';
|
||||
import createError from 'http-errors';
|
||||
import logger from 'morgan';
|
||||
import cors from 'cors';
|
||||
import express from 'express';
|
||||
import path from 'path';
|
||||
import * as dotenv from 'dotenv';
|
||||
import router from './routes/index.mjs';
|
||||
|
||||
dotenv.config();
|
||||
|
||||
let indexRouter = router;
|
||||
|
||||
let app = express();
|
||||
@@ -17,10 +15,13 @@ const PORT = process.env.PORT || 3000;
|
||||
//app.set('views', path.join(__dirname, 'views'));
|
||||
app.set('view engine', 'ejs');
|
||||
|
||||
app.use(logger('dev'));
|
||||
// Equivalent to Access-Control-Allow-Origin: *
|
||||
// if not configured otherwise
|
||||
app.use(cors());
|
||||
|
||||
app.use(logger(process.env.DEBUG));
|
||||
app.use(express.json());
|
||||
app.use(express.urlencoded({ extended: false }));
|
||||
//app.use(express.static(path.join(__dirname, 'public')));
|
||||
|
||||
app.use('/', indexRouter);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user