remove internal api server
This commit is contained in:
parent
f8071c722a
commit
7354176c48
|
|
@ -0,0 +1,28 @@
|
|||
import { apiContext } from "service-srv";
|
||||
export const _ = {
|
||||
url: "/local-ip",
|
||||
async api() {
|
||||
const { req, res } = apiContext(this);
|
||||
|
||||
const { networkInterfaces } = require("os");
|
||||
|
||||
const nets = networkInterfaces();
|
||||
const results = Object.create(null); // Or just '{}', an empty object
|
||||
const all = [];
|
||||
for (const name of Object.keys(nets)) {
|
||||
for (const net of nets[name]) {
|
||||
// Skip over non-IPv4 and internal (i.e. 127.0.0.1) addresses
|
||||
// 'IPv4' is in Node <= 17, from 18 it's a number 4 or 6
|
||||
const familyV4Value = typeof net.family === "string" ? "IPv4" : 4;
|
||||
if (net.family === familyV4Value && !net.internal) {
|
||||
if (!results[name]) {
|
||||
results[name] = [];
|
||||
}
|
||||
results[name].push(net.address);
|
||||
all.push(net.address);
|
||||
}
|
||||
}
|
||||
}
|
||||
return all as string[];
|
||||
},
|
||||
};
|
||||
|
|
@ -57,6 +57,12 @@ declare module "app/srv/api/npm" {
|
|||
api(mode: "site" | "page", id: string): Promise<void>;
|
||||
};
|
||||
}
|
||||
declare module "app/srv/api/local-ip" {
|
||||
export const _: {
|
||||
url: string;
|
||||
api(): Promise<string[]>;
|
||||
};
|
||||
}
|
||||
declare module "app/web/src/utils/types/ws" {
|
||||
export type WS_MSG = WS_MSG_GET_COMP | WS_MSG_SET_COMP | WS_MSG_GET_PAGE | WS_MSG_SET_PAGE | WS_MSG_SV_LOCAL | WS_MSG_SVDIFF_REMOTE | WS_MSG_DIFF_LOCAL | WS_MSG_UNDO | WS_MSG_REDO | WS_MSG_NEW_COMP | WS_SITE_JS | {
|
||||
type: "ping";
|
||||
|
|
@ -634,6 +640,13 @@ declare module "app/srv/exports" {
|
|||
args: string[];
|
||||
handler: Promise<typeof import("app/srv/api/npm")>;
|
||||
};
|
||||
export const local_ip: {
|
||||
name: string;
|
||||
url: string;
|
||||
path: string;
|
||||
args: any[];
|
||||
handler: Promise<typeof import("app/srv/api/local-ip")>;
|
||||
};
|
||||
export const npm_bundle: {
|
||||
name: string;
|
||||
url: string;
|
||||
|
|
|
|||
|
|
@ -26,6 +26,13 @@ export const npm = {
|
|||
args: ["mode","id"],
|
||||
handler: import("./api/npm")
|
||||
}
|
||||
export const local_ip = {
|
||||
name: "local_ip",
|
||||
url: "/local-ip",
|
||||
path: "app/srv/api/local-ip.ts",
|
||||
args: [],
|
||||
handler: import("./api/local-ip")
|
||||
}
|
||||
export const npm_bundle = {
|
||||
name: "npm_bundle",
|
||||
url: "/npm-bundle/:mode/:id",
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ const start = async () => {
|
|||
w.db = createDB(base);
|
||||
|
||||
navigator.serviceWorker.addEventListener("message", (e) => {
|
||||
console.log("[SW]", e.data);
|
||||
if (e.data.type === "activated") {
|
||||
if (e.data.shouldRefresh && sw) {
|
||||
sw.unregister().then(() => {
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ export const APIConfig: FC<{
|
|||
>
|
||||
Use Existing API Server
|
||||
</div>
|
||||
<div>— OR —</div>
|
||||
{/* <div>— OR —</div>
|
||||
<div
|
||||
className="border-2 border-slate-500 text-blue-5 px-2 py-1 rounded cursor-pointer hover:bg-blue-100 hover:border-blue-500"
|
||||
onClick={async () => {
|
||||
|
|
@ -69,7 +69,7 @@ export const APIConfig: FC<{
|
|||
}}
|
||||
>
|
||||
Create New API Server
|
||||
</div>
|
||||
</div> */}
|
||||
</>
|
||||
)}
|
||||
{local.creating && (
|
||||
|
|
|
|||
Loading…
Reference in New Issue