-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Expand file tree
/
Copy pathesm.mjs
More file actions
38 lines (27 loc) · 1.06 KB
/
esm.mjs
File metadata and controls
38 lines (27 loc) · 1.06 KB
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
import path from "node:path";
import { release, version } from "node:os";
import { createServer as createServerHttp } from "node:http";
import { fileURLToPath } from "node:url";
import("./files/c.cjs");
const random = Math.random();
const unknownObject =
random > 0.5
? (await import("./files/a.json", { assert: { type: "json" } })).default
: (await import("./files/b.json", { assert: { type: "json" } })).default;
console.log(`Release ${release()}`);
console.log(`Version ${version()}`);
console.log(`Path segment separator is "${path.sep}"`);
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
console.log(`Path to current file is ${__filename}`);
console.log(`Path to current directory is ${__dirname}`);
const myServer = createServerHttp((_, res) => {
res.end("Request accepted");
});
const PORT = 3000;
console.log(unknownObject);
myServer.listen(PORT, () => {
console.log(`Server is listening on port ${PORT}`);
console.log("To terminate it, use Ctrl+C combination");
});
export { unknownObject, myServer };