better-call 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +9 -14
  2. package/package.json +2 -1
package/README.md CHANGED
@@ -1,18 +1,11 @@
1
1
  # better-call
2
2
 
3
- Better call is a tiny web framework for creating endpoints that can be invoked as a function or mounted to a router and can be served by any web standard compatible server (like Bun, node, nextjs, sveltekit...). Built for typescript and it comes with a very high performance router based on [rou3](https://github.com/unjs/rou3).
3
+ Better call is a tiny web framework for creating endpoints that can be invoked as a normal function or mounted to a router and can be served by any web standard compatible server (like Bun, node, nextjs, sveltekit...).
4
4
 
5
- ### Use cases:
5
+ Built for typescript and it comes with a very high performance router based on [rou3](https://github.com/unjs/rou3).
6
6
 
7
- ### Use Cases:
8
7
 
9
- - **Single Function Endpoint**: Define an endpoint once and use it in different context. Like in React Server Components (RSC), as a server action, or directly as api route in your Next.js app from a single function.
10
-
11
- - **Typed Endpoints**: Create endpoints with typed parameters and return types that can be invoked from other endpoints or used throughout your code.
12
-
13
- - **Library Integration**: Ideal for libraries that need to expose server endpoints. Export a function that can be mounted to a route and used as a function, for example an auth library with a `getSession` function.
14
-
15
- > ⚠️ This project is still in development and not ready for production use. But feel free to try it out and give feedback.
8
+ > ⚠️ This project early in development and not ready for production use. But feel free to try it out and give feedback.
16
9
 
17
10
  ## Install
18
11
 
@@ -67,7 +60,7 @@ Bun.serve({
67
60
 
68
61
  You can create middleware by calling `createMiddleware` and passing it a function that will be invoked before the endpoint is called.
69
62
 
70
- If you return an object from the middleware, it will be merged with the context object on the endpoint.
63
+ If you return a context object from the middleware, it will be merged with the context object on the endpoint.
71
64
 
72
65
  ```ts
73
66
  import { createMiddleware, createEndpoint } from "better-call"
@@ -77,9 +70,11 @@ const createProtectedEndpoint = createMiddleware(async (ctx) => {
77
70
  throw new Error("Unauthorized")
78
71
  }
79
72
  return {
80
- session: {
81
- id: "123",
82
- }
73
+ context: {
74
+ session: {
75
+ id: "123",
76
+ }
77
+ }
83
78
  }
84
79
  })
85
80
 
package/package.json CHANGED
@@ -1,12 +1,13 @@
1
1
  {
2
2
  "name": "better-call",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "type": "module",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.js",
7
7
  "types": "./dist/index.d.ts",
8
8
  "scripts": {
9
9
  "test": "vitest",
10
+ "typecheck": "tsc --noEmit",
10
11
  "bump": "bumpp",
11
12
  "build": "tsup"
12
13
  },