ras-stack 0.3.4 → 0.4.0
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.
- package/README.md +15 -10
- package/dist/tanstack/query.d.ts +3 -0
- package/dist/tanstack/query.js +8 -0
- package/dist/tanstack/query.js.map +1 -0
- package/dist/tanstack/server.d.ts +8 -0
- package/dist/tanstack/server.js +10 -0
- package/dist/tanstack/server.js.map +1 -0
- package/package.json +19 -1
package/README.md
CHANGED
|
@@ -63,23 +63,28 @@ const auth = betterAuth({
|
|
|
63
63
|
})
|
|
64
64
|
```
|
|
65
65
|
|
|
66
|
-
|
|
66
|
+
The optional TanStack entrypoints bind the shared primitives to TanStack Start's ambient request and provide the common Query client default:
|
|
67
67
|
|
|
68
68
|
```ts
|
|
69
|
-
import {
|
|
70
|
-
import {
|
|
71
|
-
import { createRpc } from 'ras-stack/server'
|
|
69
|
+
import { createStackQueryClient } from 'ras-stack/tanstack/query'
|
|
70
|
+
import { createTanStackRpc, requireTanStackMutationOrigin } from 'ras-stack/tanstack/server'
|
|
72
71
|
|
|
73
|
-
export const { rpc, mutationRpc } =
|
|
74
|
-
getRequest,
|
|
72
|
+
export const { rpc, mutationRpc } = createTanStackRpc({
|
|
75
73
|
requireMutation: (request) =>
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
74
|
+
requireTanStackMutationOrigin(
|
|
75
|
+
{
|
|
76
|
+
configured: [process.env.APP_URL],
|
|
77
|
+
trustForwardedHeaders: true,
|
|
78
|
+
},
|
|
79
|
+
request,
|
|
80
|
+
),
|
|
80
81
|
})
|
|
82
|
+
|
|
83
|
+
export const queryClient = createStackQueryClient()
|
|
81
84
|
```
|
|
82
85
|
|
|
86
|
+
Applications still own their auth clients, authorization, routes, router, logging, health checks, and Query configuration. Both integrations remain optional, and their upstream libraries remain directly accessible.
|
|
87
|
+
|
|
83
88
|
Only enable `trustForwardedHeaders` behind a proxy that replaces incoming forwarded headers. Otherwise a client could choose the origin used by the check.
|
|
84
89
|
|
|
85
90
|
## Realtime updates
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { QueryClient } from '@tanstack/react-query';
|
|
2
|
+
export function createStackQueryClient(config = {}) {
|
|
3
|
+
return new QueryClient({ defaultOptions: { queries: { staleTime: 1000 } }, ...config });
|
|
4
|
+
}
|
|
5
|
+
export function queryErrorMessage(error, fallback = 'Something went wrong. Try again.') {
|
|
6
|
+
return error instanceof Error && error.message ? error.message : fallback;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=query.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query.js","sourceRoot":"","sources":["../../src/tanstack/query.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAA0B,MAAM,uBAAuB,CAAA;AAE3E,MAAM,UAAU,sBAAsB,CAAC,MAAM,GAAsB,EAAE;IACnE,OAAO,IAAI,WAAW,CAAC,EAAE,cAAc,EAAE,EAAE,OAAO,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,MAAM,EAAE,CAAC,CAAA;AACzF,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,KAAc,EAAE,QAAQ,GAAG,kCAAkC;IAC7F,OAAO,KAAK,YAAY,KAAK,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAA;AAC3E,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type OriginOptions } from '../auth/index.js';
|
|
2
|
+
import { type RpcOptions } from '../server/index.js';
|
|
3
|
+
export type TanStackRpcOptions = Omit<RpcOptions, 'getRequest'> & Pick<RpcOptions, 'getRequest'>;
|
|
4
|
+
export declare function createTanStackRpc(options?: TanStackRpcOptions): {
|
|
5
|
+
rpc: <T>(work: () => Promise<T> | T) => Promise<T>;
|
|
6
|
+
mutationRpc: <T>(work: () => Promise<T> | T, request?: Request | undefined) => Promise<T>;
|
|
7
|
+
};
|
|
8
|
+
export declare function requireTanStackMutationOrigin(options?: OriginOptions, request?: Request): void;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { getRequest } from '@tanstack/react-start/server';
|
|
2
|
+
import { requireSameOrigin } from '../auth/index.js';
|
|
3
|
+
import { createRpc } from '../server/index.js';
|
|
4
|
+
export function createTanStackRpc(options = {}) {
|
|
5
|
+
return createRpc({ ...options, getRequest: options.getRequest ?? getRequest });
|
|
6
|
+
}
|
|
7
|
+
export function requireTanStackMutationOrigin(options = {}, request = getRequest()) {
|
|
8
|
+
return requireSameOrigin(request, options);
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../../src/tanstack/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAA;AACzD,OAAO,EAAE,iBAAiB,EAAsB,MAAM,kBAAkB,CAAA;AACxE,OAAO,EAAE,SAAS,EAAmB,MAAM,oBAAoB,CAAA;AAI/D,MAAM,UAAU,iBAAiB,CAAC,OAAO,GAAuB,EAAE;IAChE,OAAO,SAAS,CAAC,EAAE,GAAG,OAAO,EAAE,UAAU,EAAE,OAAO,CAAC,UAAU,IAAI,UAAU,EAAE,CAAC,CAAA;AAChF,CAAC;AAED,MAAM,UAAU,6BAA6B,CAAC,OAAO,GAAkB,EAAE,EAAE,OAAO,GAAG,UAAU,EAAE;IAC/F,OAAO,iBAAiB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;AAC5C,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ras-stack",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Composable full-stack primitives shared across Richard Solomou's applications.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"authentication",
|
|
@@ -39,6 +39,14 @@
|
|
|
39
39
|
"types": "./dist/server/index.d.ts",
|
|
40
40
|
"default": "./dist/server/index.js"
|
|
41
41
|
},
|
|
42
|
+
"./tanstack/query": {
|
|
43
|
+
"types": "./dist/tanstack/query.d.ts",
|
|
44
|
+
"default": "./dist/tanstack/query.js"
|
|
45
|
+
},
|
|
46
|
+
"./tanstack/server": {
|
|
47
|
+
"types": "./dist/tanstack/server.d.ts",
|
|
48
|
+
"default": "./dist/tanstack/server.js"
|
|
49
|
+
},
|
|
42
50
|
"./uploads": {
|
|
43
51
|
"types": "./dist/uploads/index.d.ts",
|
|
44
52
|
"default": "./dist/uploads/index.js"
|
|
@@ -64,6 +72,8 @@
|
|
|
64
72
|
},
|
|
65
73
|
"devDependencies": {
|
|
66
74
|
"@changesets/cli": "^2.31.1",
|
|
75
|
+
"@tanstack/react-query": "^5.101.4",
|
|
76
|
+
"@tanstack/react-start": "^1.168.32",
|
|
67
77
|
"@types/node": "^26.0.0",
|
|
68
78
|
"@types/nodemailer": "^8.0.1",
|
|
69
79
|
"nodemailer": "^9.0.3",
|
|
@@ -75,10 +85,18 @@
|
|
|
75
85
|
"vitest": "^4.1.10"
|
|
76
86
|
},
|
|
77
87
|
"peerDependencies": {
|
|
88
|
+
"@tanstack/react-query": ">=5 <6",
|
|
89
|
+
"@tanstack/react-start": ">=1 <2",
|
|
78
90
|
"nodemailer": ">=9 <10",
|
|
79
91
|
"tus-js-client": ">=4 <5"
|
|
80
92
|
},
|
|
81
93
|
"peerDependenciesMeta": {
|
|
94
|
+
"@tanstack/react-query": {
|
|
95
|
+
"optional": true
|
|
96
|
+
},
|
|
97
|
+
"@tanstack/react-start": {
|
|
98
|
+
"optional": true
|
|
99
|
+
},
|
|
82
100
|
"nodemailer": {
|
|
83
101
|
"optional": true
|
|
84
102
|
},
|