-
Notifications
You must be signed in to change notification settings - Fork 98
Expand file tree
/
Copy pathmain.js
More file actions
24 lines (19 loc) · 623 Bytes
/
Copy pathmain.js
File metadata and controls
24 lines (19 loc) · 623 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
'use strict';
const fsp = require('node:fs').promises;
const path = require('node:path');
const server = require('./ws.js');
const staticServer = require('./static.js');
const apiPath = path.join(process.cwd(), './api');
const routing = {};
const main = async () => {
const files = await fsp.readdir(apiPath);
for (const fileName of files) {
if (!fileName.endsWith('.js')) continue;
const filePath = path.join(apiPath, fileName);
const serviceName = path.basename(fileName, '.js');
routing[serviceName] = require(filePath);
}
staticServer('./static', 8000);
server(routing, 8001);
};
main();