UNPKG

@lucidcms/core

Version:

The core of the Lucid CMS. It's responsible for spinning up the API and serving the CMS.

2 lines 1.15 kB
import e from"../../../../constants/constants.mjs";import t from"../../../../utils/errors/lucid-api-error.mjs";import n from"../../../../services/auth/csrf/generate-token.mjs";import r from"../../middleware/rate-limiter.mjs";import i from"../../openapi/index.mjs";import a from"../../utils/build-response.mjs";import{controllerSchemas as o}from"../../../../schemas/auth.mjs";import{z as s}from"zod";import{minutesToMilliseconds as c}from"date-fns";import{createFactory as l}from"hono/factory";import{describeRoute as u}from"hono-openapi";const d=l().createHandlers(u({description:`This endpoint returns a CSRF token in the response body as well as setting a _csrf httpOnly cookie. Some endpoints require this value to be passed via a X-CSRF-Token header.`,tags:[`auth`],summary:`CSRF Token`,responses:i.responses({schema:s.toJSONSchema(o.getCSRF.response)})}),r({mode:`ip`,limit:e.rateLimit.scopes.standard.limit,scope:e.rateLimit.scopes.standard.scopeKey,windowMs:c(1)}),async e=>{let r=await n(e);if(r.error)throw new t(r.error);return e.status(200),e.json(a(e,{data:{_csrf:r.data}}))});export{d as default}; //# sourceMappingURL=get-csrf.mjs.map