@niledatabase/server 5.0.0-alpha.13 → 5.0.0-alpha.14

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
@@ -607,92 +607,93 @@ type LoggerType = {
607
607
  error: (args: unknown | unknown[]) => void;
608
608
  debug: (args: unknown | unknown[]) => void;
609
609
  };
610
+ /**
611
+ * Configuration options used by the {@link Server} class.
612
+ * Most values can be provided via environment variables if not set here.
613
+ */
610
614
  type NileConfig = {
611
615
  /**
612
- * The specific database id. Either passed in or figured out by NILEDB_API_URL
613
- * process.env.NILEDB_ID
616
+ * Unique ID of the database.
617
+ * If omitted, the value is derived from `NILEDB_API_URL`.
618
+ * Environment variable: `NILEDB_ID`.
614
619
  */
615
620
  databaseId?: string;
616
621
  /**
617
- * The user UUID to the database
618
- * process.env.NILEDB_USER
622
+ * Database user used for authentication.
623
+ * Environment variable: `NILEDB_USER`.
619
624
  */
620
625
  user?: string;
621
626
  /**
622
- * The password UUID to the database
623
- * process.env.NILEDB_PASSWORD
627
+ * Password for the configured user.
628
+ * Environment variable: `NILEDB_PASSWORD`.
624
629
  */
625
630
  password?: string;
626
631
  /**
627
- * The name of the database. Automatically obtained from NILEDB_POSTGRES_URL
628
- * process.env.NILEDB_NAME
632
+ * Database name. Defaults to the name parsed from
633
+ * `NILEDB_POSTGRES_URL` when not provided.
634
+ * Environment variable: `NILEDB_NAME`.
629
635
  */
630
636
  databaseName?: string;
631
637
  /**
632
- * A tenant id. Scopes requests to a specific tenant, both API and DB
633
- * process.env.NILEDB_TENANT
638
+ * Tenant context used for scoping API and DB calls.
639
+ * Environment variable: `NILEDB_TENANT`.
634
640
  */
635
641
  tenantId?: string | null | undefined;
636
642
  /**
637
- * A user id. Possibly not the logged in user, used for setting database context (nile.user_id)
638
- * Generally speaking, this wouldn't be used for authentication, and in some cases simply won't do anything on some endpoints
643
+ * Optional user identifier to apply when interacting with the database.
644
+ * In most cases nile-auth injects the logged in user automatically so this
645
+ * value rarely needs to be specified directly. It can be useful when
646
+ * performing administrative actions on behalf of another user.
639
647
  */
640
648
  userId?: string | null | undefined;
641
- /**
642
- * Shows a bunch of logging on the server side to see what's being done between the sdk and nile-auth
643
- */
649
+ /** Enable verbose logging of SDK behaviour. */
644
650
  debug?: boolean;
645
651
  /**
646
- * DB configuration overrides. Environment variables are the way to go, but maybe you need something more
652
+ * Optional Postgres connection configuration.
653
+ * Environment variables will be used for any values not set here.
647
654
  */
648
655
  db?: NilePoolConfig;
649
- /**
650
- * Some kind of logger if you want to send to an external service
651
- */
656
+ /** Custom logger implementation. */
652
657
  logger?: LogReturn;
653
658
  /**
654
- * The configuration value that maps to `NILEDB_API_URL` - its going to be nile-auth (or similar service)
659
+ * Base URL for nile-auth requests.
660
+ * Environment variable: `NILEDB_API_URL`.
655
661
  */
656
662
  apiUrl?: string | undefined;
657
663
  /**
658
- * Ignore client callbackUrls by setting this.
659
- * You can force the callback URL server side to be sure nile-auth redirects to whatever location.
664
+ * Override the client provided callback URL during authentication.
665
+ * Environment variable: `NILEDB_CALLBACK_URL`.
660
666
  */
661
667
  callbackUrl?: string | undefined;
662
- /**
663
- * Need to override some routes? Change it here
664
- */
668
+ /** Override default API routes. */
665
669
  routes?: Partial<Routes>;
666
- /**
667
- * don't like the default `/api`? change it here
668
- */
670
+ /** Prefix applied to all generated routes. */
669
671
  routePrefix?: string | undefined;
670
672
  /**
671
- * In some cases, you may want to force secure cookies.
672
- * The SDK handles this for you, but might be necessary in some firewall / internal cases
673
- * Defaults to true if you're in production
673
+ * Force usage of secure cookies when communicating with nile-auth.
674
+ * Defaults to `true` when `NODE_ENV` is `production`.
675
+ * Environment variable: `NILEDB_SECURECOOKIES`.
674
676
  */
675
677
  secureCookies?: boolean;
676
678
  /**
677
- * The origin for the requests.
678
- * Allows the setting of the callback origin to a random FE
679
- * eg FE localhost:3001 -> BE: localhost:5432 would set to localhost:3001 to be sure nile-auth uses that.
680
- * In full stack cases, will just be the `host` header of the incoming request, which is used by default
681
- * It is also important to set this when dealing with secure cookies. Calling via server side needs to know if TLS is being used so that nile-auth knows which cookies to be sent.
679
+ * Origin for requests made to nile-auth. This controls where users are
680
+ * redirected after authentication. For single-page apps running on a
681
+ * different port than the API, set this to the front-end origin
682
+ * (e.g. `http://localhost:3001`). In a full-stack setup the value defaults
683
+ * to the `host` header of the incoming request. When using secure cookies on
684
+ * server-to-server calls, explicitly setting the origin ensures nile-auth
685
+ * knows whether TLS is being used and which cookies to send.
682
686
  */
683
687
  origin?: null | undefined | string;
684
688
  /**
685
- * Set the headers to use in API requests.
686
- * The `cookie` would be expected if you are setting this, else most calls will be unauthorized
689
+ * Additional headers sent with every API request.
690
+ * Include a `cookie` header to forward session information.
687
691
  */
688
692
  headers?: null | Headers | Record<string, string>;
689
- /**
690
- * Functions to run at various points to make life easier
691
- */
693
+ /** Hooks executed before and after each request. */
692
694
  extensions?: Extension[];
693
695
  /**
694
- * In some cases, like when using REST context, we want to preserve the headers from the request,
695
- * regardless of what an extension might do
696
+ * Preserve incoming request headers when running extensions.
696
697
  */
697
698
  preserveHeaders?: boolean;
698
699
  };
