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.52 kB
import e from"../../../../constants/constants.mjs";import t from"../../../../utils/errors/lucid-api-error.mjs";import n from"../../utils/create-service-context.mjs";import r from"../../../../utils/services/service-wrapper.mjs";import i from"../../../../services/media-share-links/get-share-access.mjs";import a from"../../middleware/rate-limiter.mjs";import o from"../../middleware/validate.mjs";import s from"../../openapi/index.mjs";import c from"../../utils/build-response.mjs";import{controllerSchemas as l}from"../../../../schemas/share.mjs";import u from"../../../../utils/share-link/auth-cookie.mjs";import{z as d}from"zod";import{minutesToMilliseconds as f}from"date-fns";import{getCookie as p}from"hono/cookie";import{createFactory as m}from"hono/factory";import{describeRoute as h}from"hono-openapi";const g=m().createHandlers(h({description:`Returns share link metadata and whether the current visitor must provide a password.`,tags:[`share`],summary:`Get Share Access`,parameters:s.parameters({params:l.getShareAccess.params}),responses:s.responses({schema:d.toJSONSchema(l.getShareAccess.response)})}),a({mode:`ip`,scope:e.rateLimit.scopes.low.scopeKey,limit:e.rateLimit.scopes.low.limit,windowMs:f(1)}),o(`param`,l.getShareAccess.params),async e=>{let{token:a}=e.req.valid(`param`),o=n(e),s=p(e,u(a)),l=await r(i,{transaction:!1})(o,{token:a,sessionCookie:s});if(l.error)throw new t(l.error);return e.status(200),e.json(c(e,{data:l.data}))});export{g as default}; //# sourceMappingURL=get-share-access.mjs.map