UNPKG

winterspec

Version:

Write Winter-CG compatible routes with filesystem routing and tons of features

8 lines (7 loc) 316 B
export const withResponseObjectCheck = async (req, ctx, next) => { const rawResponse = await next(req, ctx); if (typeof rawResponse === "object" && !(rawResponse instanceof Response)) { throw new Error("Use ctx.json({...}) instead of returning an object directly."); } return rawResponse; };