package/dist/index.d.ts CHANGED
@@ -607,92 +607,93 @@ type LoggerType = {
607
607
  error: (args: unknown | unknown[]) => void;
608
608
  debug: (args: unknown | unknown[]) => void;
609
609
  };
610
+ /**
611
+ * Configuration options used by the {@link Server} class.
612
+ * Most values can be provided via environment variables if not set here.
613
+ */
610
614
  type NileConfig = {
611
615
  /**
612
- * The specific database id. Either passed in or figured out by NILEDB_API_URL
613
- * process.env.NILEDB_ID
616
+ * Unique ID of the database.
617
+ * If omitted, the value is derived from `NILEDB_API_URL`.
618
+ * Environment variable: `NILEDB_ID`.
614
619
  */
615
620
  databaseId?: string;
616
621
  /**
617
- * The user UUID to the database
618
- * process.env.NILEDB_USER
622
+ * Database user used for authentication.
623
+ * Environment variable: `NILEDB_USER`.
619
624
  */
620
625
  user?: string;
621
626
  /**
622
- * The password UUID to the database
623
- * process.env.NILEDB_PASSWORD
627
+ * Password for the configured user.
628
+ * Environment variable: `NILEDB_PASSWORD`.
624
629
  */
625
630
  password?: string;
626
631
  /**
627
- * The name of the database. Automatically obtained from NILEDB_POSTGRES_URL
628
- * process.env.NILEDB_NAME
632
+ * Database name. Defaults to the name parsed from
633
+ * `NILEDB_POSTGRES_URL` when not provided.
634
+ * Environment variable: `NILEDB_NAME`.
629
635
  */
630
636
  databaseName?: string;
631
637
  /**
632
- * A tenant id. Scopes requests to a specific tenant, both API and DB
633
- * process.env.NILEDB_TENANT
638
+ * Tenant context used for scoping API and DB calls.
639
+ * Environment variable: `NILEDB_TENANT`.
634
640
  */
635
641
  tenantId?: string | null | undefined;
636
642
  /**
637
- * A user id. Possibly not the logged in user, used for setting database context (nile.user_id)
638
- * Generally speaking, this wouldn't be used for authentication, and in some cases simply won't do anything on some endpoints
643
+ * Optional user identifier to apply when interacting with the database.
644
+ * In most cases nile-auth injects the logged in user automatically so this
645
+ * value rarely needs to be specified directly. It can be useful when
646
+ * performing administrative actions on behalf of another user.
639
647
  */
640
648
  userId?: string | null | undefined;
641
- /**
642
- * Shows a bunch of logging on the server side to see what's being done between the sdk and nile-auth
643
- */
649
+ /** Enable verbose logging of SDK behaviour. */
644
650
  debug?: boolean;
645
651
  /**
646
- * DB configuration overrides. Environment variables are the way to go, but maybe you need something more
652
+ * Optional Postgres connection configuration.
653
+ * Environment variables will be used for any values not set here.
647
654
  */
648
655
  db?: NilePoolConfig;
649
- /**
650
- * Some kind of logger if you want to send to an external service
651
- */
656
+ /** Custom logger implementation. */
652
657
  logger?: LogReturn;
653
658
  /**
654
- * The configuration value that maps to `NILEDB_API_URL` - its going to be nile-auth (or similar service)
659
+ * Base URL for nile-auth requests.
660
+ * Environment variable: `NILEDB_API_URL`.
655
661
  */
656
662
  apiUrl?: string | undefined;
657
663
  /**
658
- * Ignore client callbackUrls by setting this.
659
- * You can force the callback URL server side to be sure nile-auth redirects to whatever location.
664
+ * Override the client provided callback URL during authentication.
665
+ * Environment variable: `NILEDB_CALLBACK_URL`.
660
666
  */
661
667
  callbackUrl?: string | undefined;
662
- /**
663
- * Need to override some routes? Change it here
664
- */
668
+ /** Override default API routes. */
665
669
  routes?: Partial<Routes>;
666
- /**
667
- * don't like the default `/api`? change it here
668
- */
670
+ /** Prefix applied to all generated routes. */
669
671
  routePrefix?: string | undefined;
670
672
  /**
671
- * In some cases, you may want to force secure cookies.
672
- * The SDK handles this for you, but might be necessary in some firewall / internal cases
673
- * Defaults to true if you're in production
673
+ * Force usage of secure cookies when communicating with nile-auth.
674
+ * Defaults to `true` when `NODE_ENV` is `production`.
675
+ * Environment variable: `NILEDB_SECURECOOKIES`.
674
676
  */
675
677
  secureCookies?: boolean;
676
678
  /**
677
- * The origin for the requests.
678
- * Allows the setting of the callback origin to a random FE
679
- * eg FE localhost:3001 -> BE: localhost:5432 would set to localhost:3001 to be sure nile-auth uses that.
680
- * In full stack cases, will just be the `host` header of the incoming request, which is used by default
681
- * It is also important to set this when dealing with secure cookies. Calling via server side needs to know if TLS is being used so that nile-auth knows which cookies to be sent.
679
+ * Origin for requests made to nile-auth. This controls where users are
680
+ * redirected after authentication. For single-page apps running on a
681
+ * different port than the API, set this to the front-end origin
682
+ * (e.g. `http://localhost:3001`). In a full-stack setup the value defaults
683
+ * to the `host` header of the incoming request. When using secure cookies on
684
+ * server-to-server calls, explicitly setting the origin ensures nile-auth
685
+ * knows whether TLS is being used and which cookies to send.
682
686
  */
683
687
  origin?: null | undefined | string;
684
688
  /**
685
- * Set the headers to use in API requests.
686
- * The `cookie` would be expected if you are setting this, else most calls will be unauthorized
689
+ * Additional headers sent with every API request.
690
+ * Include a `cookie` header to forward session information.
687
691
  */
688
692
  headers?: null | Headers | Record<string, string>;
689
- /**
690
- * Functions to run at various points to make life easier
691
- */
693
+ /** Hooks executed before and after each request. */
692
694
  extensions?: Extension[];
693
695
  /**
694
- * In some cases, like when using REST context, we want to preserve the headers from the request,
695
- * regardless of what an extension might do
696
+ * Preserve incoming request headers when running extensions.
696
697
  */
697
698
  preserveHeaders?: boolean;
698
699
  };