-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
36 lines (27 loc) · 790 Bytes
/
app.js
File metadata and controls
36 lines (27 loc) · 790 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// Dependencies
const express = require('express');
const morgan = require('morgan');
const path = require('path');
// Get the environment and the port
const { port, enviroment } = require('@config/server')
// Get the connection
const connection = require('@core/connection');
// Build the application
const app = express();
// Get route versions
const v1 = require('@route/v1');
// Middleware
app.use(express.json());
app.use(express.urlencoded({ extended: false }));
app.use(express.static(path.join(__dirname, 'public')));
if( 'development' == enviroment ){
app.use(morgan('dev'));
}
// Connection with the database
connection();
// set the routes
app.use('/api/v1', v1);
// Listen port
app.listen(port, () => {
console.log(`[OK] The server is listening on port ${port}`);
});