UNPKG

studiocms

Version:

Astro Native CMS for AstroDB. Built from the ground up by the Astro community.

20 lines (19 loc) 666 B
import { Effect, runEffect } from "@withstudiocms/effect"; import { defineUtility } from "astro-integration-kit"; import { getAstroProject, StudioCMSRouteConfig } from "../frontend/routes.js"; const routeHandler = defineUtility("astro:config:setup")( async (params, options) => { const { injectRoute, addMiddleware } = params; const projectEffect = getAstroProject.pipe(Effect.provide(StudioCMSRouteConfig.Live(options))); const { routes, middleware } = await runEffect(projectEffect); for (const route of routes) { injectRoute(route); } for (const mw of middleware) { addMiddleware(mw); } } ); export { routeHandler };