silgi 0.39.1 → 0.39.3
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 +6 -0
- package/dist/cli/index.mjs +1 -1
- package/dist/core/index.d.mts +3 -3
- package/dist/core/index.mjs +1 -0
- package/dist/types/index.d.mts +8 -5
- package/package.json +1 -1
package/dist/cli/build.mjs
CHANGED
|
@@ -1073,6 +1073,7 @@ async function readScanFile(silgi) {
|
|
|
1073
1073
|
silgi.schemas = scanFile.schemas || {};
|
|
1074
1074
|
silgi.services = scanFile.services || {};
|
|
1075
1075
|
silgi.shareds = scanFile.shareds || {};
|
|
1076
|
+
silgi.routers = scanFile.routers || {};
|
|
1076
1077
|
return {
|
|
1077
1078
|
context,
|
|
1078
1079
|
object: {
|
|
@@ -1451,6 +1452,7 @@ async function createSilgiCLI(config = {}, opts = {}) {
|
|
|
1451
1452
|
middleware: [],
|
|
1452
1453
|
shareds: {},
|
|
1453
1454
|
schemas: {},
|
|
1455
|
+
routers: {},
|
|
1454
1456
|
unimport: void 0,
|
|
1455
1457
|
options,
|
|
1456
1458
|
hooks,
|
|
@@ -1706,6 +1708,9 @@ async function prepareCoreFile(silgi) {
|
|
|
1706
1708
|
},
|
|
1707
1709
|
{
|
|
1708
1710
|
name: "middlewares"
|
|
1711
|
+
},
|
|
1712
|
+
{
|
|
1713
|
+
name: "routers"
|
|
1709
1714
|
}
|
|
1710
1715
|
]
|
|
1711
1716
|
},
|
|
@@ -1797,6 +1802,7 @@ async function prepareCoreFile(silgi) {
|
|
|
1797
1802
|
" services: services,",
|
|
1798
1803
|
" middlewares: middlewares,",
|
|
1799
1804
|
" schemas: schemas,",
|
|
1805
|
+
" routers: routers,",
|
|
1800
1806
|
` plugins: [${plugins.join(", ")}],`,
|
|
1801
1807
|
"",
|
|
1802
1808
|
_data.silgiConfigs.length > 0 ? _data.silgiConfigs.map((item) => {
|
package/dist/cli/index.mjs
CHANGED
package/dist/core/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SilgiConfig, Silgi, SilgiEvent, SilgiSchema, RouteEntry, CustomRequestInit, SilgiRuntimeContext, Routers, HTTPMethod, HasPathParams, BaseMethodSchema, WithPathParams, MergeAll, MiddlewareDefinition, HttpMethod, ServiceSetup, SilgiRuntimeShareds,
|
|
1
|
+
import { SilgiConfig, Silgi, SilgiEvent, SilgiSchema, RouteEntry, CustomRequestInit, SilgiRuntimeContext, Routers, HTTPMethod, HasPathParams, BaseMethodSchema, WithPathParams, MergeAll, MiddlewareDefinition, HttpMethod, ServiceSetup, SilgiRuntimeShareds, RouterConfig, SilgiURL, StorageConfig, SilgiCLI, SilgiStorageBase, SilgiRuntimeConfig } from 'silgi/types';
|
|
2
2
|
import { Storage, StorageValue } from 'unstorage';
|
|
3
3
|
import { UseContext } from 'unctx';
|
|
4
4
|
|
|
@@ -206,8 +206,8 @@ declare function createShared(shared: Partial<SilgiRuntimeShareds>): SilgiRuntim
|
|
|
206
206
|
*/
|
|
207
207
|
declare function replaceRuntimeValues(obj: any, runtime: any): any;
|
|
208
208
|
|
|
209
|
-
declare function createRoute<URL extends string>(params:
|
|
210
|
-
[K in URL]:
|
|
209
|
+
declare function createRoute<URL extends string>(params: RouterConfig<URL>): {
|
|
210
|
+
[K in URL]: RouterConfig<URL>;
|
|
211
211
|
};
|
|
212
212
|
declare function getUrlPrefix(path: string, method?: string): SilgiURL;
|
|
213
213
|
|
package/dist/core/index.mjs
CHANGED
|
@@ -270,6 +270,7 @@ async function createSilgi(config) {
|
|
|
270
270
|
routerPrefixs: [],
|
|
271
271
|
schemas: config.schemas ?? {},
|
|
272
272
|
services: config.services ?? {},
|
|
273
|
+
routers: config.routers ?? {},
|
|
273
274
|
middlewares: config.middlewares ?? {},
|
|
274
275
|
globalMiddlewares: config.globalMiddlewares ?? [],
|
|
275
276
|
shared: config.shared ?? {},
|
package/dist/types/index.d.mts
CHANGED
|
@@ -184,12 +184,12 @@ type ExtractPathParamKeys<S extends string> = S extends `${string}:${infer Param
|
|
|
184
184
|
/**
|
|
185
185
|
* Route configuration interface.
|
|
186
186
|
*/
|
|
187
|
-
interface
|
|
187
|
+
interface RouterConfig<T extends string = string> {
|
|
188
188
|
route: T;
|
|
189
189
|
setup?: any;
|
|
190
190
|
readBeforeBody?: boolean;
|
|
191
191
|
}
|
|
192
|
-
type
|
|
192
|
+
type RouterConfigService<T extends string = string> = Omit<RouterConfig<T>, 'route' | 'setup'>;
|
|
193
193
|
|
|
194
194
|
interface SilgiSchema {
|
|
195
195
|
}
|
|
@@ -364,7 +364,7 @@ type ServiceHandler<Schema extends SilgiSchema, Route extends keyof Schema, Reso
|
|
|
364
364
|
*/
|
|
365
365
|
interface ServiceSetup<Schema extends SilgiSchema = SilgiSchema, Route extends keyof Schema = keyof Schema, Resolved extends boolean = false, HiddenParameters extends boolean = false> {
|
|
366
366
|
handler: ServiceHandler<Schema, Route, Resolved, HiddenParameters>;
|
|
367
|
-
rules?:
|
|
367
|
+
rules?: RouterConfigService;
|
|
368
368
|
modules?: Partial<SetupModuleOption>;
|
|
369
369
|
storage?: StorageConfig<ServiceHandlerInput<Schema, Route, HiddenParameters>>;
|
|
370
370
|
}
|
|
@@ -380,7 +380,8 @@ interface ServiceSetup<Schema extends SilgiSchema = SilgiSchema, Route extends k
|
|
|
380
380
|
interface ResolvedServiceDefinition {
|
|
381
381
|
[methodAndRoutePath: string]: {
|
|
382
382
|
handler: (...args: any[]) => Promise<any>;
|
|
383
|
-
|
|
383
|
+
storage?: StorageConfig<any>;
|
|
384
|
+
} & Omit<ServiceSetup, 'handler' | 'storage'>;
|
|
384
385
|
}
|
|
385
386
|
/**
|
|
386
387
|
* SilgiURL tipi
|
|
@@ -424,6 +425,7 @@ interface SilgiCLI {
|
|
|
424
425
|
services: ResolvedServiceDefinition;
|
|
425
426
|
middleware: SilgiRoute[];
|
|
426
427
|
shareds: SilgiRuntimeShareds;
|
|
428
|
+
routers: Record<string, RouterConfig>;
|
|
427
429
|
schemas: Record<string, any>;
|
|
428
430
|
scannedURIs: Map<string, string>;
|
|
429
431
|
templates: SilgiTemplate[];
|
|
@@ -715,6 +717,7 @@ interface Silgi {
|
|
|
715
717
|
globalMiddlewares: SilgiRoute[];
|
|
716
718
|
routerPrefixs: string[];
|
|
717
719
|
schemas: ResolvedSchemaDefinition;
|
|
720
|
+
routers: Record<string, RouterConfig>;
|
|
718
721
|
services: ResolvedServiceDefinition;
|
|
719
722
|
shared: SilgiRuntimeShareds;
|
|
720
723
|
plugins: SilgiAppPlugin[];
|
|
@@ -1225,4 +1228,4 @@ interface LoadConfigOptions {
|
|
|
1225
1228
|
consola?: ConsolaInstance;
|
|
1226
1229
|
}
|
|
1227
1230
|
|
|
1228
|
-
export type { AllPaths, AllPrefixes, AppConfig, Awaitable, BaseMethodSchema, BuildSilgi, CaptureError, CapturedErrorContext, CommandType, Commands, CustomRequestInit, DeepPartial, DeepRequired, DefaultHooks, DefineFrameworkOptions, DotenvOptions, EnvOptions, EventHandlerResponse, ExtendContext, ExtendShared, ExtractNamespace, ExtractPathParamKeys, ExtractPathParams, ExtractPrefix, ExtractRoute, GenImport, GenerateAppOptions, HTTPMethod, HasPathParams, HookResult, HttpMethod, LoadConfigOptions, MergeAll, MergedSilgiSchema, MetaData, MethodSchemas, MiddlewareDefinition, MiddlewareHandler, MiddlewareSetup, ModuleDefinition, ModuleHookContext, ModuleMeta, ModuleOptionsCustom, ModuleSetupInstallResult, ModuleSetupReturn, NamespacesForPrefix, NitroBuildInfo, RequiredServiceType, ResolvedMiddlewareDefinition, ResolvedModuleMeta, ResolvedModuleOptions, ResolvedSchema, ResolvedSchemaDefinition, ResolvedServiceDefinition, ResolvedSilgiTemplate,
|
|
1231
|
+
export type { AllPaths, AllPrefixes, AppConfig, Awaitable, BaseMethodSchema, BuildSilgi, CaptureError, CapturedErrorContext, CommandType, Commands, CustomRequestInit, DeepPartial, DeepRequired, DefaultHooks, DefineFrameworkOptions, DotenvOptions, EnvOptions, EventHandlerResponse, ExtendContext, ExtendShared, ExtractNamespace, ExtractPathParamKeys, ExtractPathParams, ExtractPrefix, ExtractRoute, GenImport, GenerateAppOptions, HTTPMethod, HasPathParams, HookResult, HttpMethod, LoadConfigOptions, MergeAll, MergedSilgiSchema, MetaData, MethodSchemas, MiddlewareDefinition, MiddlewareHandler, MiddlewareSetup, ModuleDefinition, ModuleHookContext, ModuleMeta, ModuleOptionsCustom, ModuleSetupInstallResult, ModuleSetupReturn, NamespacesForPrefix, NitroBuildInfo, RequiredServiceType, ResolvedMiddlewareDefinition, ResolvedModuleMeta, ResolvedModuleOptions, ResolvedSchema, ResolvedSchemaDefinition, ResolvedServiceDefinition, ResolvedSilgiTemplate, RouteEntry, RouteRules, RouterConfig, RouterConfigService, RouterParams, Routers, RoutesForPrefixAndNamespace, ScanFile, Schema, ServiceHandler, ServiceHandlerInput, ServiceHandlerOutput, ServiceHandlerSource, ServiceSetup, SetupModuleOption, Silgi, SilgiAppPlugin, SilgiCLI, SilgiCLIConfig, SilgiCLIHooks, SilgiCLIOptions, SilgiCommands, SilgiCompatibility, SilgiCompatibilityIssue, SilgiCompatibilityIssues, SilgiConfig, SilgiEvent, SilgiFetchClient, SilgiFetchOptions, SilgiFrameworkInfo, SilgiHooks, 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 };
|