REDROOM
PHP 8.2.30
Path:
Logout
Edit File
Size: 3.08 KB
Close
//proc/thread-self/root/home/byroehnu/.trash/node_modules11/@adminjs/express/lib/buildRouter.js
Text
Base64
import { Router as AdminRouter } from "adminjs"; import { Router } from "express"; import formidableMiddleware from "express-formidable"; import path from "path"; import { WrongArgumentError } from "./errors.js"; import { log } from "./logger.js"; import { convertToExpressRoute } from "./convertRoutes.js"; const INVALID_ADMINJS_INSTANCE = "You have to pass an instance of AdminJS to the buildRouter() function"; export const initializeAdmin = (admin) => { var _a; if (((_a = admin === null || admin === void 0 ? void 0 : admin.constructor) === null || _a === void 0 ? void 0 : _a.name) !== "AdminJS") { throw new WrongArgumentError(INVALID_ADMINJS_INSTANCE); } admin.initialize().then(() => { log.debug("AdminJS: bundle ready"); }); }; export const routeHandler = ({ admin, route }) => async (req, res, next) => { try { const controller = new route.Controller({ admin }, req.session && req.session.adminUser); const { params, query } = req; const method = req.method.toLowerCase(); const payload = Object.assign(Object.assign({}, (req.fields || {})), (req.files || {})); const html = await controller[route.action](Object.assign(Object.assign({}, req), { params, query, payload, method }), res); if (route.contentType) { res.set({ "Content-Type": route.contentType }); } if (html) { res.send(html); } } catch (e) { next(e); } }; export const buildRoute = ({ route, router, admin, }) => { // we have to change routes defined in AdminJS from {recordId} to :recordId const expressPath = convertToExpressRoute(route.path); if (route.method === "GET") { router.get(expressPath, routeHandler({ admin, route })); } if (route.method === "POST") { router.post(expressPath, routeHandler({ admin, route })); } }; export const buildRoutes = ({ admin, routes, router, }) => { routes.forEach((route) => buildRoute({ route, router, admin })); }; export const buildAssets = ({ admin, assets, routes, router, }) => { // Note: We want components.bundle.js to be globally available. In production it is served as a .js asset, meanwhile // in local environments it's a route with "bundleComponents" action assigned. const componentBundlerRoute = routes.find((r) => r.action === "bundleComponents"); if (componentBundlerRoute) { buildRoute({ route: componentBundlerRoute, router, admin }); } assets.forEach((asset) => { router.get(asset.path, async (_req, res) => { res.sendFile(path.resolve(asset.src)); }); }); }; export const buildRouter = (admin, predefinedRouter, formidableOptions) => { initializeAdmin(admin); const { routes, assets } = AdminRouter; const router = predefinedRouter !== null && predefinedRouter !== void 0 ? predefinedRouter : Router(); // todo fix types router.use(formidableMiddleware(formidableOptions)); buildAssets({ admin, assets, routes, router }); buildRoutes({ admin, routes, router }); return router; };
Save
Close
Exit & Reset
Text mode: syntax highlighting auto-detects file type.
Directory Contents
Dirs: 1 × Files: 14
Delete Selected
Select All
Select None
Sort:
Name
Size
Modified
Enable drag-to-move
Name
Size
Perms
Modified
Actions
authentication
DIR
-
drwxr-xr-x
2026-02-28 00:29:10
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
buildAuthenticatedRouter.d.ts
1.51 KB
lrw-r--r--
2026-02-28 00:28:44
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
buildAuthenticatedRouter.js
2.99 KB
lrw-r--r--
2026-02-28 00:27:30
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
buildRouter.d.ts
1.15 KB
lrw-r--r--
2026-02-28 00:28:48
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
buildRouter.js
3.08 KB
lrw-r--r--
2026-02-28 00:27:34
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
convertRoutes.d.ts
76 B
lrw-r--r--
2026-02-28 00:28:52
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
convertRoutes.js
102 B
lrw-r--r--
2026-02-28 00:27:44
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
errors.d.ts
491 B
lrw-r--r--
2026-02-28 00:28:56
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
errors.js
1.07 KB
lrw-r--r--
2026-02-28 00:27:48
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
index.d.ts
3.68 KB
lrw-r--r--
2026-02-28 00:28:58
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
index.js
3.41 KB
lrw-r--r--
2026-02-28 00:28:00
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
logger.d.ts
172 B
lrw-r--r--
2026-02-28 00:29:00
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
logger.js
255 B
lrw-r--r--
2026-02-28 00:28:04
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
types.d.ts
1.17 KB
lrw-r--r--
2026-02-28 00:29:12
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
types.js
11 B
lrw-r--r--
2026-02-28 00:28:24
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
Zip Selected
If ZipArchive is unavailable, a
.tar
will be created (no compression).