Compare commits

..

7 Commits

Author SHA1 Message Date
wobsoriano
230422bb16 docs: fix incorrect syntax 2023-08-23 12:49:09 -07:00
wobsoriano
057c8f8d3a docs: fix missing title 2023-08-23 12:48:32 -07:00
wobsoriano
9808375f31 docs: add response caching page 2023-08-23 12:46:22 -07:00
wobsoriano
8e893a2e30 chore(release): v0.10.11 2023-08-22 10:52:53 -07:00
wobsoriano
f74273190f bump local deps 2023-08-22 10:52:41 -07:00
wobsoriano
283400d41a chore(deps): bump ohash to 1.1.3 2023-08-22 10:51:54 -07:00
wobsoriano
5221dc0515 chore(deps): bump ofetch to 1.2.0 2023-08-22 10:51:29 -07:00
4 changed files with 142 additions and 25 deletions

View File

@@ -1,6 +1,22 @@
# Changelog
## v0.10.11
[compare changes](https://github.com/wobsoriano/trpc-nuxt/compare/v0.10.10...v0.10.11)
### 🩹 Fixes
- Add missing useLazyQuery type ([299ae55](https://github.com/wobsoriano/trpc-nuxt/commit/299ae55))
### 📖 Documentation
- Bump @nuxt-themes/docus to 1.14.6 ([f7eeb10](https://github.com/wobsoriano/trpc-nuxt/commit/f7eeb10))
### ❤️ Contributors
- Wobsoriano ([@wobsoriano](http://github.com/wobsoriano))
## v0.10.10
[compare changes](https://github.com/wobsoriano/trpc-nuxt/compare/v0.10.9...v0.10.10)

View File

@@ -0,0 +1,51 @@
---
title: Response Caching
---
## Response Caching
Your server responses must [satisfy some criteria](https://vercel.com/docs/concepts/functions/serverless-functions/edge-caching) in order for them to be cached (i.e. by Vercel's Edge Network). Please refer to [this section of the tRPC.io documentation](https://trpc.io/docs/caching) for more information.
The `createNuxtApiHandler` function conveniently allows you to specify a `responseMeta` function.
```ts [server/api/trpc/[trpc].ts]
import { createNuxtApiHandler } from 'trpc-nuxt'
import { appRouter } from '~/server/trpc/routers'
export default createNuxtApiHandler({
router: appRouter,
/**
* @link https://trpc.io/docs/caching#api-response-caching
*/
responseMeta(opts) {
// cache request for 1 day + revalidate once every second
const ONE_DAY_IN_SECONDS = 60 * 60 * 24;
return {
headers: {
'cache-control': `s-maxage=1, stale-while-revalidate=${ONE_DAY_IN_SECONDS}`,
},
};
},
})
```
You can also take advantage of Nitro's [Cache API](https://nitro.unjs.io/guide/cache#cache-api) if doing server-side calls:
```ts
import { appRouter } from '@/server/trpc/routers'
const caller = appRouter.createCaller({})
export default cachedEventHandler(async (event) => {
const { name } = getQuery(event)
const greeting = await caller.greeting({ name })
return {
greeting
}
}, {
swr: true, maxAge: 10
})
```

View File

@@ -3,7 +3,7 @@
"description": "End-to-end typesafe APIs in Nuxt applications.",
"type": "module",
"packageManager": "pnpm@8.6.9",
"version": "0.10.10",
"version": "0.10.11",
"license": "MIT",
"sideEffects": false,
"exports": {
@@ -40,14 +40,14 @@
},
"dependencies": {
"h3": "^1.8.0",
"ofetch": "^1.1.1",
"ohash": "^1.1.2"
"ofetch": "^1.2.0",
"ohash": "^1.1.3"
},
"devDependencies": {
"@nuxt/eslint-config": "^0.1.1",
"@trpc/client": "^10.37.1",
"@trpc/server": "^10.37.1",
"changelogen": "^0.5.4",
"changelogen": "^0.5.5",
"eslint": "^8.45.0",
"taze": "^0.11.2",
"tsup": "7.2.0",

92
pnpm-lock.yaml generated
View File

@@ -17,11 +17,11 @@ importers:
specifier: ^1.8.0
version: 1.8.0
ofetch:
specifier: ^1.1.1
version: 1.1.1
specifier: ^1.2.0
version: 1.2.0
ohash:
specifier: ^1.1.2
version: 1.1.2
specifier: ^1.1.3
version: 1.1.3
devDependencies:
'@nuxt/eslint-config':
specifier: ^0.1.1
@@ -33,8 +33,8 @@ importers:
specifier: 10.37.1
version: 10.37.1
changelogen:
specifier: ^0.5.4
version: 0.5.4
specifier: ^0.5.5
version: 0.5.5
eslint:
specifier: ^8.45.0
version: 8.45.0
@@ -1319,7 +1319,7 @@ packages:
listhen: 1.3.0
mdast-util-to-hast: 12.3.0
mdurl: 1.0.1
ohash: 1.1.2
ohash: 1.1.3
pathe: 1.1.1
property-information: 6.2.0
rehype-external-links: 2.1.0
@@ -1577,7 +1577,7 @@ packages:
mri: 1.2.0
nanoid: 4.0.2
node-fetch: 3.3.1
ofetch: 1.1.1
ofetch: 1.2.0
parse-git-config: 3.0.0
rc9: 2.1.1
std-env: 3.3.3
@@ -1615,7 +1615,7 @@ packages:
knitwork: 1.0.0
magic-string: 0.30.1
mlly: 1.4.0
ohash: 1.1.2
ohash: 1.1.3
pathe: 1.1.1
perfect-debounce: 1.0.0
pkg-types: 1.0.3
@@ -3326,7 +3326,7 @@ packages:
giget: 1.1.2
jiti: 1.19.1
mlly: 1.4.0
ohash: 1.1.2
ohash: 1.1.3
pathe: 1.1.1
perfect-debounce: 1.0.0
pkg-types: 1.0.3
@@ -3477,24 +3477,24 @@ packages:
tslib: 2.5.0
dev: true
/changelogen@0.5.4:
resolution: {integrity: sha512-ady7TjLW3ZKMWzVF8MG3vJRqLVctNTGIZnO5XoFbMbcC59BVNTZXNXL8tovB+OK6DHLk4NeTHUWzdwMaKmFyUA==}
/changelogen@0.5.5:
resolution: {integrity: sha512-IzgToIJ/R9NhVKmL+PW33ozYkv53bXvufDNUSH3GTKXq1iCHGgkbgbtqEWbo8tnWNnt7nPDpjL8PwSG2iS8RVw==}
hasBin: true
dependencies:
c12: 1.4.2
colorette: 2.0.20
consola: 3.2.3
convert-gitmoji: 0.1.3
execa: 7.1.1
execa: 8.0.1
mri: 1.2.0
node-fetch-native: 1.2.0
ofetch: 1.1.1
node-fetch-native: 1.3.1
ofetch: 1.2.0
open: 9.1.0
pathe: 1.1.1
pkg-types: 1.0.3
scule: 1.0.0
semver: 7.5.4
std-env: 3.3.3
std-env: 3.4.2
yaml: 2.3.1
transitivePeerDependencies:
- supports-color
@@ -3985,7 +3985,7 @@ packages:
dependencies:
bundle-name: 3.0.0
default-browser-id: 3.0.0
execa: 7.1.1
execa: 7.2.0
titleize: 3.0.0
dev: true
@@ -4049,6 +4049,7 @@ packages:
/destr@2.0.0:
resolution: {integrity: sha512-FJ9RDpf3GicEBvzI3jxc2XhHzbqD8p4ANw/1kPsFBfTvP1b7Gn/Lg1vO7R9J4IVgoMbyUmFrFGZafJ1hPZpvlg==}
dev: true
/destr@2.0.1:
resolution: {integrity: sha512-M1Ob1zPSIvlARiJUkKqvAZ3VAqQY6Jcuth/pBKQ2b1dX/Qx0OnJ8Vux6J2H5PTMQeRzWrrbTu70VxBfv/OPDJA==}
@@ -4563,6 +4564,21 @@ packages:
strip-final-newline: 3.0.0
dev: true
/execa@8.0.1:
resolution: {integrity: sha512-VyhnebXciFV2DESc+p6B+y0LjSm0krU4OgJN44qFAhBY0TJ+1V61tYD2+wHusZ6F9n5K+vl8k0sTy7PEfV4qpg==}
engines: {node: '>=16.17'}
dependencies:
cross-spawn: 7.0.3
get-stream: 8.0.1
human-signals: 5.0.0
is-stream: 3.0.0
merge-stream: 2.0.0
npm-run-path: 5.1.0
onetime: 6.0.0
signal-exit: 4.1.0
strip-final-newline: 3.0.0
dev: true
/extend@3.0.2:
resolution: {integrity: sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==}
dev: true
@@ -4877,6 +4893,11 @@ packages:
engines: {node: '>=10'}
dev: true
/get-stream@8.0.1:
resolution: {integrity: sha512-VaUJspBffn/LMCJVoMvSAdmscJyS1auj5Zulnn5UoYcY531UWmdwhRWkcGKnGU93m5HSXP9LP2usOryrBtQowA==}
engines: {node: '>=16'}
dev: true
/get-tsconfig@4.6.2:
resolution: {integrity: sha512-E5XrT4CbbXcXWy+1jChlZmrmCwd5KGx502kDCXJJ7y898TtWW9FwoG5HfOLVRKmlmDGkWN2HM9Ho+/Y8F0sJDg==}
dependencies:
@@ -5334,6 +5355,11 @@ packages:
engines: {node: '>=14.18.0'}
dev: true
/human-signals@5.0.0:
resolution: {integrity: sha512-AXcZb6vzzrFAUE61HnN4mpLqd/cSIwNQjtNWR0euPm6y0iqx3G4gOXaIDdtdDwZmhwe82LA6+zinmW4UBWVePQ==}
engines: {node: '>=16.17.0'}
dev: true
/humanize-ms@1.2.1:
resolution: {integrity: sha512-Fl70vYtsAFb/C06PTS9dZBo7ihau+Tu/DNCk/OyHhea07S+aeMWpFFkUaXRa8fI+ScZbEI8dfSxwY7gxZ9SAVQ==}
dependencies:
@@ -6828,8 +6854,8 @@ packages:
mlly: 1.4.0
mri: 1.2.0
node-fetch-native: 1.2.0
ofetch: 1.1.1
ohash: 1.1.2
ofetch: 1.2.0
ohash: 1.1.3
openapi-typescript: 6.3.2
pathe: 1.1.1
perfect-debounce: 1.0.0
@@ -6893,6 +6919,9 @@ packages:
/node-fetch-native@1.2.0:
resolution: {integrity: sha512-5IAMBTl9p6PaAjYCnMv5FmqIF6GcZnawAVnzaCG0rX2aYZJ4CxEkZNtVPuTRug7fL7wyM5BQYTlAzcyMPi6oTQ==}
/node-fetch-native@1.3.1:
resolution: {integrity: sha512-Z1q9inzb0c2+FuByzG5P2rHaNe3CEYLPqJywun4M/eOI0IHB3K9TDINfb1VA20vWFsW2rWUMaGIo87R3zwpMug==}
/node-fetch@2.6.9:
resolution: {integrity: sha512-DJm/CJkZkRjKKj4Zi4BsKVZh3ValV5IR5s7LVZnW+6YMh0W1BfNA8XSs6DLMGYlId5F3KnA70uu2qepcR08Qqg==}
engines: {node: 4.x || >=6.0.0}
@@ -7261,9 +7290,21 @@ packages:
destr: 2.0.0
node-fetch-native: 1.2.0
ufo: 1.2.0
dev: true
/ofetch@1.2.0:
resolution: {integrity: sha512-R8CM00cUpy/+PS8jyf/8ijTgKNSOhrAap77DJD5hck6eNChMvJkz/lmN7HaxZW0BlCIVMWmgmDYRwALsc5ypPw==}
dependencies:
destr: 2.0.1
node-fetch-native: 1.3.1
ufo: 1.2.0
/ohash@1.1.2:
resolution: {integrity: sha512-9CIOSq5945rI045GFtcO3uudyOkYVY1nyfFxVQp+9BRgslr8jPNiSSrsFGg/BNTUFOLqx0P5tng6G32brIPw0w==}
dev: true
/ohash@1.1.3:
resolution: {integrity: sha512-zuHHiGTYTA1sYJ/wZN+t5HKZaH23i4yI1HMwbuXm24Nid7Dv0KcuRlKoNKS9UNfAVSBlnGLcuQrnOKWOZoEGaw==}
/on-finished@2.4.1:
resolution: {integrity: sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg==}
@@ -7546,7 +7587,7 @@ packages:
defu: 6.1.2
magic-string: 0.30.2
nanoid: 4.0.2
ohash: 1.1.2
ohash: 1.1.3
paneer: 0.1.0
pathe: 1.1.1
postcss-custom-properties: 13.1.4(postcss@8.4.25)
@@ -8547,6 +8588,11 @@ packages:
engines: {node: '>=14'}
dev: true
/signal-exit@4.1.0:
resolution: {integrity: sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==}
engines: {node: '>=14'}
dev: true
/sigstore@1.5.0:
resolution: {integrity: sha512-i3nhvdobiPj8XrXNIggjeur6+A5iAQ4f+r1bR5SGitFJBbthy/6c7Fz0h+kY70Wua1FSMdDr/UEhXSVRXNpynw==}
engines: {node: ^14.17.0 || ^16.13.0 || >=18.0.0}
@@ -8732,6 +8778,10 @@ packages:
resolution: {integrity: sha512-Rz6yejtVyWnVjC1RFvNmYL10kgjC49EOghxWn0RFqlCHGFpQx+Xe7yW3I4ceK1SGrWIGMjD5Kbue8W/udkbMJg==}
dev: true
/std-env@3.4.2:
resolution: {integrity: sha512-Cw6eJDX9AxEEL0g5pYj8Zx9KXtDf60rxwS2ze0HBanS0aKhj1sBlzcsmg+R0qYy8byFa854/yR2X5ZmBSClVmg==}
dev: true
/streamsearch@1.1.0:
resolution: {integrity: sha512-Mcc5wHehp9aXz1ax6bZUyY5afg9u2rv5cqQI3mRrYkGC8rW2hM02jWuwjtL++LS5qinSyhj2QfLyNsuc+VsExg==}
engines: {node: '>=10.0.0'}
@@ -9602,7 +9652,7 @@ packages:
lru-cache: 10.0.0
mri: 1.2.0
node-fetch-native: 1.2.0
ofetch: 1.1.1
ofetch: 1.2.0
ufo: 1.2.0
transitivePeerDependencies:
- supports-color