-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathserver.js
More file actions
37 lines (27 loc) · 1005 Bytes
/
server.js
File metadata and controls
37 lines (27 loc) · 1005 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
37
const express = require('express');
const bodyParser = require('body-parser');
const cors = require('cors');
const initDB = require('./models/db');
const api = require('./routes/user');
initDB.createUserTable();
initDB.createTokenTable();
const app = express();
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
app.use(cors());
app.set('view engine', 'ejs');
app.set("views", __dirname + "/view");
app.use('/api',api);
var today = new Date();
var date = today.getFullYear()+'-'+(today.getMonth()+1)+'-'+today.getDate();
var time = today.getHours() + ":" + today.getMinutes() + ":" + today.getSeconds();
var dateTime = date+' '+time;
app.get('/', (req, res) => res.status(200).send({
appName :'Postgres Authentication Server with Express.',
serverStatus :'Server is running.',
lastUpdatedTime:dateTime,
auther :'capcod3r'
}));
app.listen(process.env.PORT || 3000, () => {
console.log(`Server listening in http://localhost:3000`)
});