-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
4,183 additions
and
351 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import AdminJS from "adminjs" | ||
import { AdminJSOptions } from "adminjs" | ||
import AdminJSExpress from "@adminjs/express" | ||
import { Database, Resource, getModelByName } from "@adminjs/prisma" | ||
import express, { Request, Response } from "express" | ||
|
||
import prisma from "@/lib/prisma" | ||
|
||
AdminJS.registerAdapter({ Database, Resource }) | ||
|
||
console.log("running expressjs") | ||
|
||
const options: AdminJSOptions = { | ||
rootPath: "/admin", | ||
branding: { | ||
companyName: "My Company", | ||
withMadeWithLove: false, | ||
}, | ||
locale: { | ||
language: "en", // default language | ||
availableLanguages: ["en"], | ||
localeDetection: true, | ||
}, | ||
resources: [ | ||
{ | ||
resource: { model: getModelByName("Study"), client: prisma }, | ||
options: {}, | ||
}, | ||
], | ||
} | ||
|
||
const adminJs = new AdminJS(options) | ||
const app = express() | ||
app.use(adminJs.options.rootPath, AdminJSExpress.buildRouter(adminJs)) | ||
|
||
// adminJs.watch() | ||
|
||
const handler = (req: Request, res: Response) => { | ||
app(req, res, err => { | ||
console.log("express handling") | ||
|
||
if (!res.headersSent) { | ||
console.warn("no headers sent") | ||
} | ||
|
||
if (err) { | ||
console.error(err) | ||
res.status(err.status || 500).end(err.message) | ||
} else { | ||
res.end() | ||
} | ||
}) | ||
} | ||
|
||
export default handler | ||
|
||
export const config = { | ||
api: { | ||
// Defaults to true. Setting this to false disables body parsing and allows you to consume the request body as stream or raw-body. | ||
bodyParser: false, | ||
|
||
// Determines how much data should be sent from the response body. It is automatically enabled and defaults to 4mb. | ||
responseLimit: false, | ||
|
||
// Disables warnings for unresolved requests if the route is being handled by an external resolver like Express.js or Connect. Defaults to false. | ||
externalResolver: true, | ||
}, | ||
} |
Oops, something went wrong.