From 9ba535845a17287bf82f7aec005764d9e8413cda Mon Sep 17 00:00:00 2001 From: Tim Mikeladze Date: Thu, 23 May 2024 02:41:56 +0200 Subject: [PATCH] docs: update docs --- README.md | 10 ++ examples/nextjs-example/package.json | 9 +- examples/nextjs-example/pnpm-lock.yaml | 153 ++++++++++++++++++ .../src/app/api/next-flag/nf.ts | 5 + 4 files changed, 173 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 1af3d49..437b766 100644 --- a/README.md +++ b/README.md @@ -85,6 +85,7 @@ Finally, let's write some code to use the `next-flag` package. ```ts // src/app/api/next-flag/nf.ts import { NextFlag } from 'next-flag'; +import { revalidateTag, unstable_cache } from 'next/cache'; export const nf = new NextFlag({ paths: [ @@ -93,6 +94,10 @@ export const nf = new NextFlag({ issue: 123, }, ], + cache: { + revalidateTag, + unstable_cache, + }, }); ``` @@ -249,6 +254,7 @@ NEXT_PUBLIC_NEXT_FLAG_ENDPOINT="https:///api/next-flag" ```ts // src/app/api/next-flag/nf.ts import { NextFlag } from 'next-flag'; +import { revalidateTag, unstable_cache } from 'next/cache'; export const nf = new NextFlag({ paths: [ @@ -263,6 +269,10 @@ export const nf = new NextFlag({ issue: 124, }, ], + cache: { + revalidateTag, + unstable_cache, + }, }); ``` diff --git a/examples/nextjs-example/package.json b/examples/nextjs-example/package.json index 7f1d85a..7b3c700 100644 --- a/examples/nextjs-example/package.json +++ b/examples/nextjs-example/package.json @@ -9,16 +9,17 @@ "lint": "next lint" }, "dependencies": { + "next": "14.2.3", + "next-flag": "^0.0.1", "react": "^18", - "react-dom": "^18", - "next": "14.2.3" + "react-dom": "^18" }, "devDependencies": { - "typescript": "^5", "@types/node": "^20", "@types/react": "^18", "@types/react-dom": "^18", "eslint": "^8", - "eslint-config-next": "14.2.3" + "eslint-config-next": "14.2.3", + "typescript": "^5" } } diff --git a/examples/nextjs-example/pnpm-lock.yaml b/examples/nextjs-example/pnpm-lock.yaml index 0d4286e..aedf586 100644 --- a/examples/nextjs-example/pnpm-lock.yaml +++ b/examples/nextjs-example/pnpm-lock.yaml @@ -11,6 +11,9 @@ importers: next: specifier: 14.2.3 version: 14.2.3(react-dom@18.3.1(react@18.3.1))(react@18.3.1) + next-flag: + specifier: ^0.0.1 + version: 0.0.1(react-dom@18.3.1(react@18.3.1))(react@18.3.1) react: specifier: ^18 version: 18.3.1 @@ -148,6 +151,58 @@ packages: resolution: {integrity: sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg==} engines: {node: '>= 8'} + '@octokit/auth-token@4.0.0': + resolution: {integrity: sha512-tY/msAuJo6ARbK6SPIxZrPBms3xPbfwBrulZe0Wtr/DIY9lje2HeV1uoebShn6mx7SjCHif6EjMvoREj+gZ+SA==} + engines: {node: '>= 18'} + + '@octokit/core@5.2.0': + resolution: {integrity: sha512-1LFfa/qnMQvEOAdzlQymH0ulepxbxnCYAKJZfMci/5XJyIHWgEYnDmgnKakbTh7CH2tFQ5O60oYDvns4i9RAIg==} + engines: {node: '>= 18'} + + '@octokit/endpoint@9.0.5': + resolution: {integrity: sha512-ekqR4/+PCLkEBF6qgj8WqJfvDq65RH85OAgrtnVp1mSxaXF03u2xW/hUdweGS5654IlC0wkNYC18Z50tSYTAFw==} + engines: {node: '>= 18'} + + '@octokit/graphql@7.1.0': + resolution: {integrity: sha512-r+oZUH7aMFui1ypZnAvZmn0KSqAUgE1/tUXIWaqUCa1758ts/Jio84GZuzsvUkme98kv0WFY8//n0J1Z+vsIsQ==} + engines: {node: '>= 18'} + + '@octokit/openapi-types@22.2.0': + resolution: {integrity: sha512-QBhVjcUa9W7Wwhm6DBFu6ZZ+1/t/oYxqc2tp81Pi41YNuJinbFRx8B133qVOrAaBbF7D/m0Et6f9/pZt9Rc+tg==} + + '@octokit/plugin-paginate-rest@11.3.1': + resolution: {integrity: sha512-ryqobs26cLtM1kQxqeZui4v8FeznirUsksiA+RYemMPJ7Micju0WSkv50dBksTuZks9O5cg4wp+t8fZ/cLY56g==} + engines: {node: '>= 18'} + peerDependencies: + '@octokit/core': '5' + + '@octokit/plugin-request-log@4.0.1': + resolution: {integrity: sha512-GihNqNpGHorUrO7Qa9JbAl0dbLnqJVrV8OXe2Zm5/Y4wFkZQDfTreBzVmiRfJVfE4mClXdihHnbpyyO9FSX4HA==} + engines: {node: '>= 18'} + peerDependencies: + '@octokit/core': '5' + + '@octokit/plugin-rest-endpoint-methods@13.2.2': + resolution: {integrity: sha512-EI7kXWidkt3Xlok5uN43suK99VWqc8OaIMktY9d9+RNKl69juoTyxmLoWPIZgJYzi41qj/9zU7G/ljnNOJ5AFA==} + engines: {node: '>= 18'} + peerDependencies: + '@octokit/core': ^5 + + '@octokit/request-error@5.1.0': + resolution: {integrity: sha512-GETXfE05J0+7H2STzekpKObFe765O5dlAKUTLNGeH+x47z7JjXHfsHKo5z21D/o/IOZTUEI6nyWyR+bZVP/n5Q==} + engines: {node: '>= 18'} + + '@octokit/request@8.4.0': + resolution: {integrity: sha512-9Bb014e+m2TgBeEJGEbdplMVWwPmL1FPtggHQRkV+WVsMggPtEkLKPlcVYm/o8xKLkpJ7B+6N8WfQMtDLX2Dpw==} + engines: {node: '>= 18'} + + '@octokit/rest@20.1.1': + resolution: {integrity: sha512-MB4AYDsM5jhIHro/dq4ix1iWTLGToIGk6cWF5L6vanFaMble5jTX/UBQyiv05HsWnwUtY8JrfHy2LWfKwihqMw==} + engines: {node: '>= 18'} + + '@octokit/types@13.5.0': + resolution: {integrity: sha512-HdqWTf5Z3qwDVlzCrP8UJquMwunpDiMPt5er+QjGzL4hqr/vBVY/MauQgS1xWxCDT1oMx1EULyqxncdCY/NVSQ==} + '@pkgjs/parseargs@0.11.0': resolution: {integrity: sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg==} engines: {node: '>=14'} @@ -300,6 +355,9 @@ packages: balanced-match@1.0.2: resolution: {integrity: sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==} + before-after-hook@2.2.3: + resolution: {integrity: sha512-NzUnlZexiaH/46WDhANlyR2bXRopNg4F/zuSA3OpZnllCUgRaOF2znDioDWrmbNVsuZk6l9pMquQB38cfBZwkQ==} + brace-expansion@1.1.11: resolution: {integrity: sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==} @@ -392,6 +450,9 @@ packages: resolution: {integrity: sha512-8QmQKqEASLd5nx0U1B1okLElbUuuttJ/AnYmRXbbbGDWh6uS208EjD4Xqq/I9wK7u0v6O08XhTWnt5XtEbR6Dg==} engines: {node: '>= 0.4'} + deprecation@2.3.1: + resolution: {integrity: sha512-xmHIy4F3scKVwMsQ4WnVaS8bHOx0DmVwRywosKhaILI0ywMDWPtBSku2HNxRvF7jtwDRsoEwYQSfbxj8b7RlJQ==} + dequal@2.0.3: resolution: {integrity: sha512-0je+qPKHEMohvfRTCEo3CrPG6cAzAYgmzKyxRiYSSDkS6eGJdyVJm7WaYA5ECaAD9wLB2T4EEeymA5aFVcYXCA==} engines: {node: '>=6'} @@ -918,6 +979,13 @@ packages: natural-compare@1.4.0: resolution: {integrity: sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==} + next-flag@0.0.1: + resolution: {integrity: sha512-GiWsoXR+d3yjv3OrIvkW+VzTGGGr2T6TMzQOgeNlW+UL+wfzRVZDyB+bDrfkPomDALwqpC31Ku65kXjoqbqeAQ==} + engines: {node: '>=18.0.0'} + peerDependencies: + react: '>=17' + react-dom: '>=17' + next@14.2.3: resolution: {integrity: sha512-dowFkFTR8v79NPJO4QsBUtxv0g9BrS/phluVpMAt2ku7H+cbcBJlopXjkWlwxrk/xGqMemr7JkGPGemPrLLX7A==} engines: {node: '>=18.17.0'} @@ -1143,6 +1211,10 @@ packages: resolution: {integrity: sha512-itJW8lvSA0TXEphiRoawsCksnlf8SyvmFzIhltqAHluXd88pkCd+cXJVHTDwdCr0IzwptSm035IHQktUu1QUMg==} engines: {node: '>=0.10.0'} + space-slug@2.0.2: + resolution: {integrity: sha512-qwr8SOyl62Zpv9fsuh6r371yq7SriL7kUgqLAuWYcbDvw1pIYtD7jgoCEP3PSXfs8CxtHOK9vqmh+4Nln91pOA==} + engines: {node: '>=14.0.0'} + streamsearch@1.1.0: resolution: {integrity: sha512-Mcc5wHehp9aXz1ax6bZUyY5afg9u2rv5cqQI3mRrYkGC8rW2hM02jWuwjtL++LS5qinSyhj2QfLyNsuc+VsExg==} engines: {node: '>=10.0.0'} @@ -1265,6 +1337,9 @@ packages: undici-types@5.26.5: resolution: {integrity: sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==} + universal-user-agent@6.0.1: + resolution: {integrity: sha512-yCzhz6FN2wU1NiiQRogkTQszlQSlpWaw8SvVegAc+bDxbzHgh1vX8uIe8OYyMH6DwH+sdTJsgMl36+mSMdRJIQ==} + uri-js@4.4.1: resolution: {integrity: sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==} @@ -1402,6 +1477,69 @@ snapshots: '@nodelib/fs.scandir': 2.1.5 fastq: 1.17.1 + '@octokit/auth-token@4.0.0': {} + + '@octokit/core@5.2.0': + dependencies: + '@octokit/auth-token': 4.0.0 + '@octokit/graphql': 7.1.0 + '@octokit/request': 8.4.0 + '@octokit/request-error': 5.1.0 + '@octokit/types': 13.5.0 + before-after-hook: 2.2.3 + universal-user-agent: 6.0.1 + + '@octokit/endpoint@9.0.5': + dependencies: + '@octokit/types': 13.5.0 + universal-user-agent: 6.0.1 + + '@octokit/graphql@7.1.0': + dependencies: + '@octokit/request': 8.4.0 + '@octokit/types': 13.5.0 + universal-user-agent: 6.0.1 + + '@octokit/openapi-types@22.2.0': {} + + '@octokit/plugin-paginate-rest@11.3.1(@octokit/core@5.2.0)': + dependencies: + '@octokit/core': 5.2.0 + '@octokit/types': 13.5.0 + + '@octokit/plugin-request-log@4.0.1(@octokit/core@5.2.0)': + dependencies: + '@octokit/core': 5.2.0 + + '@octokit/plugin-rest-endpoint-methods@13.2.2(@octokit/core@5.2.0)': + dependencies: + '@octokit/core': 5.2.0 + '@octokit/types': 13.5.0 + + '@octokit/request-error@5.1.0': + dependencies: + '@octokit/types': 13.5.0 + deprecation: 2.3.1 + once: 1.4.0 + + '@octokit/request@8.4.0': + dependencies: + '@octokit/endpoint': 9.0.5 + '@octokit/request-error': 5.1.0 + '@octokit/types': 13.5.0 + universal-user-agent: 6.0.1 + + '@octokit/rest@20.1.1': + dependencies: + '@octokit/core': 5.2.0 + '@octokit/plugin-paginate-rest': 11.3.1(@octokit/core@5.2.0) + '@octokit/plugin-request-log': 4.0.1(@octokit/core@5.2.0) + '@octokit/plugin-rest-endpoint-methods': 13.2.2(@octokit/core@5.2.0) + + '@octokit/types@13.5.0': + dependencies: + '@octokit/openapi-types': 22.2.0 + '@pkgjs/parseargs@0.11.0': optional: true @@ -1590,6 +1728,8 @@ snapshots: balanced-match@1.0.2: {} + before-after-hook@2.2.3: {} + brace-expansion@1.1.11: dependencies: balanced-match: 1.0.2 @@ -1684,6 +1824,8 @@ snapshots: has-property-descriptors: 1.0.2 object-keys: 1.1.1 + deprecation@2.3.1: {} + dequal@2.0.3: {} dir-glob@3.0.1: @@ -2363,6 +2505,13 @@ snapshots: natural-compare@1.4.0: {} + next-flag@0.0.1(react-dom@18.3.1(react@18.3.1))(react@18.3.1): + dependencies: + '@octokit/rest': 20.1.1 + react: 18.3.1 + react-dom: 18.3.1(react@18.3.1) + space-slug: 2.0.2 + next@14.2.3(react-dom@18.3.1(react@18.3.1))(react@18.3.1): dependencies: '@next/env': 14.2.3 @@ -2609,6 +2758,8 @@ snapshots: source-map-js@1.2.0: {} + space-slug@2.0.2: {} + streamsearch@1.1.0: {} string-width@4.2.3: @@ -2750,6 +2901,8 @@ snapshots: undici-types@5.26.5: {} + universal-user-agent@6.0.1: {} + uri-js@4.4.1: dependencies: punycode: 2.3.1 diff --git a/examples/nextjs-example/src/app/api/next-flag/nf.ts b/examples/nextjs-example/src/app/api/next-flag/nf.ts index 437e2fc..5478e73 100644 --- a/examples/nextjs-example/src/app/api/next-flag/nf.ts +++ b/examples/nextjs-example/src/app/api/next-flag/nf.ts @@ -1,4 +1,5 @@ import { NextFlag } from 'next-flag'; +import { revalidateTag, unstable_cache } from 'next/cache'; export const nf = new NextFlag({ paths: [ @@ -7,4 +8,8 @@ export const nf = new NextFlag({ issue: 3, }, ], + cache: { + revalidateTag, + unstable_cache, + }, });