@rpcbase/api 0.94.0 → 0.96.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.js +6 -5
- package/dist/index.js.map +1 -1
- package/dist/initApi.d.ts +3 -1
- package/dist/initApi.d.ts.map +1 -1
- package/dist/types.d.ts +6 -6
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -21523,11 +21523,12 @@ const initApi = async ({
|
|
|
21523
21523
|
}, { concurrency: 32 });
|
|
21524
21524
|
for (const [routePath] of routeEntries) {
|
|
21525
21525
|
const routeModule = loadedModules.get(routePath);
|
|
21526
|
-
|
|
21526
|
+
const routeRegistrar = routeModule?.default;
|
|
21527
|
+
if (typeof routeRegistrar !== "function") {
|
|
21527
21528
|
console.warn(`skipping api module without default export: ${routePath}`);
|
|
21528
21529
|
continue;
|
|
21529
21530
|
}
|
|
21530
|
-
|
|
21531
|
+
routeRegistrar(api);
|
|
21531
21532
|
const GRAY = "\x1B[90m";
|
|
21532
21533
|
const RESET = "\x1B[0m";
|
|
21533
21534
|
const coloredPath = routePath.startsWith("@rpcbase/") ? `${GRAY}${routePath}${RESET}` : routePath;
|
|
@@ -21539,9 +21540,9 @@ const initApi = async ({
|
|
|
21539
21540
|
});
|
|
21540
21541
|
app.use("/api", (err, _req, res, next) => {
|
|
21541
21542
|
if (res.headersSent) return next(err);
|
|
21542
|
-
const
|
|
21543
|
-
const code = typeof
|
|
21544
|
-
const statusCode = typeof
|
|
21543
|
+
const errLike = err;
|
|
21544
|
+
const code = typeof errLike?.code === "string" ? errLike.code : null;
|
|
21545
|
+
const statusCode = typeof errLike?.statusCode === "number" ? errLike.statusCode : typeof errLike?.status === "number" ? errLike.status : null;
|
|
21545
21546
|
if (code === "invalid_pagination") {
|
|
21546
21547
|
res.status(statusCode ?? 400).json({ error: code });
|
|
21547
21548
|
return;
|