-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathserver.js
More file actions
25 lines (20 loc) · 734 Bytes
/
server.js
File metadata and controls
25 lines (20 loc) · 734 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
const express = require('express');
const app = express();
const path = require('path');
const fileUpload = require('express-fileupload');
const connectDB = require('./models/db');
const PORT = 5000 || process.env.PORT;
connectDB(); //connect to db
app.use(
fileUpload({
createParentPath: true
})
);
app.use('/images', express.static(path.join(__dirname, 'uploads')));
app.use(express.json({ extended: true })); //for jsondata bodyparsing
app.use(express.urlencoded({ extended: true })); // for x-www-form-urlencoded bodyparsing
app.use('/image', require('./routes/api'));
app.get('/', (req, res) => {
res.send(`listening to port ${PORT}`);
});
app.listen(PORT, () => console.log(`listening to port ${PORT}........`));