forked from HazzazBinFaiz/node-framework
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
48 lines (39 loc) · 1.13 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
require('dotenv').config();
var express = require('express')
var {ErrorHandle} = require('./vendor/ErrorHandler')
const fileUpload = require('express-fileupload')
var SystemHelper = require('./vendor/SystemHelper')
// define app
var app = express()
new SystemHelper(app, express)
app.use(fileUpload());
// Enable auth default module
// const AuthModule = require('./vendor/defaultAuth/AuthModule')
// new AuthModule(app)
// define routes
var web = require('./routes/web')
var api = require('./routes/api')
app.use('/', web)
app.use('/api', api)
// GET 404 & send to error handler
app.get("*", (req, res, next) => {
// ============== for api =================
// res.send(setResponse(null,'failed', 404, ['url not found']))
// ============== for view ================
const err = new Error('Not Found')
err.status = 404
next(err)
})
// error handler
app.use(ErrorHandle)
// set file upload size
app.use(fileUpload({
limits: {
fileSize: 50 * 1024 * 1024,
},
}));
// define http server
var port = (process.env.APP_PORT || 3000)
app.listen(port,function (){
console.log(`Server stated on port : ${port}`)
})