Skip to content
This repository has been archived by the owner on Sep 24, 2024. It is now read-only.

Split constraints into separate files #55

Merged
merged 4 commits into from
Dec 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 0 additions & 17 deletions server/plugins/constraints.ts

This file was deleted.

23 changes: 23 additions & 0 deletions server/plugins/triggers.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { apiError, ErrorCode } from "~/utils/error";
import { addTriggers } from "~/server/prisma";

import { h3Error } from "./apiError";

/**
* Makes sure that the triggers script has run correctly before accepting requests on release.
*/
export default defineNitroPlugin(async (nitroApp) => {
if (process.env.NODE_ENV !== "development") {
const oldHandler = nitroApp.h3App.handler;
nitroApp.h3App.handler = defineEventHandler(() => {
throw h3Error(
apiError(ErrorCode.InternalError, "Constraints not ready."),
);
});

await addTriggers();
nitroApp.h3App.handler = oldHandler;
} else {
await addTriggers();
}
});
Loading