-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.ts
41 lines (31 loc) · 1.21 KB
/
server.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
30
31
32
33
34
35
36
37
38
39
40
41
// server.js
import express from 'express';
import next from 'next';
import ProviderLauch from './config/providerLaucher';
import bodyParser from 'body-parser';
import FileExplorerHandler from './pages/api/file-exporer/index';
import FileHandler from './pages/api/file-exporer/file';
import DirectoryHandler from './pages/api/file-exporer/directory';
import FileExplorerRefreshHandler from './pages/api/file-exporer/refresh';
const dev = process.env.NODE_ENV !== 'production'
const hostname = 'localhost'
const port = 3000
// when using middleware `hostname` and `port` must be provided below
const app = next({ dev, hostname, port })
const handle = app.getRequestHandler()
app.prepare().then(async () => {
await ProviderLauch.generateProviders();
const server = new express()
server.use(bodyParser.json());
server.all('/api/file-explorer', FileExplorerHandler)
server.all('/api/file-explorer/file', FileHandler)
server.all('/api/file-explorer/directory', DirectoryHandler)
server.all('/api/file-explorer/refresh', FileExplorerRefreshHandler)
server.get('*', (req, res) => {
return handle(req, res)
});
server.listen(port, hostname, err => {
if (err) throw err;
console.log('Server ready')
});
})