UNPKG

create-jd-app

Version:

Create modern type safed Solid web application within seconds

34 lines (32 loc) 873 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const getBuilder = (ctx) => { const useAuth = ctx.installers.includes("AuthJS"); return `import { createCaller${useAuth ? ", error$" : ""} } from "@solid-mediakit/prpc";${useAuth ? `\nimport { authOptions } from "./auth";\nimport { getSession } from "@solid-mediakit/auth";` : ""} export const helloCaller = createCaller .use(() => { return { hello: 1, }; }) .use(({ ctx$ }) => { return { ...ctx$, world: 2, }; });${useAuth ? `\n\nexport const userCaller = createCaller.use(async ({ event$ }) => { const session = await getSession(event$.request, authOptions); if (!session) { return error$("Unauthorized", { status: 401, }); } return session; });` : ""} `; }; exports.default = getBuilder;