mirror of
https://gitlab.com/soapbox-pub/ditto.git
synced 2025-12-06 11:29:46 +00:00
15 lines
463 B
TypeScript
15 lines
463 B
TypeScript
import { HTTPException } from '@hono/hono/http-exception';
|
|
|
|
import type { DittoConfig } from '@ditto/config';
|
|
import type { MiddlewareHandler } from '@hono/hono';
|
|
|
|
/** Throws an error if conf isn't set. */
|
|
export const confRequiredMw: MiddlewareHandler<{ Variables: { conf: DittoConfig } }> = async (c, next) => {
|
|
const { conf } = c.var;
|
|
|
|
if (!conf) {
|
|
throw new HTTPException(500, { message: 'Ditto config not set in request.' });
|
|
}
|
|
|
|
await next();
|
|
};
|