-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
55 lines (40 loc) · 1.36 KB
/
app.js
File metadata and controls
55 lines (40 loc) · 1.36 KB
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
require('express-async-errors');
const express = require('express');
const logger = require('morgan');
//const bodyParser = require('body-parser');
//const config = require('config');
const helmet = require('helmet');
const app = express();
const error = require('./src/middleware/error.js');
const winston = require('winston');
winston.add(new winston.transports.File({ filename: 'logfile.log' }));
app.use(express.json());
app.use(express.urlencoded({extende: true}));
app.use(express.static('public'));
app.use(logger('dev'));
app.use(helmet());
app.use(express.Router());
/*app.use(function(err,req,res,next){
//error medlleware
return res.status(500).send("somethiung faild. "+err);
});*/
require('./src/routes/route_post.js')(app);
require('./src/routes/route_user.js')(app);
require('./src/routes/login.js')(app);
//db connection
require('./src/database/connection.js');
//require('./src/boostrap')();
app.get('/' , (req , res) =>{
res.send('hello world');
});
app.get('*', (req, res) => res.status(200).send({
message: 'Welcome to the beginning of nothingness.',
}));
app.use(error);
const http = require('http');
const port = parseInt(process.env.PORT, 10) || 8000;
const server = http.createServer(app);
server.listen(port, () => {
console.log(`The server is running at localhost:${port}`);
});
//module.exports = app;