diff --git a/packages/core/src/logger.ts b/packages/core/src/logger.ts index a09f9f76..5c1a7aa4 100644 --- a/packages/core/src/logger.ts +++ b/packages/core/src/logger.ts @@ -1,3 +1,4 @@ +/* eslint-disable @typescript-eslint/no-duplicate-enum-values */ import { createConsola } from "consola"; import type { ConsolaInstance } from "consola"; @@ -79,11 +80,11 @@ export function setLoggerLevel( break; case "silent": case FourzeLogLevel.Silent: - logger.level = -Infinity; + logger.level = Number.NEGATIVE_INFINITY; break; case "verbose": case FourzeLogLevel.Verbose: - logger.level = Infinity; + logger.level = Number.POSITIVE_INFINITY; break; } }; diff --git a/packages/core/src/polyfill/response.ts b/packages/core/src/polyfill/response.ts index 32fb16e8..c5c509ef 100644 --- a/packages/core/src/polyfill/response.ts +++ b/packages/core/src/polyfill/response.ts @@ -1,4 +1,4 @@ -import EventEmitter from "events"; +import EventEmitter from "node:events"; import { getHeaderRawValue } from "./header"; export class PolyfillServerResponse extends EventEmitter { diff --git a/packages/core/src/shared/context.ts b/packages/core/src/shared/context.ts index 955e9ba1..864ff489 100644 --- a/packages/core/src/shared/context.ts +++ b/packages/core/src/shared/context.ts @@ -1,4 +1,4 @@ -import type { IncomingMessage, OutgoingMessage } from "http"; +import type { IncomingMessage, OutgoingMessage } from "node:http"; import type { FourzeRequest } from "./request"; import { createRequest } from "./request"; import type { FourzeResponse } from "./response"; diff --git a/packages/core/src/shared/interface.ts b/packages/core/src/shared/interface.ts index 8531d661..0115e827 100644 --- a/packages/core/src/shared/interface.ts +++ b/packages/core/src/shared/interface.ts @@ -1,4 +1,4 @@ -import type { IncomingMessage, OutgoingMessage } from "http"; +import type { IncomingMessage, OutgoingMessage } from "node:http"; import type { MaybePromise, MaybeRegex } from "maybe-types"; import { overload } from "../utils"; import type { FourzeContextOptions, FourzeServiceContext } from "./context"; diff --git a/packages/core/src/shared/matcher.ts b/packages/core/src/shared/matcher.ts index feb1b218..8339e7e0 100644 --- a/packages/core/src/shared/matcher.ts +++ b/packages/core/src/shared/matcher.ts @@ -209,7 +209,7 @@ export function createRouteMatcher(options: RouteMatcherOptions = {}): RouteM const data = node.payload.get(method); if (data) { - const lastSection = sections[sections.length - 1]; + const lastSection = sections.at(-1); node.payload.delete(method); if (Object.keys(node.children).length === 0) { const parentNode = node.parent!; @@ -235,7 +235,7 @@ export function createRouteMatcher(options: RouteMatcherOptions = {}): RouteM }; } -const PARAM_KEY_REGEX = /^\{.*\}$/; +const PARAM_KEY_REGEX = /^{.*}$/; function getNodeType(path: string) { if (path.startsWith("**")) { diff --git a/packages/core/src/shared/request.ts b/packages/core/src/shared/request.ts index 54215d76..26ef3540 100644 --- a/packages/core/src/shared/request.ts +++ b/packages/core/src/shared/request.ts @@ -1,8 +1,7 @@ -import type { IncomingMessage } from "http"; -import {parseQuery} from "ufo"; +import type { IncomingMessage } from "node:http"; +import { getQuery, parseQuery, parseURL, withoutBase } from "ufo"; import type { MaybeRegex } from "maybe-types"; import { safeParse } from "fast-content-type-parse"; -import { getQuery, parseURL, withoutBase } from "ufo"; import type { PolyfillHeaderInit } from "../polyfill"; import { decodeFormData, flatHeaders, getHeaderValue } from "../polyfill"; import { isString, isUint8Array, parseJson } from "../utils"; diff --git a/packages/core/src/shared/response.ts b/packages/core/src/shared/response.ts index a550cac9..8071d9ce 100644 --- a/packages/core/src/shared/response.ts +++ b/packages/core/src/shared/response.ts @@ -1,4 +1,4 @@ -import type { OutgoingMessage, ServerResponse } from "http"; +import type { OutgoingMessage, ServerResponse } from "node:http"; import { safeParse } from "fast-content-type-parse"; import { PolyfillServerResponse, getHeaderValue } from "../polyfill"; import { assert, defineOverload, isDef, isNumber, isObject, isString, isUint8Array, isUndefined } from "../utils"; diff --git a/packages/core/src/utils/array.ts b/packages/core/src/utils/array.ts index 085573fa..cf7eca6e 100644 --- a/packages/core/src/utils/array.ts +++ b/packages/core/src/utils/array.ts @@ -256,7 +256,7 @@ export class CollectionQueryClass implements ArrayLike { deleteProperty(target, prop) { if (isString(prop)) { let index = +prop; - if (!isNaN(index)) { + if (!Number.isNaN(index)) { index = normalizeIndex(index, target.length); return delete target.source[index]; } @@ -655,7 +655,7 @@ export class CollectionQueryClass implements ArrayLike { } last() { - return this.source[this.source.length - 1]; + return this.source.at(-1); } toMap(keySelector: MapFn, valueSelector?: MapFn) { diff --git a/packages/core/src/utils/events.ts b/packages/core/src/utils/events.ts index 4e54eeb9..d203423e 100644 --- a/packages/core/src/utils/events.ts +++ b/packages/core/src/utils/events.ts @@ -1,4 +1,4 @@ -import EventEmitter from "events"; +import EventEmitter from "node:events"; export function injectEventEmitter(app: T) { const _emitter = new EventEmitter(); diff --git a/packages/core/src/utils/faker.ts b/packages/core/src/utils/faker.ts index a158f4bc..7e17ad8b 100644 --- a/packages/core/src/utils/faker.ts +++ b/packages/core/src/utils/faker.ts @@ -20,7 +20,7 @@ export function parseFakerNumber(num: MaybeArray): number { if (num.match(/^\d+-\d+$/g)) { return randomInt(num); } - return parseInt(num); + return Number.parseInt(num); } return num; } @@ -92,11 +92,11 @@ export function parseFakerValue( context: any = {} ) { if (isString(val)) { - if (val.match(/^\{[^}]*\}$/g)) { + if (val.match(/^{[^}]*}$/g)) { return parseFakerDynamic(val.slice(1, -1), context); } - const matches = val.match(/\{[^}]*}/g); + const matches = val.match(/{[^}]*}/g); if (matches) { for (const match of matches) { const matchValue = match.slice(1, -1); diff --git a/packages/core/src/utils/random.ts b/packages/core/src/utils/random.ts index eb23f759..99fd3a2c 100644 --- a/packages/core/src/utils/random.ts +++ b/packages/core/src/utils/random.ts @@ -18,8 +18,8 @@ export function randomInt(param0: number | string, max?: number) { let min: number; if (isString(param0)) { const [minStr, maxStr] = param0.split("-"); - min = parseInt(minStr); - max = parseInt(maxStr); + min = Number.parseInt(minStr); + max = Number.parseInt(maxStr); } else { min = param0; } diff --git a/packages/core/src/utils/storage.ts b/packages/core/src/utils/storage.ts index f74de6f9..3d3dda0b 100644 --- a/packages/core/src/utils/storage.ts +++ b/packages/core/src/utils/storage.ts @@ -78,7 +78,7 @@ export function createStorage(options: StorageOptions = {}): Storage { function emitChange() { if (persistence) { if (isNode()) { - const fs = require("fs") as typeof import("fs"); + const fs = require("node:fs") as typeof import("fs"); fs.writeFileSync(`${dir}/${id}`, JSON.stringify(storage)); } else { const _store = target === "local" ? localStorage : sessionStorage; @@ -89,8 +89,8 @@ export function createStorage(options: StorageOptions = {}): Storage { function initStorage() { if (isNode()) { - const fs = require("fs") as typeof import("fs"); - const path = require("path") as typeof import("path"); + const fs = require("node:fs") as typeof import("fs"); + const path = require("node:path") as typeof import("path"); const storagePath = path.resolve(dir); if (!fs.existsSync(storagePath)) { fs.mkdirSync(storagePath); diff --git a/packages/core/src/utils/string.ts b/packages/core/src/utils/string.ts index 7fc68f5a..1a3ae808 100644 --- a/packages/core/src/utils/string.ts +++ b/packages/core/src/utils/string.ts @@ -22,7 +22,7 @@ export function escapeStringRegexp(str: string) { // Escape characters with special meaning either inside or outside character sets. // Use a simple backslash escape when it’s always valid, and a `\xnn` escape when the simpler form would be disallowed by Unicode patterns’ stricter grammar. return str - .replace(/[|\\{}()[\]^$+*?.]/g, "\\$&") + .replace(/[$()*+.?[\\\]^{|}]/g, "\\$&") .replace(/-/g, "\\x2d"); } diff --git a/packages/integrations/nuxt/src/module.ts b/packages/integrations/nuxt/src/module.ts index 49066a2c..9b13b146 100644 --- a/packages/integrations/nuxt/src/module.ts +++ b/packages/integrations/nuxt/src/module.ts @@ -33,25 +33,25 @@ export default defineNuxtModule({ write: true, getContents() { return dedent` - import { createServer,createHmrApp } from "@fourze/server" - import { defineEventHandler } from "h3" + import { createServer,createHmrApp } from "@fourze/server" + import { defineEventHandler } from "h3" - const hmrApp = createHmrApp({ - base: "${options.base ?? "/api"}", - dir: "${options.dir ?? "./mock"}", - delay: ${JSON.stringify(options.delay ?? 0)}, - }) + const hmrApp = createHmrApp({ + base: "${options.base ?? "/api"}", + dir: "${options.dir ?? "./mock"}", + delay: ${JSON.stringify(options.delay ?? 0)}, + }) - const service = createServer(hmrApp) + const service = createServer(hmrApp) - const onNotFound = () => { - /** empty */ - } + const onNotFound = () => { + /** empty */ + } - export default defineEventHandler(async event => { - await service(event.node.req, event.node.res, onNotFound) - }) - `; + export default defineEventHandler(async event => { + await service(event.node.req, event.node.res, onNotFound) + }) + `; } }); diff --git a/packages/integrations/swagger-middleware/src/index.ts b/packages/integrations/swagger-middleware/src/index.ts index d54cafca..7e7068a4 100644 --- a/packages/integrations/swagger-middleware/src/index.ts +++ b/packages/integrations/swagger-middleware/src/index.ts @@ -70,8 +70,8 @@ export function createSwaggerMiddleware( function getPaths() { const paths = new Map< - string, - Record | SwaggerPathSchema + string, + Record | SwaggerPathSchema >(); const groups = routes.groupBy((e) => e.path); for (const [path, routes] of groups) { @@ -105,8 +105,8 @@ export function createSwaggerMiddleware( } } const newPath = Object.fromEntries(map.entries()) as Record< - RequestMethod, - SwaggerPathSchema + RequestMethod, + SwaggerPathSchema >; let exist = paths.get(path); if (exist) { diff --git a/packages/integrations/swagger-middleware/src/types.ts b/packages/integrations/swagger-middleware/src/types.ts index e8ddc7dd..6de9b4d6 100644 --- a/packages/integrations/swagger-middleware/src/types.ts +++ b/packages/integrations/swagger-middleware/src/types.ts @@ -9,11 +9,11 @@ export interface SwaggerPathSchema { consumes?: string[] produces?: string[] responses?: Record< - string, - { - description: string - schema?: Record - } + string, + { + description: string + schema?: Record + } > } diff --git a/packages/integrations/swagger/src/build.ts b/packages/integrations/swagger/src/build.ts index d38b2b15..72afe7be 100644 --- a/packages/integrations/swagger/src/build.ts +++ b/packages/integrations/swagger/src/build.ts @@ -1,4 +1,4 @@ -import path from "path"; +import path from "node:path"; import type { FourzeHmrApp } from "@fourze/server"; import type { InlineConfig } from "vite"; diff --git a/packages/integrations/unplugin/src/index.ts b/packages/integrations/unplugin/src/index.ts index 2876ee8a..ee0a3a58 100644 --- a/packages/integrations/unplugin/src/index.ts +++ b/packages/integrations/unplugin/src/index.ts @@ -1,18 +1,18 @@ -import path from "path"; +import path from "node:path"; import type { DelayMsType, FourzeLogLevelKey, - RequestMethod, + RequestMethod } from "@fourze/core"; import { createLogger, isBoolean, setLoggerLevel, - withBase, + withBase } from "@fourze/core"; import { createDelayMiddleware, - createTimeoutMiddleware, + createTimeoutMiddleware } from "@fourze/middlewares"; import { createUnplugin } from "unplugin"; @@ -22,7 +22,7 @@ import { connect, createHmrApp, createServer, - defineEnvs, + defineEnvs } from "@fourze/server"; import { build, getModuleAlias, service } from "@fourze/swagger"; @@ -41,86 +41,86 @@ export interface SwaggerPluginOption { /** * @default vite.base + "/swagger-ui/" */ - base?: string; + base?: string - generateDocument?: boolean; + generateDocument?: boolean - defaultMethod?: RequestMethod; + defaultMethod?: RequestMethod } export type MockEnable = boolean | "auto"; export interface MockOptions { - enable?: MockEnable; - mode?: FourzeMockAppOptions["mode"]; - injectScript?: boolean; - host?: string | string[]; + enable?: MockEnable + mode?: FourzeMockAppOptions["mode"] + injectScript?: boolean + host?: string | string[] } export interface UnpluginFourzeOptions { /** * @default 'src/mock' */ - dir?: string; + dir?: string /** * @default '/api' */ - base?: string; + base?: string /** * @default env.command == 'build' || env.mode === 'mock' */ - mock?: MockOptions | boolean; + mock?: MockOptions | boolean /** * @default true * */ - hmr?: boolean; + hmr?: boolean /** * @default "info" */ - logLevel?: FourzeLogLevelKey | number; + logLevel?: FourzeLogLevelKey | number server?: { /** * */ - host?: string; + host?: string /** * */ - port?: number; - }; + port?: number + } files?: - | { - /** + | { + /** * @default ["*.ts","*.js"] */ - pattern?: string[]; - ignore?: string[]; - } - | string[]; + pattern?: string[] + ignore?: string[] + } + | string[] - proxy?: (FourzeProxyOption | string)[] | Record; + proxy?: (FourzeProxyOption | string)[] | Record - delay?: DelayMsType; + delay?: DelayMsType /** * @default 5000 */ - timeout?: number; + timeout?: number - allow?: string[]; + allow?: string[] - deny?: string[]; + deny?: string[] - swagger?: SwaggerPluginOption | boolean; + swagger?: SwaggerPluginOption | boolean - transformCode?: typeof createMockClient; + transformCode?: typeof createMockClient } const createFourzePlugin = createUnplugin( @@ -143,13 +143,13 @@ const createFourzePlugin = createUnplugin( const defaultEnableMockOptions: MockOptions = { enable: true, injectScript: true, - mode: ["xhr", "fetch"], + mode: ["xhr", "fetch"] }; const defaultDisableMockOptions: MockOptions = { enable: false, injectScript: false, - mode: [], + mode: [] }; const mockOptions: MockOptions = isBoolean(options.mock) @@ -159,7 +159,7 @@ const createFourzePlugin = createUnplugin( : { ...defaultEnableMockOptions, enable: "auto", - ...options.mock, + ...options.mock }; const injectScript = mockOptions.injectScript ?? true; @@ -183,7 +183,7 @@ const createFourzePlugin = createUnplugin( allow, deny, dir, - files: options.files, + files: options.files }); if (timeout) { @@ -203,8 +203,8 @@ const createFourzePlugin = createUnplugin( const swaggerOptions = isBoolean(options.swagger) ? {} : options.swagger ?? {}; - const generateDocument = - swaggerOptions.generateDocument ?? !!options.swagger; + const generateDocument + = swaggerOptions.generateDocument ?? !!options.swagger; return [ { @@ -214,12 +214,12 @@ const createFourzePlugin = createUnplugin( await build(hmrApp, { distPath: viteConfig.build?.outDir, vite: { - ...viteConfig, + ...viteConfig }, swagger: { basePath: base, - ...swaggerOptions, - }, + ...swaggerOptions + } }); } }, @@ -245,7 +245,7 @@ const createFourzePlugin = createUnplugin( ...options, base, mode: mockOptions.mode, - host: mockOptions.host, + host: mockOptions.host }); } }, @@ -267,45 +267,45 @@ const createFourzePlugin = createUnplugin( tag: "script", attrs: { type: "module", - src: `/${CLIENT_ID}`, - }, - }, - ], + src: `/${CLIENT_ID}` + } + } + ] }; } return html; - }, + } }, async config(_, env) { if (mockOptions.enable === "auto") { - mockOptions.enable = - env.command === "build" || env.mode === "mock"; + mockOptions.enable + = env.command === "build" || env.mode === "mock"; } return { define: { - VITE_PLUGIN_FOURZE_MOCK: mockOptions.enable, + VITE_PLUGIN_FOURZE_MOCK: mockOptions.enable }, resolve: { - alias: env.command === "build" ? getModuleAlias() : [], + alias: env.command === "build" ? getModuleAlias() : [] }, build: { rollupOptions: { - external: ["@fourze/server"], - }, - }, + external: ["@fourze/server"] + } + } }; }, async configResolved(config) { hmrApp.configure({ define: { ...defineEnvs(config.env, "import.meta.env."), - ...defineEnvs(config.define ?? {}), + ...defineEnvs(config.define ?? {}) }, alias: Object.fromEntries( config.resolve.alias.map((r) => { return [r.find, r.replacement]; }) - ), + ) }); viteConfig.base = config.base; viteConfig.envDir = path.resolve(config.root, config.envDir ?? ""); @@ -323,14 +323,14 @@ const createFourzePlugin = createUnplugin( const swaggerMiddleware = service(hmrApp, { uiBase, basePath: base, - ...swaggerOptions, + ...swaggerOptions }); middlewares.use(uiBase, connect(swaggerMiddleware)); } middlewares.use(base, connect(hmrApp)); - }, - }, - }, + } + } + } ]; } ); diff --git a/packages/middlewares/src/middlewares/filter.ts b/packages/middlewares/src/middlewares/filter.ts index 8edd9e88..2a44ddb1 100644 --- a/packages/middlewares/src/middlewares/filter.ts +++ b/packages/middlewares/src/middlewares/filter.ts @@ -23,10 +23,6 @@ export function createFilterMiddleware( } return defineMiddleware(middleware.name ?? "Match", middleware.order ?? -1, async (req, res, next) => { const { path } = req; - if (isInclude(path)) { - await middleware(req, res, next); - } else { - await next?.(); - } + await (isInclude(path) ? middleware(req, res, next) : next?.()); }); } diff --git a/packages/middlewares/src/middlewares/resolve.ts b/packages/middlewares/src/middlewares/resolve.ts index abf0a127..b1ff313f 100644 --- a/packages/middlewares/src/middlewares/resolve.ts +++ b/packages/middlewares/src/middlewares/resolve.ts @@ -61,11 +61,7 @@ export function createResolveMiddleware( const isAllow = (isUndef(useResolve) || !["false", "0", "off"].includes(useResolve)); if (isAllow) { - if (isError(payload) && reject) { - payload = reject(payload) ?? payload; - } else { - payload = resolve(payload, contentType) ?? payload; - } + payload = isError(payload) && reject ? reject(payload) ?? payload : resolve(payload, contentType) ?? payload; } _send(payload, statusCode, contentType); diff --git a/packages/mock/src/app.ts b/packages/mock/src/app.ts index 8122cc0f..21502cbb 100644 --- a/packages/mock/src/app.ts +++ b/packages/mock/src/app.ts @@ -1,4 +1,4 @@ -import type http from "http"; +import type http from "node:http"; import type { FourzeContextOptions } from "@fourze/core"; import { FOURZE_VERSION, @@ -67,8 +67,8 @@ export function createMockApp( let _request: typeof http.request; if (isNode()) { - const http = require("http"); - const https = require("https"); + const http = require("node:http"); + const https = require("node:https"); app.originalHttpRequest = http.request; app.originalHttpsRequest = https.request; @@ -145,8 +145,8 @@ export function createMockApp( globalThis.fetch = app.fetch; } if (isNode() && activeMode.has("request")) { - const http = require("http") as typeof import("http"); - const https = require("https") as typeof import("https"); + const http = require("node:http") as typeof import("http"); + const https = require("node:https") as typeof import("https"); http.request = app.request; https.request = app.request; } @@ -166,8 +166,8 @@ export function createMockApp( globalThis.fetch = app.originalFetch; } if (_mode.includes("request") && isNode()) { - const http = require("http") as typeof import("http"); - const https = require("https") as typeof import("https"); + const http = require("node:http") as typeof import("http"); + const https = require("node:https") as typeof import("https"); http.request = this.originalHttpRequest; https.request = this.originalHttpsRequest; } diff --git a/packages/mock/src/client.ts b/packages/mock/src/client.ts index b15021c7..272ed07a 100644 --- a/packages/mock/src/client.ts +++ b/packages/mock/src/client.ts @@ -18,10 +18,10 @@ export function createMockClient( } code += dedent` - createMockApp({ - ...${JSON.stringify(options)}, - modules:[${names.join(",")}].flat(), - }); + createMockApp({ + ...${JSON.stringify(options)}, + modules:[${names.join(",")}].flat(), + }); `; return code; } diff --git a/packages/mock/src/request.ts b/packages/mock/src/request.ts index 833d7843..92c6348f 100644 --- a/packages/mock/src/request.ts +++ b/packages/mock/src/request.ts @@ -3,9 +3,9 @@ import type { ClientRequestArgs, IncomingMessage, RequestOptions -} from "http"; -import type http from "http"; -import type https from "https"; +} from "node:http"; +import type http from "node:http"; +import type https from "node:https"; import { assert, createLogger, @@ -52,7 +52,7 @@ export function createProxyRequest(app: FourzeMockApp) { return; } - const { Writable, Readable } = require("stream") as typeof import("stream"); + const { Writable, Readable } = require("node:stream") as typeof import("stream"); class ProxyClientResponse extends Readable { headers: IncomingMessage["headers"]; diff --git a/packages/mock/src/shared.ts b/packages/mock/src/shared.ts index b31ff206..5b19599e 100644 --- a/packages/mock/src/shared.ts +++ b/packages/mock/src/shared.ts @@ -1,5 +1,5 @@ -import type http from "http"; -import type https from "https"; +import type http from "node:http"; +import type https from "node:https"; import type { DelayMsType, FourzeApp, FourzeAppOptions } from "@fourze/core"; export type FourzeMockRequestMode = "xhr" | "fetch" | "request"; diff --git a/packages/server/src/importer.ts b/packages/server/src/importer.ts index 610bdd48..584cedd6 100644 --- a/packages/server/src/importer.ts +++ b/packages/server/src/importer.ts @@ -1,7 +1,7 @@ -import { runInThisContext } from "vm"; -import { Module, builtinModules } from "module"; -import { platform } from "os"; -import { pathToFileURL } from "url"; +import { runInThisContext } from "node:vm"; +import { Module, builtinModules } from "node:module"; +import { platform } from "node:os"; +import { pathToFileURL } from "node:url"; import { dirname, extname, join } from "pathe"; import { normalizeAliases, resolveAlias } from "pathe/utils"; import { createLogger, escapeStringRegexp, parseJson } from "@fourze/core"; diff --git a/packages/server/src/renderer.ts b/packages/server/src/renderer.ts index cbac15e0..f5678925 100644 --- a/packages/server/src/renderer.ts +++ b/packages/server/src/renderer.ts @@ -1,5 +1,5 @@ -import fs from "fs"; -import path from "path"; +import fs from "node:fs"; +import path from "node:path"; import type { FourzeComponent, FourzeLogger, @@ -152,7 +152,7 @@ export async function renderTsx( requireCache: false }); - const maybes = file.match(/\.[t|j]sx$/) ? [file] : []; + const maybes = file.match(/\.[jt|]sx$/) ? [file] : []; maybes.push( ...["index.tsx", "index.jsx"].map((ext) => path.normalize(`${file}/${ext}`)) ); diff --git a/packages/server/src/server.ts b/packages/server/src/server.ts index 96d350a9..a60d6d0a 100644 --- a/packages/server/src/server.ts +++ b/packages/server/src/server.ts @@ -1,7 +1,7 @@ -import type EventEmitter from "events"; -import type { IncomingMessage, OutgoingMessage, Server } from "http"; -import http from "http"; -import https from "https"; +import type EventEmitter from "node:events"; +import type { IncomingMessage, OutgoingMessage, Server } from "node:http"; +import http from "node:http"; +import https from "node:https"; import { FOURZE_VERSION, createApp, diff --git a/packages/server/src/utils.ts b/packages/server/src/utils.ts index 30d0799b..b1ffea7a 100644 --- a/packages/server/src/utils.ts +++ b/packages/server/src/utils.ts @@ -1,10 +1,10 @@ -import os from "os"; -import path from "path"; -import { promises as dns } from "dns"; -import net from "net"; +import os from "node:os"; +import path from "node:path"; +import { promises as dns } from "node:dns"; +import net from "node:net"; -import type { AddressInfo } from "net"; -import type { Server } from "http"; +import type { AddressInfo } from "node:net"; +import type { Server } from "node:http"; import { isNumber, isString, normalizeURL } from "@fourze/core"; import { loopbackHosts, wildcardHosts } from "./constants"; @@ -28,7 +28,7 @@ export function defineEnvs( } export async function getLocalhostAddressIfDiffersFromDNS(): Promise< - string | undefined +string | undefined > { const [nodeResult, dnsResult] = await Promise.all([ dns.lookup("localhost"),