-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
41 lines (31 loc) · 1.11 KB
/
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
33
34
35
36
37
38
39
40
41
const patient = require('./controllers/patient.js');
const express = require('express');
const multer = require('multer');
const bodyParser = require('body-parser');
let app = express();
app.set('views', './views');
app.set('view engine', 'pug');
app.use(express.static('public'));
app.use('/static', express.static(__dirname + '/public'));
app.use(bodyParser.json({limit: '100mb', extended: true}));
app.use(bodyParser.urlencoded({limit: '100mb', extended: true}));
app.use((req, res, next) => {
console.log('Requesting: ['+req.method+']:\t'+req.originalUrl);
res.header("Access-Control-Allow-Origin", "*");
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
next();
});
let storage = multer.diskStorage({
destination: (req, file, next) => {
next(null, 'public/uploads/')
},
filename: (req, file, next) => {
next(null, file.originalname)
}
})
let upload = multer({ storage: storage })
app.get('/', patient.getAll);
app.post('/', upload.single('photo'), patient.update);
app.listen(31415, '0.0.0.0', () => {
console.log('Listning...')
});