{"id":21895280,"url":"https://github.com/orjdev/authpc","last_synced_at":"2026-02-08T18:01:27.145Z","repository":{"id":264976778,"uuid":"875011576","full_name":"OrJDev/authpc","owner":"OrJDev","description":null,"archived":false,"fork":false,"pushed_at":"2024-10-19T01:24:09.000Z","size":42,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-16T07:29:20.925Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/OrJDev.png","metadata":{"files":{"readme":"README.MD","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-10-18T22:31:03.000Z","updated_at":"2024-10-21T08:56:12.000Z","dependencies_parsed_at":"2024-11-27T06:34:57.782Z","dependency_job_id":null,"html_url":"https://github.com/OrJDev/authpc","commit_stats":null,"previous_names":["orjdev/authpc"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OrJDev%2Fauthpc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OrJDev%2Fauthpc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OrJDev%2Fauthpc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OrJDev%2Fauthpc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/OrJDev","download_url":"https://codeload.github.com/OrJDev/authpc/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244904385,"owners_count":20529427,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-28T13:33:57.846Z","updated_at":"2026-02-08T18:01:22.102Z","avatar_url":"https://github.com/OrJDev.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003e uncompleted docs, demo purposes\n\n- check out [how it works](./Testing.md)\n- check out [transform](./transform.md)\n\n# @solid-mediakit/authpc\n\nType-safe utility library for Solid\n\n## createCaller\n\nUse this method to interact with the api, you can choose wether to use a `query` or a `mutation` (default is query) and also choose wether to use `GET`/`POST` (default is POST).\n\n```ts\nimport { createCaller, response$ } from '@solid-mediakit/authpc'\nimport { z } from 'zod'\n\nconst mySchema = z.object({ name: z.string() })\n\ncreateCaller(mySchema, ({ input$, session$ }) =\u003e {\n  console.log('User logged in?', session$)\n  return `Hey there ${input$.name}`\n})\n\n// protected server function\ncreateCaller(\n  mySchema,\n  ({ input$, session$ }) =\u003e {\n    console.log('User logged in!!!', session$)\n    return `Hey there ${input$.name}`\n  },\n  {\n    protected: true,\n  },\n)\n\n// this will be called using GET method\nexport const getRequest = createCaller(\n  () =\u003e {\n    return response$(\n      { iSetTheHeader: true },\n      { headers: { 'cache-control': 'max-age=60' } },\n    )\n  },\n  {\n    method: 'GET',\n  },\n)\n\n// this will be called using GET method, and is a mutation\nexport const mutation = createCaller(\n  () =\u003e {\n    return response$(\n      { iSetTheHeader: true },\n      { headers: { 'cache-control': 'max-age=60' } },\n    )\n  },\n  {\n    method: 'GET',\n    type: 'action',\n  },\n)\nmutation.mutate()\n```\n\n## Middleware \u0026 Merging\n\nYou can combine multiple callers / middlewares and import them to different files.\n\n### file1.ts\n\n```ts\nimport { createCaller } from '@solid-mediakit/authpc'\n\nexport const withMw1 = createCaller.use(() =\u003e {\n  return {\n    myFile1: 1,\n  }\n})\n\nexport const action1 = withMw1(({ ctx$ }) =\u003e {\n  return `hey ${ctx$.myFile1} `\n})\n```\n\nbecomes\n\n```ts\nimport { createCaller, callMiddleware$ } from '@solid-mediakit/authpc'\n\nexport const withMw1 = createCaller\n\nexport const action1 = createCaller(\n  async ({ input$: _$$payload }) =\u003e {\n    'use server'\n    const ctx$ = await callMiddleware$(_$$event, _$$withMw1_mws)\n    if (ctx$ instanceof Response) return ctx$\n    return `hey ${ctx$.myFile1} `\n  },\n  {\n    protected: false,\n    key: 'action1',\n    method: 'POST',\n    type: 'query',\n  },\n)\n\nexport const _$$withMw1_mws = [\n  () =\u003e {\n    return {\n      myFile1: 1,\n    }\n  },\n]\n```\n\n### file2.ts\n\n```ts\nimport { withMw1 } from './file1'\n\nexport const withMw2 = withMw1.use(({ ctx$ }) =\u003e {\n  return {\n    ...ctx$,\n    myFile2: 2,\n  }\n})\n\nexport const action2 = withMw2(({ ctx$ }) =\u003e {\n  return `hey ${ctx$.myFile1} ${ctx$.myFile2}`\n})\n```\n\nbecomes:\n\n\n```ts\nimport { createCaller, callMiddleware$ } from '@solid-mediakit/authpc'\nimport { withMw1, _$$withMw1_mws } from './file1'\n\nexport const withMw2 = withMw1\n\nexport const action2 = createCaller(\n  async ({ input$: _$$payload }) =\u003e {\n    'use server'\n    const ctx$ = await callMiddleware$(_$$event, _$$withMw2_mws)\n    if (ctx$ instanceof Response) return ctx$\n    return `hey ${ctx$.myFile1} ${ctx$.myFile2}`\n  },\n  {\n    protected: false,\n    key: 'action2',\n    method: 'POST',\n    type: 'query',\n  },\n)\n\nexport const _$$withMw2_mws = [\n  ..._$$withMw1_mws,\n  ({ ctx$ }) =\u003e {\n    return {\n      ...ctx$,\n      myFile2: 2,\n    }\n  },\n]\n```\n\n- check out [how it works](./Testing.md)\n- check out [transform](./transform.md)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Forjdev%2Fauthpc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Forjdev%2Fauthpc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Forjdev%2Fauthpc/lists"}