silgi 0.38.0 → 0.38.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.
- package/dist/cli/build.mjs +7 -7
- package/dist/cli/index.mjs +1 -1
- package/dist/kit/index.d.mts +2 -2
- package/dist/kit/index.mjs +5 -12
- package/dist/types/index.d.mts +5 -5
- package/package.json +1 -1
package/dist/cli/build.mjs
CHANGED
|
@@ -429,18 +429,18 @@ async function registerModuleExportScan(silgi) {
|
|
|
429
429
|
});
|
|
430
430
|
options.runtimeHooks.push({ key: configKey, value: importName });
|
|
431
431
|
}
|
|
432
|
-
if (hasTypeExport("
|
|
433
|
-
const importName = hash(`${configKey}
|
|
432
|
+
if (hasTypeExport("SetupModuleOption")) {
|
|
433
|
+
const importName = hash(`${configKey}SetupModuleOption`);
|
|
434
434
|
options.addImportItemType({
|
|
435
435
|
imports: [
|
|
436
436
|
{
|
|
437
437
|
as: importName,
|
|
438
|
-
name: "
|
|
438
|
+
name: "SetupModuleOption"
|
|
439
439
|
}
|
|
440
440
|
],
|
|
441
441
|
specifier
|
|
442
442
|
});
|
|
443
|
-
options.
|
|
443
|
+
options.setupModuleOption.push({ key: configKey, value: importName });
|
|
444
444
|
}
|
|
445
445
|
if (hasTypeExport("ModuleRuntimeMethods")) {
|
|
446
446
|
const importName = hash(`${configKey}ModuleRuntimeMethods`);
|
|
@@ -1862,7 +1862,7 @@ async function prepareSchema(silgi) {
|
|
|
1862
1862
|
addImportItemType,
|
|
1863
1863
|
options: [],
|
|
1864
1864
|
contexts: [],
|
|
1865
|
-
|
|
1865
|
+
setupModuleOption: [],
|
|
1866
1866
|
shareds: [],
|
|
1867
1867
|
events: [],
|
|
1868
1868
|
hooks: [],
|
|
@@ -1900,7 +1900,7 @@ async function prepareSchema(silgi) {
|
|
|
1900
1900
|
}).join(",\n")}
|
|
1901
1901
|
}` : "interface SilgiModuleEventsExtends {}",
|
|
1902
1902
|
"",
|
|
1903
|
-
`type
|
|
1903
|
+
`type SetupModuleOptionExtend = ${data.setupModuleOption?.length ? data.setupModuleOption.map(({ value }) => `${value}`).join(" & ") : "{}"}`,
|
|
1904
1904
|
"",
|
|
1905
1905
|
`type RuntimeMethodExtends = ${data.methods?.length ? data.methods.map(({ value }) => `${value}`).join(" & ") : "{}"}`,
|
|
1906
1906
|
"",
|
|
@@ -1961,7 +1961,7 @@ async function prepareSchema(silgi) {
|
|
|
1961
1961
|
SilgiRuntimeContext: [{}, { extends: ["SilgiModuleContextExtends"] }],
|
|
1962
1962
|
SilgiEvent: [{}, { extends: ["SilgiModuleEventsExtends"] }],
|
|
1963
1963
|
SilgiRuntimeSharedsExtend: [{}, { extends: ["SilgiModuleSharedExtends"] }],
|
|
1964
|
-
|
|
1964
|
+
SetupModuleOption: [{}, { extends: ["SetupModuleOptionExtend"] }],
|
|
1965
1965
|
SilgiRuntimeOptions: [{}, { extends: ["SilgiRuntimeOptionExtends"] }],
|
|
1966
1966
|
SilgiRuntimeHooks: [{}, { extends: ["SilgiRuntimeHooksExtends"] }],
|
|
1967
1967
|
SilgiRuntimeConfig: [{}, { extends: ["SilgiRuntimeConfigExtends"] }],
|
package/dist/cli/index.mjs
CHANGED
package/dist/kit/index.d.mts
CHANGED
|
@@ -282,10 +282,10 @@ declare function useResponse<T extends ServerResponse>(event: SilgiEvent): Serve
|
|
|
282
282
|
declare function getIpAddress(event: SilgiEvent): string | boolean;
|
|
283
283
|
/**
|
|
284
284
|
* Extract the client's IP address from request headers with high accuracy
|
|
285
|
-
* @param req - The incoming HTTP request
|
|
285
|
+
* @param req - The incoming HTTP request (Fetch API Request)
|
|
286
286
|
* @returns The client's IP address or empty string if not found
|
|
287
287
|
*/
|
|
288
|
-
declare function ipAddress(req:
|
|
288
|
+
declare function ipAddress(req: Request): string;
|
|
289
289
|
|
|
290
290
|
declare function relativeWithDot(from: string, to: string): string;
|
|
291
291
|
declare function toArray<T>(value: T | T[]): T[];
|
package/dist/kit/index.mjs
CHANGED
|
@@ -940,12 +940,8 @@ function useResponse(event) {
|
|
|
940
940
|
return event;
|
|
941
941
|
}
|
|
942
942
|
function getIpAddress(event) {
|
|
943
|
-
const
|
|
944
|
-
|
|
945
|
-
const _ipAddress = ipAddress(event.node.req);
|
|
946
|
-
return _ipAddress;
|
|
947
|
-
}
|
|
948
|
-
return false;
|
|
943
|
+
const _ipAddress = ipAddress(event.req);
|
|
944
|
+
return _ipAddress;
|
|
949
945
|
}
|
|
950
946
|
function ipAddress(req) {
|
|
951
947
|
const headers = [
|
|
@@ -981,13 +977,11 @@ function ipAddress(req) {
|
|
|
981
977
|
// Used by some CDNs
|
|
982
978
|
];
|
|
983
979
|
for (const header of headers) {
|
|
984
|
-
const value = req.headers
|
|
980
|
+
const value = req.headers.get(header);
|
|
985
981
|
if (!value)
|
|
986
982
|
continue;
|
|
987
983
|
let ip;
|
|
988
|
-
if (
|
|
989
|
-
ip = value[0];
|
|
990
|
-
} else if (header === "x-forwarded-for" || header === "forwarded-for" || header === "x-original-forwarded-for") {
|
|
984
|
+
if (header === "x-forwarded-for" || header === "forwarded-for" || header === "x-original-forwarded-for") {
|
|
991
985
|
ip = value.split(",")[0];
|
|
992
986
|
} else if (header === "forwarded") {
|
|
993
987
|
const match = value.match(/for=([^;]+)/);
|
|
@@ -1000,8 +994,7 @@ function ipAddress(req) {
|
|
|
1000
994
|
return cleanIp;
|
|
1001
995
|
}
|
|
1002
996
|
}
|
|
1003
|
-
|
|
1004
|
-
return socketIp && isValidIp(socketIp) ? socketIp : "";
|
|
997
|
+
return "";
|
|
1005
998
|
}
|
|
1006
999
|
function isValidIp(ip) {
|
|
1007
1000
|
if (ip === "::1" || ip === "localhost" || ip === "127.0.0.1")
|
package/dist/types/index.d.mts
CHANGED
|
@@ -357,7 +357,7 @@ type ServiceHandler<Schema extends SilgiSchema, Route extends keyof Schema, Meth
|
|
|
357
357
|
interface ServiceSetup<Schema extends SilgiSchema = SilgiSchema, Route extends keyof Schema = keyof Schema, Method extends keyof Schema[Route] = keyof Schema[Route], Resolved extends boolean = false, HiddenParameters extends boolean = false> {
|
|
358
358
|
handler: ServiceHandler<Schema, Route, Method, Resolved, HiddenParameters>;
|
|
359
359
|
rules?: RouteConfigService;
|
|
360
|
-
modules?: Partial<
|
|
360
|
+
modules?: Partial<SetupModuleOption>;
|
|
361
361
|
storage?: StorageConfig<ServiceHandlerInput<Schema, Route, Method, HiddenParameters>>;
|
|
362
362
|
}
|
|
363
363
|
/**
|
|
@@ -395,7 +395,7 @@ type MiddlewareHandler<Response extends EventHandlerResponse = EventHandlerRespo
|
|
|
395
395
|
interface MiddlewareSetup {
|
|
396
396
|
handler: MiddlewareHandler;
|
|
397
397
|
rules?: RouteRules;
|
|
398
|
-
modules?: Partial<
|
|
398
|
+
modules?: Partial<SetupModuleOption>;
|
|
399
399
|
storage?: StorageConfig;
|
|
400
400
|
}
|
|
401
401
|
type MiddlewareDefinition = MiddlewareSetup;
|
|
@@ -513,7 +513,7 @@ interface ResolvedSilgiTemplate<Options = TemplateDefaultOptions> extends SilgiT
|
|
|
513
513
|
modified?: boolean;
|
|
514
514
|
}
|
|
515
515
|
|
|
516
|
-
interface
|
|
516
|
+
interface SetupModuleOption {
|
|
517
517
|
}
|
|
518
518
|
interface SilgiModuleOptions {
|
|
519
519
|
}
|
|
@@ -873,7 +873,7 @@ interface SilgiCLIHooks extends SilgiHooks {
|
|
|
873
873
|
key: string;
|
|
874
874
|
value: string;
|
|
875
875
|
}[];
|
|
876
|
-
|
|
876
|
+
setupModuleOption: {
|
|
877
877
|
key: string;
|
|
878
878
|
value: string;
|
|
879
879
|
}[];
|
|
@@ -1229,4 +1229,4 @@ interface LoadConfigOptions {
|
|
|
1229
1229
|
consola?: ConsolaInstance;
|
|
1230
1230
|
}
|
|
1231
1231
|
|
|
1232
|
-
export type { AllPaths, AllPrefixes, AppConfig, Awaitable, BuildSilgi, CaptureError, CapturedErrorContext, CommandType, Commands, CustomRequestInit, DeepPartial, DeepRequired, DefaultHooks, DefineFrameworkOptions, DotenvOptions, EnvOptions, EventHandlerResponse, ExtendContext, ExtendShared, ExtractNamespace, ExtractPathParamKeys, ExtractPathParams, ExtractPrefix, ExtractRoute, GenImport, GenerateAppOptions, HTTPMethod, HookResult, HttpMethod, LoadConfigOptions, MergeAll, MergedSilgiSchema, MethodSchemas, MiddlewareDefinition, MiddlewareHandler, MiddlewareRoute, MiddlewareSetup, ModuleDefinition, ModuleHookContext, ModuleMeta, ModuleOptionsCustom, ModuleSetupInstallResult, ModuleSetupReturn, NamespacesForPrefix, NitroBuildInfo, RequiredServiceType, ResolvedMiddlewareDefinition, ResolvedModuleMeta, ResolvedModuleOptions, ResolvedSchema, ResolvedSchemaDefinition, ResolvedServiceDefinition, ResolvedSilgiTemplate, RouteConfig, RouteConfigService, RouteRules, RouterParams, Routers, RoutesForPrefixAndNamespace, ScanFile, Schema, ServiceHandler, ServiceHandlerInput, ServiceHandlerOutput, ServiceHandlerSource, ServiceMethods, ServiceSetup, Silgi, SilgiAppPlugin, SilgiCLI, SilgiCLIConfig, SilgiCLIHooks, SilgiCLIOptions, SilgiCommands, SilgiCompatibility, SilgiCompatibilityIssue, SilgiCompatibilityIssues, SilgiConfig, SilgiEvent, SilgiFetchClient, SilgiFetchOptions, SilgiFrameworkInfo, SilgiHooks, SilgiMeta, SilgiModule, SilgiModuleInput, SilgiModuleOptions, SilgiOptions, SilgiPreset, SilgiPresetMeta, SilgiRoute, SilgiRouterTypes,
|
|
1232
|
+
export type { AllPaths, AllPrefixes, AppConfig, Awaitable, BuildSilgi, CaptureError, CapturedErrorContext, CommandType, Commands, CustomRequestInit, DeepPartial, DeepRequired, DefaultHooks, DefineFrameworkOptions, DotenvOptions, EnvOptions, EventHandlerResponse, ExtendContext, ExtendShared, ExtractNamespace, ExtractPathParamKeys, ExtractPathParams, ExtractPrefix, ExtractRoute, GenImport, GenerateAppOptions, HTTPMethod, HookResult, HttpMethod, LoadConfigOptions, MergeAll, MergedSilgiSchema, MethodSchemas, MiddlewareDefinition, MiddlewareHandler, MiddlewareRoute, MiddlewareSetup, ModuleDefinition, ModuleHookContext, ModuleMeta, ModuleOptionsCustom, ModuleSetupInstallResult, ModuleSetupReturn, NamespacesForPrefix, NitroBuildInfo, RequiredServiceType, ResolvedMiddlewareDefinition, ResolvedModuleMeta, ResolvedModuleOptions, ResolvedSchema, ResolvedSchemaDefinition, ResolvedServiceDefinition, ResolvedSilgiTemplate, RouteConfig, RouteConfigService, RouteRules, RouterParams, Routers, RoutesForPrefixAndNamespace, ScanFile, Schema, ServiceHandler, ServiceHandlerInput, ServiceHandlerOutput, ServiceHandlerSource, ServiceMethods, ServiceSetup, SetupModuleOption, Silgi, SilgiAppPlugin, SilgiCLI, SilgiCLIConfig, SilgiCLIHooks, SilgiCLIOptions, SilgiCommands, SilgiCompatibility, SilgiCompatibilityIssue, SilgiCompatibilityIssues, SilgiConfig, SilgiEvent, SilgiFetchClient, SilgiFetchOptions, SilgiFrameworkInfo, SilgiHooks, SilgiMeta, SilgiModule, SilgiModuleInput, SilgiModuleOptions, SilgiOptions, SilgiPreset, SilgiPresetMeta, SilgiRoute, SilgiRouterTypes, SilgiRuntimeConfig, SilgiRuntimeContext, SilgiRuntimeDefaultConfig, SilgiRuntimeHooks, SilgiRuntimeMethods, SilgiRuntimeOptions, SilgiRuntimeShareds, SilgiRuntimeSharedsExtend, SilgiSchema, SilgiStorageBase, SilgiTemplate, SilgiURL, StandardHTTPMethod, StorageConfig, StorageKeyGenerator, StorageKeyParams, StorageMounts, TSReference, TrimAfterFourSlashes, WithPathParams };
|