Skip to content

OrJDev/solid-start-trpc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Base

import { createSolidAPIHandler } from "solid-start-trpc";

const handler = createSolidAPIHandler({
  router: appRouter,
  createContext: () => null,
});
export const get = handler;
export const post = handler;

// for version 0.1.6 +
export const GET = handler;
export const POST = handler;

Ctx

const createContext = (opts) => ({ req: opts.req, res: opts.res });

Response Meta

const handler = createSolidAPIHandler({
  router: appRouter,
  createContext,
  responseMeta: ({ ctx }) => {
    if (ctx?.req.headers.get("x-random-header")) {
      return {
        headers: {
          "x-random-header": `hello-${ctx.req.headers.get("x-random-header")}`,
        },
      };
    }
    return {};
  },
});

About

tRPC API Handler For Solid Start

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published