solid-start-trpc
TypeScript icon, indicating that this package has built-in type declarations

0.0.16 • Public • Published

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 {};
  },
});

Readme

Keywords

Package Sidebar

Install

npm i solid-start-trpc

Weekly Downloads

13

Version

0.0.16

License

ISC

Unpacked Size

19.8 kB

Total Files

11

Last publish

Collaborators

  • orjdev