-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.ts
29 lines (24 loc) · 818 Bytes
/
index.ts
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
import * as express from 'express';
import * as fileUpload from 'express-fileupload';
const app = express()
const port = 3000
app.use((req, res, next) => {
res.setHeader('Access-Control-Allow-Origin', '*');
res.setHeader('Access-Control-Allow-Methods', 'GET, POST, OPTIONS, PUT, PATCH, DELETE');
res.setHeader('Access-Control-Allow-Headers', '*');
res.setHeader('Access-Control-Allow-Credentials', '*');
next();
});
app.use(fileUpload({ debug: true }));
app.get('/', (req, res) => {
res.send('Status 🟢');
})
app.post('/upload', (req, res) => {
delete (req.files.file as any).data;
delete (req.files.file as any).mv;
console.log(req.files.file);
res.json({ success: true });
});
app.listen(port, () => {
console.log(`Server listening on http://localhost:${port}`)
})