-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
29 lines (23 loc) · 697 Bytes
/
app.js
File metadata and controls
29 lines (23 loc) · 697 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
const express = require('express');
const bodyParser = require('body-parser');
const route = require('./routes/route');
const cors = require('cors')
const app = express();
const port = process.env.PORT || 3000;
app.use(cors());
app.use(bodyParser.json());
app.use('/api/v1/todos', route);
// app.use('', route);
//start server
app.listen(port, () => {
console.log(`Server is running on port ${port}`);
});
// Handle 404 Errors
app.use((req, res, next) => {
res.status(404).json({ message: 'Route not found' });
});
//run with: node --env-file .env app.js
/**
* if run fail, comment env import in connection.js and uncomment hard coded db variables then
* nope app.js
*/