-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
Proof of ConceptReArc BackendThis concerns either the backend itself or the client -> server connectionThis concerns either the backend itself or the client -> server connectionRefactoringThis issue refactors a part of the codebaseThis issue refactors a part of the codebaseResearch
Description
Old:
export const AdminStoreVerificationGet: RouteArrayed = [
"get",
"/admin/store/verification/:itemId",
async (req, res, stop) => {
if (!req.headers.authorization) return stop();
const [type, token] = req.headers.authorization.split(" ");
if (type !== "Bearer" || !token) return stop();
const user = await getUserByToken(token);
if (await isTokenRestricted(token)) return stop(403);
if (!user || !user.admin) return stop(403);
if (!canAccess(user, AdminScopes.adminStoreVerificationGet))
return stop(401);
const pkg = await getPackageById(req.params.itemId);
if (!pkg) return stop(404);
res.json({
version: pkg.verifiedVer,
by: pkg.verifiedBy,
note: pkg.verifiedNote,
});
return;
},
0,
];New:
export class AdminStoreVerificationGet extends AdminEndpointBuilder<{ itemId: string }>(AdminScopes.adminStoreVerificationGet, Params("itemId")) {
static method: Method = "get";
static route = "/admin/store/verification/:itemId";
async handler(_: Request, res: Response, stop: StopFn): Promise<any> {
const pkg = await getPackageById(this.params.itemId);
if (!pkg) return stop(404);
res.json({
version: pkg.verifiedVer,
by: pkg.verifiedBy,
note: pkg.verifiedNote,
});
}
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Proof of ConceptReArc BackendThis concerns either the backend itself or the client -> server connectionThis concerns either the backend itself or the client -> server connectionRefactoringThis issue refactors a part of the codebaseThis issue refactors a part of the codebaseResearch