-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
33 lines (25 loc) · 810 Bytes
/
app.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
require('dotenv').config()
var express = require("express");
var app = express();
var http = require('http').Server(app);
var bodyParser = require("body-parser");
var cors = require('cors');
var Files_Route = require('./routes/files');
var Mongoose = require("mongoose");
var config = require('./config');
Mongoose.connect(config.mongo.URL, { useNewUrlParser: true },(error)=>{
if(error) console.log(error);
});
app.use(cors());
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({extended: true}));
app.use('/api/files', Files_Route);
app.get('/', (req, res)=>{
res.send('welcome!')
});
app.use(function(req, res){
res.status(404).json({error: 'This endpoint is not found on the server'});
});
app.listen(config.port, ()=>{
console.log('listening on port:' + config.port)
})