-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathweb.js
40 lines (31 loc) · 1.03 KB
/
web.js
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
37
38
39
40
const express = require('express');
const cookieParser = require('cookie-parser')
const bodyParser = require('body-parser');
const {
Client
} = require('pg');
// Connexion à la base
const pgsql = new Client({
connectionString: process.env.DATABASE_URL,
ssl: {
rejectUnauthorized: false
}
});
pgsql.connect();
let cookies = new Map();
const app = express();
// CONFIGURATION ==================================
app.use(cookieParser());
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({extended: true}));
app.set('view engine', 'pug');
app.set('views', 'views/')
// ROUTES =========================================
require('./app/webpages.js')(app, pgsql, __dirname, cookies);
require('./app/getAPI.js')(app, pgsql, __dirname, cookies);
require('./app/postAPI.js')(app, pgsql, __dirname, cookies);
require('./app/static.js')(app, __dirname);
// LAUNCH ========================================
app.listen(process.env.PORT, function () {
console.log("Serveur démarré sur le port " + process.env.PORT);
});