@absolutejs/absolute 0.2.1 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Elysia } from "elysia";
|
|
2
|
+
export declare const networkingPlugin: (app: Elysia) => Elysia<"", false, {
|
|
3
|
+
decorator: {};
|
|
4
|
+
store: {};
|
|
5
|
+
derive: {};
|
|
6
|
+
resolve: {};
|
|
7
|
+
}, {
|
|
8
|
+
type: {};
|
|
9
|
+
error: {};
|
|
10
|
+
}, {
|
|
11
|
+
schema: {};
|
|
12
|
+
macro: {};
|
|
13
|
+
}, {}, {
|
|
14
|
+
derive: {};
|
|
15
|
+
resolve: {};
|
|
16
|
+
schema: {};
|
|
17
|
+
}, {
|
|
18
|
+
derive: {};
|
|
19
|
+
resolve: {};
|
|
20
|
+
schema: {};
|
|
21
|
+
}>;
|
package/package.json
CHANGED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { argv } from "node:process";
|
|
2
|
+
import { env } from "bun";
|
|
3
|
+
import { Elysia } from "elysia";
|
|
4
|
+
import { getLocalIPAddress } from "../utils/networking";
|
|
5
|
+
import { DEFAULT_PORT } from "../constants";
|
|
6
|
+
|
|
7
|
+
let host = env.HOST ?? "localhost";
|
|
8
|
+
const port = env.PORT ?? DEFAULT_PORT;
|
|
9
|
+
let localIP: string | undefined;
|
|
10
|
+
|
|
11
|
+
const args = argv;
|
|
12
|
+
const hostFlag = args.includes("--host");
|
|
13
|
+
|
|
14
|
+
if (hostFlag) {
|
|
15
|
+
localIP = getLocalIPAddress();
|
|
16
|
+
host = "0.0.0.0";
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export const networkingPlugin = (app: Elysia) =>
|
|
20
|
+
app.listen(
|
|
21
|
+
{
|
|
22
|
+
hostname: host,
|
|
23
|
+
port: port
|
|
24
|
+
},
|
|
25
|
+
() => {
|
|
26
|
+
if (hostFlag) {
|
|
27
|
+
console.log(`Server started on http://localhost:${port}`);
|
|
28
|
+
console.log(
|
|
29
|
+
`Server started on network: http://${localIP}:${port}`
|
|
30
|
+
);
|
|
31
|
+
} else {
|
|
32
|
+
console.log(`Server started on http://${host}:${port}`);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
);
|