forked from dzakijo1/rest-api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
56 lines (40 loc) · 1.85 KB
/
index.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
const express = require('express');
const app = express();
var favicon = require('serve-favicon')
var path = require('path')
var cookieParser = require('cookie-parser');
var createError = require('http-errors')
require('./settings')
cors = require('cors'),
secure = require('ssl-express-www');
const PORT = process.env.PORT || 8080 || 5000 || 3000
app.use(favicon(path.join(__dirname,'public','images','favicon.ico')))
var main = require('./routes/main'),
api = require('./routes/api')
app.set('trust proxy', true);
app.set("json spaces",2)
app.use(cors())
app.use(secure)
app.use(cookieParser());
app.use(express.static("public"))
app.use('/', main)
app.use('/api', api)
app.use(function (req, res, next) {
next(createError(404))
})
app.use(function (err, req, res, next) {
res.sendFile(__path + '/view/404.html')
})
app.listen(PORT, () => {
console.log(`
██████╗ ███████╗███████╗████████╗ █████╗ ██████╗ ██╗
██╔══██╗██╔════╝██╔════╝╚══██╔══╝██╔══██╗██╔══██╗██║
██████╔╝█████╗ ███████╗ ██║ ███████║██████╔╝██║
██╔══██╗██╔══╝ ╚════██║ ██║ ██╔══██║██╔═══╝ ██║
██║ ██║███████╗███████║ ██║ ██║ ██║██║ ██║
╚═╝ ╚═╝╚══════╝╚══════╝ ╚═╝ ╚═╝ ╚═╝╚═╝ ╚═╝
Make by Aine
Server running on http://localhost:` + PORT)
console.log(`Hello ${creator}`)
})
module.exports = app