mirror of
https://github.com/fosrl/pangolin.git
synced 2025-07-30 07:35:15 +02:00
remove server admin from config and add onboarding ui
This commit is contained in:
parent
f300838f8e
commit
d03f45279c
15 changed files with 345 additions and 190 deletions
42
server/routers/auth/initialSetupComplete.ts
Normal file
42
server/routers/auth/initialSetupComplete.ts
Normal file
|
@ -0,0 +1,42 @@
|
|||
import { NextFunction, Request, Response } from "express";
|
||||
import HttpCode from "@server/types/HttpCode";
|
||||
import createHttpError from "http-errors";
|
||||
import logger from "@server/logger";
|
||||
import { response } from "@server/lib";
|
||||
import { db, users } from "@server/db";
|
||||
import { eq } from "drizzle-orm";
|
||||
|
||||
export type InitialSetupCompleteResponse = {
|
||||
complete: boolean;
|
||||
};
|
||||
|
||||
export async function initialSetupComplete(
|
||||
req: Request,
|
||||
res: Response,
|
||||
next: NextFunction
|
||||
): Promise<any> {
|
||||
try {
|
||||
const [existing] = await db
|
||||
.select()
|
||||
.from(users)
|
||||
.where(eq(users.serverAdmin, true));
|
||||
|
||||
return response<InitialSetupCompleteResponse>(res, {
|
||||
data: {
|
||||
complete: !!existing
|
||||
},
|
||||
success: true,
|
||||
error: false,
|
||||
message: "Initial setup check completed",
|
||||
status: HttpCode.OK
|
||||
});
|
||||
} catch (e) {
|
||||
logger.error(e);
|
||||
return next(
|
||||
createHttpError(
|
||||
HttpCode.INTERNAL_SERVER_ERROR,
|
||||
"Failed to check initial setup completion"
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue