@rpcbase/api 0.33.0 → 0.35.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.
@@ -1,4 +1,4 @@
1
- import { i as isValidNumber, a as isEmail } from "./isValidNumber-R0qDZ-qD.js";
1
+ import { i as isValidNumber, a as isEmail } from "./isValidNumber-D_h4CKEH.js";
2
2
  import { o as object, b as boolean, s as string } from "./schemas-DKK0lkQz.js";
3
3
  const Route = "/api/rb/auth/sign-in";
4
4
  const requestSchema = object({
@@ -1,5 +1,5 @@
1
1
  import require$$0 from "crypto";
2
- import { i as isValidNumber, a as isEmail } from "./isValidNumber-R0qDZ-qD.js";
2
+ import { i as isValidNumber, a as isEmail } from "./isValidNumber-D_h4CKEH.js";
3
3
  import { loadModel } from "@rpcbase/api";
4
4
  import { hashPassword } from "@rpcbase/server";
5
5
  import { o as object, s as string, b as boolean } from "./schemas-DKK0lkQz.js";
@@ -33042,7 +33042,7 @@ process.env = {
33042
33042
  ...__rb_env__,
33043
33043
  ...process.env
33044
33044
  };
33045
- const initApi = async (app) => {
33045
+ const initApi = async (app, opts) => {
33046
33046
  await initApiClient({ app });
33047
33047
  const registerHandler = (method, path, handler) => {
33048
33048
  assert(path.startsWith("/api"), "API routes must start with /api");
@@ -33071,15 +33071,17 @@ const initApi = async (app) => {
33071
33071
  app.use("/api", function __FIRST_API_MIDDLEWARE__(_req, _res, next) {
33072
33072
  next();
33073
33073
  });
33074
- const routes = {
33075
- // @ts-expect-error: Property 'glob' does not exist on type 'ImportMeta'.
33076
- .../* @__PURE__ */ Object.assign({ "../../auth/src/api/sign-in/handler.ts": () => import("./handler-D7eudoVU.js"), "../../auth/src/api/sign-out/handler.ts": () => import("./handler-rzI-pkuD.js"), "../../auth/src/api/sign-up/handler.ts": () => import("./handler-v8WUNWbe.js") }),
33077
- // @ts-expect-error: Property 'glob' does not exist on type 'ImportMeta'.
33074
+ const routes = opts?.routes ?? {
33075
+ .../* @__PURE__ */ Object.assign({ "../../auth/src/api/sign-in/handler.ts": () => import("./handler-BgIfr0Vh.js"), "../../auth/src/api/sign-out/handler.ts": () => import("./handler-rzI-pkuD.js"), "../../auth/src/api/sign-up/handler.ts": () => import("./handler-D-HYO2Rb.js") }),
33078
33076
  .../* @__PURE__ */ Object.assign({})
33079
33077
  };
33080
33078
  const routeEntries = Object.entries(routes);
33081
33079
  const loadRoute = async ([routePath, loadFn]) => {
33082
33080
  const routeModule = await loadFn();
33081
+ if (typeof routeModule.default !== "function") {
33082
+ console.warn(`skipping api module without default export: ${routePath}`);
33083
+ return;
33084
+ }
33083
33085
  routeModule.default(api);
33084
33086
  const loggedPath = routePath.startsWith("../../") ? routePath.replace("../../", "@rpcbase/") : routePath;
33085
33087
  const GRAY = "\x1B[90m";
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { M, i, l } from "./index-Cvr_AVid.js";
1
+ import { M, i, l } from "./index-DNsXQO-7.js";
2
2
  export {
3
3
  M as MOCK_TYPE,
4
4
  i as initApi,
package/dist/initApi.d.ts CHANGED
@@ -1,3 +1,7 @@
1
1
  import { Application } from 'express';
2
- export declare const initApi: (app: Application) => Promise<void>;
2
+ type InitApiOptions = {
3
+ routes?: Record<string, () => Promise<any>>;
4
+ };
5
+ export declare const initApi: (app: Application, opts?: InitApiOptions) => Promise<void>;
6
+ export {};
3
7
  //# sourceMappingURL=initApi.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"initApi.d.ts","sourceRoot":"","sources":["../src/initApi.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,WAAW,EAAS,MAAM,SAAS,CAAA;AAiB5C,eAAO,MAAM,OAAO,GAAU,KAAK,WAAW,kBA4E7C,CAAA"}
1
+ {"version":3,"file":"initApi.d.ts","sourceRoot":"","sources":["../src/initApi.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,WAAW,EAAS,MAAM,SAAS,CAAA;AAiB5C,KAAK,cAAc,GAAG;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,OAAO,CAAC,GAAG,CAAC,CAAC,CAAA;CAC5C,CAAA;AAED,eAAO,MAAM,OAAO,GAAU,KAAK,WAAW,EAAE,OAAO,cAAc,kBAiFpE,CAAA"}
@@ -1,4 +1,4 @@
1
- import { g as getDefaultExportFromCjs } from "./index-Cvr_AVid.js";
1
+ import { g as getDefaultExportFromCjs } from "./index-DNsXQO-7.js";
2
2
  var isEmail$1 = { exports: {} };
3
3
  var assertString = { exports: {} };
4
4
  var hasRequiredAssertString;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rpcbase/api",
3
- "version": "0.33.0",
3
+ "version": "0.35.0",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"