summary refs log tree commit diff
path: root/src/api/util/handlers/route.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/api/util/handlers/route.ts')
-rw-r--r--src/api/util/handlers/route.ts26
1 files changed, 15 insertions, 11 deletions
diff --git a/src/api/util/handlers/route.ts b/src/api/util/handlers/route.ts
index 04910ed4..331ac0c2 100644
--- a/src/api/util/handlers/route.ts
+++ b/src/api/util/handlers/route.ts
@@ -52,27 +52,31 @@ export type RouteResponse = {
 export interface RouteOptions {
 	permission?: PermissionResolvable;
 	right?: RightResolvable;
-	body?: `${string}Schema`; // typescript interface name
+	requestBody?: `${string}Schema`; // typescript interface name
 	responses?: {
 		[status: number]: {
 			// body?: `${string}Response`;
 			body?: string;
 		};
 	};
-	test?: {
-		response?: RouteResponse;
-		body?: unknown;
-		path?: string;
-		event?: EVENT | EVENT[];
-		headers?: Record<string, string>;
-	};
+	event?: EVENT | EVENT[];
+	summary?: string;
+	description?: string;
+	// test?: {
+	// 	response?: RouteResponse;
+	// 	body?: unknown;
+	// 	path?: string;
+	// 	event?: EVENT | EVENT[];
+	// 	headers?: Record<string, string>;
+	// };
 }
 
 export function route(opts: RouteOptions) {
 	let validate: AnyValidateFunction | undefined;
-	if (opts.body) {
-		validate = ajv.getSchema(opts.body);
-		if (!validate) throw new Error(`Body schema ${opts.body} not found`);
+	if (opts.requestBody) {
+		validate = ajv.getSchema(opts.requestBody);
+		if (!validate)
+			throw new Error(`Body schema ${opts.requestBody} not found`);
 	}
 
 	return async (req: Request, res: Response, next: NextFunction) => {