@niledatabase/server 5.0.0-alpha.22 → 5.0.0-alpha.24
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/index.d.mts +10 -6
- package/dist/index.d.ts +10 -6
- package/dist/index.js +8 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +8 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -540,10 +540,8 @@ declare class Server {
|
|
|
540
540
|
/**
|
|
541
541
|
* A convenience function that applies a config and ensures whatever was passed is set properly
|
|
542
542
|
*/
|
|
543
|
-
getInstance<T = Request | Headers | Record<string, string>>(config: NileConfig, req?: T):
|
|
544
|
-
get handlers():
|
|
545
|
-
withContext: CTXHandlerType;
|
|
546
|
-
};
|
|
543
|
+
getInstance<T = Request | Headers | Record<string, string>>(config: NileConfig, req?: T): this;
|
|
544
|
+
get handlers(): NileHandlers;
|
|
547
545
|
get paths(): ConfigurablePaths;
|
|
548
546
|
set paths(paths: ConfigurablePaths);
|
|
549
547
|
/**
|
|
@@ -559,7 +557,7 @@ declare class Server {
|
|
|
559
557
|
}, ...remaining: unknown[]) => void;
|
|
560
558
|
getContext(): any;
|
|
561
559
|
}
|
|
562
|
-
declare function create(config?: NileConfig):
|
|
560
|
+
declare function create<T = Server>(config?: NileConfig): T;
|
|
563
561
|
|
|
564
562
|
type Opts = {
|
|
565
563
|
basePath?: string;
|
|
@@ -574,6 +572,12 @@ type ExtensionResult = {
|
|
|
574
572
|
onConfigure?: (...params: Any) => void;
|
|
575
573
|
onSetContext?: (...params: Any) => void;
|
|
576
574
|
onGetContext?: () => Any;
|
|
575
|
+
replace?: {
|
|
576
|
+
handlers: (handlers: NileHandlers) => Any;
|
|
577
|
+
};
|
|
578
|
+
};
|
|
579
|
+
type NileHandlers = RouteFunctions & {
|
|
580
|
+
withContext: CTXHandlerType;
|
|
577
581
|
};
|
|
578
582
|
type Extension = (instance: Server) => ExtensionResult;
|
|
579
583
|
declare enum ExtensionState {
|
|
@@ -798,4 +802,4 @@ declare const USER_COOKIE = "nile.user-id";
|
|
|
798
802
|
declare const HEADER_ORIGIN = "nile-origin";
|
|
799
803
|
declare const HEADER_SECURE_COOKIES = "nile-secure-cookies";
|
|
800
804
|
|
|
801
|
-
export { type APIError, APIErrorErrorCodeEnum, type ActiveSession, type AfterCreate, type CTXHandlerType, type ContextReturn, type CreateBasicUserRequest, type CreateTenantUserRequest, type Extension, type ExtensionResult, ExtensionState, HEADER_ORIGIN, HEADER_SECURE_COOKIES, type Invite, type JWT, type LoggerType, type LoginUserResponse, type LoginUserResponseToken, LoginUserResponseTokenTypeEnum, create as Nile, type NileConfig, type NileDb, type NilePoolConfig, type NileRequest, type NileResponse, type Opts, type Providers, type RouteFunctions, type RouteReturn, Server, TENANT_COOKIE, type Tenant, USER_COOKIE, type User, parseCSRF, parseCallback, parseResetToken, parseToken };
|
|
805
|
+
export { type APIError, APIErrorErrorCodeEnum, type ActiveSession, type AfterCreate, type CTXHandlerType, type ContextReturn, type CreateBasicUserRequest, type CreateTenantUserRequest, type Extension, type ExtensionResult, ExtensionState, HEADER_ORIGIN, HEADER_SECURE_COOKIES, type Invite, type JWT, type LoggerType, type LoginUserResponse, type LoginUserResponseToken, LoginUserResponseTokenTypeEnum, create as Nile, type NileConfig, type NileDb, type NileHandlers, type NilePoolConfig, type NileRequest, type NileResponse, type Opts, type Providers, type RouteFunctions, type RouteReturn, Server, TENANT_COOKIE, type Tenant, USER_COOKIE, type User, parseCSRF, parseCallback, parseResetToken, parseToken };
|
package/dist/index.d.ts
CHANGED
|
@@ -540,10 +540,8 @@ declare class Server {
|
|
|
540
540
|
/**
|
|
541
541
|
* A convenience function that applies a config and ensures whatever was passed is set properly
|
|
542
542
|
*/
|
|
543
|
-
getInstance<T = Request | Headers | Record<string, string>>(config: NileConfig, req?: T):
|
|
544
|
-
get handlers():
|
|
545
|
-
withContext: CTXHandlerType;
|
|
546
|
-
};
|
|
543
|
+
getInstance<T = Request | Headers | Record<string, string>>(config: NileConfig, req?: T): this;
|
|
544
|
+
get handlers(): NileHandlers;
|
|
547
545
|
get paths(): ConfigurablePaths;
|
|
548
546
|
set paths(paths: ConfigurablePaths);
|
|
549
547
|
/**
|
|
@@ -559,7 +557,7 @@ declare class Server {
|
|
|
559
557
|
}, ...remaining: unknown[]) => void;
|
|
560
558
|
getContext(): any;
|
|
561
559
|
}
|
|
562
|
-
declare function create(config?: NileConfig):
|
|
560
|
+
declare function create<T = Server>(config?: NileConfig): T;
|
|
563
561
|
|
|
564
562
|
type Opts = {
|
|
565
563
|
basePath?: string;
|
|
@@ -574,6 +572,12 @@ type ExtensionResult = {
|
|
|
574
572
|
onConfigure?: (...params: Any) => void;
|
|
575
573
|
onSetContext?: (...params: Any) => void;
|
|
576
574
|
onGetContext?: () => Any;
|
|
575
|
+
replace?: {
|
|
576
|
+
handlers: (handlers: NileHandlers) => Any;
|
|
577
|
+
};
|
|
578
|
+
};
|
|
579
|
+
type NileHandlers = RouteFunctions & {
|
|
580
|
+
withContext: CTXHandlerType;
|
|
577
581
|
};
|
|
578
582
|
type Extension = (instance: Server) => ExtensionResult;
|
|
579
583
|
declare enum ExtensionState {
|
|
@@ -798,4 +802,4 @@ declare const USER_COOKIE = "nile.user-id";
|
|
|
798
802
|
declare const HEADER_ORIGIN = "nile-origin";
|
|
799
803
|
declare const HEADER_SECURE_COOKIES = "nile-secure-cookies";
|
|
800
804
|
|
|
801
|
-
export { type APIError, APIErrorErrorCodeEnum, type ActiveSession, type AfterCreate, type CTXHandlerType, type ContextReturn, type CreateBasicUserRequest, type CreateTenantUserRequest, type Extension, type ExtensionResult, ExtensionState, HEADER_ORIGIN, HEADER_SECURE_COOKIES, type Invite, type JWT, type LoggerType, type LoginUserResponse, type LoginUserResponseToken, LoginUserResponseTokenTypeEnum, create as Nile, type NileConfig, type NileDb, type NilePoolConfig, type NileRequest, type NileResponse, type Opts, type Providers, type RouteFunctions, type RouteReturn, Server, TENANT_COOKIE, type Tenant, USER_COOKIE, type User, parseCSRF, parseCallback, parseResetToken, parseToken };
|
|
805
|
+
export { type APIError, APIErrorErrorCodeEnum, type ActiveSession, type AfterCreate, type CTXHandlerType, type ContextReturn, type CreateBasicUserRequest, type CreateTenantUserRequest, type Extension, type ExtensionResult, ExtensionState, HEADER_ORIGIN, HEADER_SECURE_COOKIES, type Invite, type JWT, type LoggerType, type LoginUserResponse, type LoginUserResponseToken, LoginUserResponseTokenTypeEnum, create as Nile, type NileConfig, type NileDb, type NileHandlers, type NilePoolConfig, type NileRequest, type NileResponse, type Opts, type Providers, type RouteFunctions, type RouteReturn, Server, TENANT_COOKIE, type Tenant, USER_COOKIE, type User, parseCSRF, parseCallback, parseResetToken, parseToken };
|
package/dist/index.js
CHANGED
|
@@ -1147,7 +1147,7 @@ var baseLogger = (config, ...params) => ({
|
|
|
1147
1147
|
},
|
|
1148
1148
|
debug(message, meta) {
|
|
1149
1149
|
if (config?.debug) {
|
|
1150
|
-
console.
|
|
1150
|
+
console.info(
|
|
1151
1151
|
`${orange}[niledb]${reset}${purple}[DEBUG]${reset}${params.join(
|
|
1152
1152
|
""
|
|
1153
1153
|
)}${reset} ${message}`,
|
|
@@ -3168,6 +3168,13 @@ var Server = class {
|
|
|
3168
3168
|
if (ext.onConfigure) {
|
|
3169
3169
|
ext.onConfigure();
|
|
3170
3170
|
}
|
|
3171
|
+
if (ext?.replace?.handlers) {
|
|
3172
|
+
this.#config.logger("[EXTENSION]").debug(`${ext.id} replacing handlers`);
|
|
3173
|
+
this.#handlers = ext.replace.handlers({
|
|
3174
|
+
...this.#config.handlers,
|
|
3175
|
+
withContext: handlersWithContext(this.#config)
|
|
3176
|
+
});
|
|
3177
|
+
}
|
|
3171
3178
|
}
|
|
3172
3179
|
}
|
|
3173
3180
|
}
|