-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Expand file tree
/
Copy pathesm.mjs
More file actions
43 lines (31 loc) · 1.12 KB
/
esm.mjs
File metadata and controls
43 lines (31 loc) · 1.12 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
39
40
41
42
43
import path from "node:path";
import { release, version } from "node:os";
import { createServer as createServerHttp } from "node:http";
import { fileURLToPath } from "url";
import { createRequire } from "node:module";
import a from "./files/a.json" with { type: "json" };
import b from "./files/b.json" with { type: "json" };
const require = createRequire(import.meta.url);
require("./files/c.js");
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const random = Math.random();
const unknownObject = random > 0.5 ? a : b
console.log(`Release ${release()}`);
console.log(`Version ${version()}`);
console.log(`Path segment separator is "${path.sep}"`);
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 default {
unknownObject,
myServer,
};