-
Notifications
You must be signed in to change notification settings - Fork 2
/
server.js
32 lines (27 loc) · 1014 Bytes
/
server.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
const { fileLoader } = require('ejs');
const express = require('express');
const fileUpload=require('express-fileupload');
const fs = require('fs')
const { isBuffer } = require('util');
const { error } = require('console');
const http=require('http')
const path=require('path')
const bodyparser=require('body-parser');
const cors = require('cors')
const app=express();
app.use('/static', express.static('App.js'))
app.use(fileUpload());
//MONGODB
const mongoose = require('mongoose');
mongoose.connect( process.env.MONGODB_URI || 'mongodb://localhost/karu', {useNewUrlParser: true, useUnifiedTopology: true, useFindAndModify: false});
const db = mongoose.connection;
db.on('error', console.error.bind(console, 'connection error:'));
db.once('open', function() {
// we're connected!
console.log ('We are connected')
});
app.use(cors());
app.use(express.json())
const fileRouter=require('./routes/file')
app.use('/file',fileRouter)
app.listen( process.env.PORT ||5000,()=>console.log('Server Started...'));