🧙♀️ Move Fast and Break Nothing. End-to-end typesafe APIs made easy.
Installations
npm install @trpc/server
Developer Guide
Typescript
No
Module System
CommonJS, ESM
Node Version
20.10.0
NPM Version
lerna/8.0.0/node@v20.10.0+x64 (darwin)
Score
98.8
Supply Chain
96.5
Quality
97.6
Maintenance
100
Vulnerability
100
License
Releases
Contributors
Languages
TypeScript (79.83%)
MDX (17.17%)
JavaScript (1.78%)
CSS (1.22%)
Developer
Download Statistics
Total Downloads
49,080,972
Last Day
35,411
Last Week
484,277
Last Month
2,838,953
Last Year
31,482,921
GitHub Statistics
35,350 Stars
4,321 Commits
1,271 Forks
97 Watching
29 Branches
428 Contributors
Bundle Size
14.40 kB
Minified
4.56 kB
Minified + Gzipped
Sponsor this package
Package Meta Information
Latest Version
10.45.2
Package Id
@trpc/server@10.45.2
Unpacked Size
696.62 kB
Size
147.08 kB
File Count
354
NPM Version
lerna/8.0.0/node@v20.10.0+x64 (darwin)
Node Version
20.10.0
Publised On
11 Mar 2024
Total Downloads
Cumulative downloads
Total Downloads
49,080,972
Last day
-73.3%
35,411
Compared to previous day
Last week
-31.2%
484,277
Compared to previous week
Last month
-2.1%
2,838,953
Compared to previous month
Last year
114.1%
31,482,921
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dev Dependencies
32
tRPC
End-to-end typesafe APIs made easy
@trpc/server
Create tRPC routers and connect them to a server.
Documentation
Full documentation for @trpc/server
can be found here
Installation
1# npm 2npm install @trpc/server 3 4# Yarn 5yarn add @trpc/server 6 7# pnpm 8pnpm add @trpc/server 9 10# Bun 11bun add @trpc/server
We also recommend installing zod
to validate procedure inputs.
Basic Example
1import { initTRPC } from '@trpc/server'; 2import { 3 CreateHTTPContextOptions, 4 createHTTPServer, 5} from '@trpc/server/adapters/standalone'; 6import { z } from 'zod'; 7 8// Initialize a context for the server 9function createContext(opts: CreateHTTPContextOptions) { 10 return {}; 11} 12 13// Get the context type 14type Context = Awaited<ReturnType<typeof createContext>>; 15 16// Initialize tRPC 17const t = initTRPC.context<Context>().create(); 18 19// Create main router 20const appRouter = t.router({ 21 // Greeting procedure 22 greeting: t.procedure 23 .input( 24 z.object({ 25 name: z.string(), 26 }), 27 ) 28 .query(({ input }) => `Hello, ${input.name}!`), 29}); 30 31// Export the app router type to be imported on the client side 32export type AppRouter = typeof appRouter; 33 34// Create HTTP server 35const { listen } = createHTTPServer({ 36 router: appRouter, 37 createContext, 38}); 39 40// Listen on port 2022 41listen(2022);
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
30 commit(s) and 18 issue activity found in the last 90 days -- score normalized to 10
Reason
security policy file detected
Details
- Info: security policy file detected: SECURITY.md:1
- Info: Found linked content: SECURITY.md:1
- Info: Found disclosure, vulnerability, and/or timelines in security policy: SECURITY.md:1
- Info: Found text in security policy: SECURITY.md:1
Reason
no binaries found in the repo
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
Found 11/15 approved changesets -- score normalized to 7
Reason
SAST tool detected but not run on all commits
Details
- Info: SAST configuration detected: CodeQL
- Warn: 0 commits out of 30 are checked with a SAST tool
Reason
detected GitHub workflow tokens with excessive permissions
Details
- Info: jobLevel 'actions' permission set to 'read': .github/workflows/codeql-analysis.yml:28
- Info: jobLevel 'contents' permission set to 'read': .github/workflows/codeql-analysis.yml:29
- Info: jobLevel 'contents' permission set to 'read': .github/workflows/labeler.yml:8
- Warn: no topLevel permission defined: .github/workflows/codeql-analysis.yml:1
- Warn: topLevel 'contents' permission set to 'write': .github/workflows/dependabot-approve.yml:6
- Warn: no topLevel permission defined: .github/workflows/labeler.yml:1
- Info: topLevel 'contents' permission set to 'read': .github/workflows/lint.yml:3
- Warn: no topLevel permission defined: .github/workflows/main.yml:1
- Warn: no topLevel permission defined: .github/workflows/release-next.yml:1
- Warn: no topLevel permission defined: .github/workflows/release-tmp.yml:1
- Warn: no topLevel permission defined: .github/workflows/release.yml:1
- Warn: no topLevel permission defined: .github/workflows/subtree.yml:1
- Info: no jobLevel write permissions found
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/codeql-analysis.yml:42: update your workflow using https://app.stepsecurity.io/secureworkflow/trpc/trpc/codeql-analysis.yml/next?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/codeql-analysis.yml:46: update your workflow using https://app.stepsecurity.io/secureworkflow/trpc/trpc/codeql-analysis.yml/next?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/codeql-analysis.yml:57: update your workflow using https://app.stepsecurity.io/secureworkflow/trpc/trpc/codeql-analysis.yml/next?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/codeql-analysis.yml:71: update your workflow using https://app.stepsecurity.io/secureworkflow/trpc/trpc/codeql-analysis.yml/next?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/labeler.yml:12: update your workflow using https://app.stepsecurity.io/secureworkflow/trpc/trpc/labeler.yml/next?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/lint.yml:21: update your workflow using https://app.stepsecurity.io/secureworkflow/trpc/trpc/lint.yml/next?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/lock-issues.yml:23: update your workflow using https://app.stepsecurity.io/secureworkflow/trpc/trpc/lock-issues.yml/next?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/main.yml:97: update your workflow using https://app.stepsecurity.io/secureworkflow/trpc/trpc/main.yml/next?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/main.yml:135: update your workflow using https://app.stepsecurity.io/secureworkflow/trpc/trpc/main.yml/next?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/main.yml:142: update your workflow using https://app.stepsecurity.io/secureworkflow/trpc/trpc/main.yml/next?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/main.yml:170: update your workflow using https://app.stepsecurity.io/secureworkflow/trpc/trpc/main.yml/next?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/main.yml:177: update your workflow using https://app.stepsecurity.io/secureworkflow/trpc/trpc/main.yml/next?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/main.yml:217: update your workflow using https://app.stepsecurity.io/secureworkflow/trpc/trpc/main.yml/next?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/main.yml:224: update your workflow using https://app.stepsecurity.io/secureworkflow/trpc/trpc/main.yml/next?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/main.yml:249: update your workflow using https://app.stepsecurity.io/secureworkflow/trpc/trpc/main.yml/next?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/main.yml:24: update your workflow using https://app.stepsecurity.io/secureworkflow/trpc/trpc/main.yml/next?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/main.yml:39: update your workflow using https://app.stepsecurity.io/secureworkflow/trpc/trpc/main.yml/next?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/main.yml:46: update your workflow using https://app.stepsecurity.io/secureworkflow/trpc/trpc/main.yml/next?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release-next.yml:25: update your workflow using https://app.stepsecurity.io/secureworkflow/trpc/trpc/release-next.yml/next?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/release-next.yml:42: update your workflow using https://app.stepsecurity.io/secureworkflow/trpc/trpc/release-next.yml/next?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release-tmp.yml:28: update your workflow using https://app.stepsecurity.io/secureworkflow/trpc/trpc/release-tmp.yml/next?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release.yml:25: update your workflow using https://app.stepsecurity.io/secureworkflow/trpc/trpc/release.yml/next?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/subtree.yml:34: update your workflow using https://app.stepsecurity.io/secureworkflow/trpc/trpc/subtree.yml/next?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/subtree.yml:39: update your workflow using https://app.stepsecurity.io/secureworkflow/trpc/trpc/subtree.yml/next?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/subtree.yml:48: update your workflow using https://app.stepsecurity.io/secureworkflow/trpc/trpc/subtree.yml/next?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/subtree.yml:49: update your workflow using https://app.stepsecurity.io/secureworkflow/trpc/trpc/subtree.yml/next?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/subtree.yml:69: update your workflow using https://app.stepsecurity.io/secureworkflow/trpc/trpc/subtree.yml/next?enable=pin
- Warn: containerImage not pinned by hash: examples/.railway/next-sse-chat/Dockerfile:1
- Warn: containerImage not pinned by hash: examples/.railway/next-sse-chat/Dockerfile:9
- Warn: containerImage not pinned by hash: examples/.railway/next-sse-chat/Dockerfile:17
- Warn: containerImage not pinned by hash: examples/.railway/next-sse-chat/Dockerfile:32
- Info: 0 out of 19 GitHub-owned GitHubAction dependencies pinned
- Info: 1 out of 9 third-party GitHubAction dependencies pinned
- Info: 0 out of 4 containerImage dependencies pinned
Reason
40 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-hpx4-r86g-5jrg
- Warn: Project is vulnerable to: GHSA-prr3-c3m5-p7q2
- Warn: Project is vulnerable to: GHSA-7q7g-4xm8-89cq
- Warn: Project is vulnerable to: GHSA-c2jc-4fpr-4vhg
- Warn: Project is vulnerable to: GHSA-wf5p-g6vw-rhxx
- Warn: Project is vulnerable to: GHSA-8hc4-vh64-cxmj
- Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg
- Warn: Project is vulnerable to: GHSA-pxg6-pf52-xh8x
- Warn: Project is vulnerable to: GHSA-h452-7996-h45h
- Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275
- Warn: Project is vulnerable to: GHSA-ghr5-ch3p-vcr6
- Warn: Project is vulnerable to: GHSA-4gmj-3p3h-gm8h
- Warn: Project is vulnerable to: GHSA-rrr8-f88r-h8q6
- Warn: Project is vulnerable to: GHSA-jchw-25xp-jwwc
- Warn: Project is vulnerable to: GHSA-cxjh-pqwp-8mfp
- Warn: Project is vulnerable to: GHSA-9pv7-vfvm-6vr7
- Warn: Project is vulnerable to: GHSA-c7qv-q95q-8v27
- Warn: Project is vulnerable to: GHSA-78xj-cgh5-2h22
- Warn: Project is vulnerable to: GHSA-2p57-rm9w-gvfp
- Warn: Project is vulnerable to: GHSA-hhhv-q57g-882q
- Warn: Project is vulnerable to: GHSA-pppg-cpfq-h7wr
- Warn: Project is vulnerable to: GHSA-3xq5-wjfh-ppjc
- Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv
- Warn: Project is vulnerable to: GHSA-mwcw-c2x4-8c55
- Warn: Project is vulnerable to: GHSA-rhx6-c78j-4q9w
- Warn: Project is vulnerable to: GHSA-9wv6-86v2-598j
- Warn: Project is vulnerable to: GHSA-hrpp-h998-j3pp
- Warn: Project is vulnerable to: GHSA-gcx4-mw62-g8wm
- Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw
- Warn: Project is vulnerable to: GHSA-9w5j-4mwv-2wj8
- Warn: Project is vulnerable to: GHSA-f5x3-32g6-xq36
- Warn: Project is vulnerable to: GHSA-3787-6prv-h9w3
- Warn: Project is vulnerable to: GHSA-9qxr-qj54-h672
- Warn: Project is vulnerable to: GHSA-m4v8-wqvr-p9f7
- Warn: Project is vulnerable to: GHSA-5r9g-qh6m-jxff
- Warn: Project is vulnerable to: GHSA-r6ch-mqf9-qc9w
- Warn: Project is vulnerable to: GHSA-wqq4-5wpv-mx2g
- Warn: Project is vulnerable to: GHSA-8c93-4hch-xgxp
- Warn: Project is vulnerable to: GHSA-f8mp-x433-5wpf
- Warn: Project is vulnerable to: GHSA-776f-qx25-q3cc
Score
5.7
/10
Last Scanned on 2024-12-16
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More