@niledatabase/server 5.2.0-alpha.0 → 5.2.0

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 CHANGED
@@ -602,7 +602,7 @@ type ExtensionResult<TParams> = {
602
602
  onRequest?: (params: TParams, ctx: CTX) => void | Promise<void | RequestInit>;
603
603
  onResponse?: (params: TParams, ctx: CTX) => void | Promise<void>;
604
604
  onHandleRequest?: (params?: TParams) => RouteReturn | Promise<RouteReturn>;
605
- onConfigure?: (params?: TParams) => void;
605
+ onConfigure?: (instance: Server) => void;
606
606
  withUserId?: () => string;
607
607
  withTenantId?: () => string;
608
608
  replace?: {
@@ -612,7 +612,7 @@ type ExtensionResult<TParams> = {
612
612
  type NileHandlers = RouteFunctions & {
613
613
  withContext: CTXHandlerType;
614
614
  };
615
- type Extension<TParams = Any> = (instance: Server) => ExtensionResult<TParams>;
615
+ type Extension<TParams = Any> = (params?: TParams) => ExtensionResult<TParams>;
616
616
  declare enum ExtensionState {
617
617
  onHandleRequest = "onHandleRequest",
618
618
  onRequest = "onRequest",
package/dist/index.d.ts CHANGED
@@ -602,7 +602,7 @@ type ExtensionResult<TParams> = {
602
602
  onRequest?: (params: TParams, ctx: CTX) => void | Promise<void | RequestInit>;
603
603
  onResponse?: (params: TParams, ctx: CTX) => void | Promise<void>;
604
604
  onHandleRequest?: (params?: TParams) => RouteReturn | Promise<RouteReturn>;
605
- onConfigure?: (params?: TParams) => void;
605
+ onConfigure?: (instance: Server) => void;
606
606
  withUserId?: () => string;
607
607
  withTenantId?: () => string;
608
608
  replace?: {
@@ -612,7 +612,7 @@ type ExtensionResult<TParams> = {
612
612
  type NileHandlers = RouteFunctions & {
613
613
  withContext: CTXHandlerType;
614
614
  };
615
- type Extension<TParams = Any> = (instance: Server) => ExtensionResult<TParams>;
615
+ type Extension<TParams = Any> = (params?: TParams) => ExtensionResult<TParams>;
616
616
  declare enum ExtensionState {
617
617
  onHandleRequest = "onHandleRequest",
618
618
  onRequest = "onRequest",
package/dist/index.js CHANGED
@@ -3667,9 +3667,10 @@ var Server = class {
3667
3667
  if (typeof create2 !== "function") {
3668
3668
  continue;
3669
3669
  }
3670
- const ext = create2(this);
3671
- if (ext.onConfigure) {
3672
- ext.onConfigure();
3670
+ const ext = create2();
3671
+ if (typeof ext.onConfigure === "function") {
3672
+ this.#config.logger("[EXTENSION]").debug(`configuring for ${ext.id}`);
3673
+ ext.onConfigure(this);
3673
3674
  }
3674
3675
  if (ext?.replace?.handlers) {
3675
3676
  this.#config.logger("[EXTENSION]").debug(`${ext.id} replacing handlers`);
@@ -3709,7 +3710,7 @@ var Server = class {
3709
3710
  return {
3710
3711
  remove: async (id) => {
3711
3712
  if (!this.#config.extensions) return;
3712
- const resolved = this.#config.extensions.map((ext) => ext(this));
3713
+ const resolved = this.#config.extensions.map((ext) => ext());
3713
3714
  const index = resolved.findIndex((ext) => ext.id === id);
3714
3715
  if (index !== -1) {
3715
3716
  this.#config.extensions.splice(index, 1);