@towa-digital/storyblok-nuxt-cv 0.1.4 → 0.2.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 +3 -2
- package/dist/module.d.mts +12 -6
- package/dist/module.json +1 -1
- package/dist/module.mjs +10 -10
- package/dist/runtime/server/utils/cv.js +3 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -69,9 +69,10 @@ Then create a **story publish webhook** in Storyblok
|
|
|
69
69
|
export default defineNuxtConfig({
|
|
70
70
|
storyblokCv: {
|
|
71
71
|
token: undefined, // default: auto-detected from @storyblok/nuxt config; env NUXT_STORYBLOK_CV_TOKEN
|
|
72
|
-
region: 'eu', // eu | us | ap | ca | cn
|
|
72
|
+
region: 'eu', // eu | us | ap | ca | cn
|
|
73
|
+
endpoint: undefined, // full API endpoint incl. /v2 (like @storyblok/nuxt); overrides region — for proxied spaces
|
|
73
74
|
storage: 'storyblok-cv', // nitro storage mount name
|
|
74
|
-
|
|
75
|
+
statusRoute: '/api/storyblok-cv', // GET current cv; false to disable
|
|
75
76
|
webhook: true, // built-in route /api/storyblok-cv-webhook; string = custom route; false = use refreshStoryblokCv() yourself
|
|
76
77
|
ttl: false, // e.g. 60_000 — background refresh when the stored cv is older (serverless/multi-instance)
|
|
77
78
|
onStartup: true, // populate the store once at boot
|
package/dist/module.d.mts
CHANGED
|
@@ -11,18 +11,24 @@ interface ModuleOptions {
|
|
|
11
11
|
* Overridable at runtime via `NUXT_STORYBLOK_CV_TOKEN`.
|
|
12
12
|
*/
|
|
13
13
|
token?: string;
|
|
14
|
-
/** Storyblok API region. Ignored when `
|
|
14
|
+
/** Storyblok API region. Ignored when `endpoint` is set. */
|
|
15
15
|
region?: 'eu' | 'us' | 'ap' | 'ca' | 'cn';
|
|
16
|
-
/**
|
|
17
|
-
|
|
16
|
+
/**
|
|
17
|
+
* Full Storyblok API endpoint **including the version segment**, exactly as
|
|
18
|
+
* `@storyblok/nuxt` / storyblok-js-client expect it (e.g.
|
|
19
|
+
* `https://api.storyblok.com/v2`). Set this for proxied spaces — pass the
|
|
20
|
+
* same value as the render client's `apiOptions.endpoint`, no surgery. When
|
|
21
|
+
* unset, derived from `region`.
|
|
22
|
+
*/
|
|
23
|
+
endpoint?: string;
|
|
18
24
|
/**
|
|
19
25
|
* Nitro storage mount the `cv` is stored under. The default (unmounted) is
|
|
20
26
|
* per-process memory — fine for a single Node process. For PM2 cluster mount
|
|
21
27
|
* an `fs` driver, for multi-node mount Redis, in the host's `nitro.storage`.
|
|
22
28
|
*/
|
|
23
29
|
storage?: string;
|
|
24
|
-
/** GET
|
|
25
|
-
|
|
30
|
+
/** GET route exposing the current `cv` (client re-pins, debugging). `false` disables. */
|
|
31
|
+
statusRoute?: string | false;
|
|
26
32
|
/**
|
|
27
33
|
* Built-in Storyblok publish webhook. `true` registers it at
|
|
28
34
|
* `/api/storyblok-cv-webhook`, a string sets the route, `false` disables it —
|
|
@@ -46,7 +52,7 @@ declare module '@nuxt/schema' {
|
|
|
46
52
|
interface RuntimeConfig {
|
|
47
53
|
storyblokCv: {
|
|
48
54
|
token: string;
|
|
49
|
-
|
|
55
|
+
endpoint: string;
|
|
50
56
|
storage: string;
|
|
51
57
|
ttl: number;
|
|
52
58
|
onStartup: boolean;
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { defineNuxtModule, createResolver, useLogger, addServerHandler, addServerPlugin, addServerImports, addPlugin, addTypeTemplate } from '@nuxt/kit';
|
|
2
2
|
import { defu } from 'defu';
|
|
3
3
|
|
|
4
|
-
const
|
|
5
|
-
eu: "https://api.storyblok.com",
|
|
6
|
-
us: "https://api-us.storyblok.com",
|
|
7
|
-
ap: "https://api-ap.storyblok.com",
|
|
8
|
-
ca: "https://api-ca.storyblok.com",
|
|
9
|
-
cn: "https://api.storyblokchina.cn"
|
|
4
|
+
const API_ENDPOINTS = {
|
|
5
|
+
eu: "https://api.storyblok.com/v2",
|
|
6
|
+
us: "https://api-us.storyblok.com/v2",
|
|
7
|
+
ap: "https://api-ap.storyblok.com/v2",
|
|
8
|
+
ca: "https://api-ca.storyblok.com/v2",
|
|
9
|
+
cn: "https://api.storyblokchina.cn/v2"
|
|
10
10
|
};
|
|
11
11
|
const module$1 = defineNuxtModule({
|
|
12
12
|
meta: {
|
|
@@ -19,7 +19,7 @@ const module$1 = defineNuxtModule({
|
|
|
19
19
|
debug: false,
|
|
20
20
|
region: "eu",
|
|
21
21
|
storage: "storyblok-cv",
|
|
22
|
-
|
|
22
|
+
statusRoute: "/api/storyblok-cv",
|
|
23
23
|
webhook: true,
|
|
24
24
|
ttl: false,
|
|
25
25
|
onStartup: true
|
|
@@ -42,7 +42,7 @@ const module$1 = defineNuxtModule({
|
|
|
42
42
|
nuxt.options.runtimeConfig.storyblokCv,
|
|
43
43
|
{
|
|
44
44
|
token: token ?? "",
|
|
45
|
-
|
|
45
|
+
endpoint: options.endpoint || API_ENDPOINTS[options.region] || API_ENDPOINTS.eu,
|
|
46
46
|
storage: options.storage,
|
|
47
47
|
ttl: options.ttl === false ? 0 : options.ttl ?? 0,
|
|
48
48
|
onStartup: options.onStartup !== false,
|
|
@@ -53,9 +53,9 @@ const module$1 = defineNuxtModule({
|
|
|
53
53
|
middleware: true,
|
|
54
54
|
handler: resolver.resolve("./runtime/server/middleware/cv")
|
|
55
55
|
});
|
|
56
|
-
if (options.
|
|
56
|
+
if (options.statusRoute) {
|
|
57
57
|
addServerHandler({
|
|
58
|
-
route: options.
|
|
58
|
+
route: options.statusRoute,
|
|
59
59
|
method: "get",
|
|
60
60
|
handler: resolver.resolve("./runtime/server/api/cv.get")
|
|
61
61
|
});
|
|
@@ -3,12 +3,12 @@ import { useRuntimeConfig, useStorage } from "#imports";
|
|
|
3
3
|
const KEY = "current";
|
|
4
4
|
const store = () => useStorage(useRuntimeConfig().storyblokCv.storage);
|
|
5
5
|
export async function getLiveStoryblokCv() {
|
|
6
|
-
const { token,
|
|
6
|
+
const { token, endpoint } = useRuntimeConfig().storyblokCv;
|
|
7
7
|
if (!token) {
|
|
8
8
|
throw new Error("[storyblok-cv] no access token configured");
|
|
9
9
|
}
|
|
10
|
-
const response = await $fetch("
|
|
11
|
-
baseURL:
|
|
10
|
+
const response = await $fetch("cdn/spaces/me", {
|
|
11
|
+
baseURL: endpoint,
|
|
12
12
|
query: { token }
|
|
13
13
|
});
|
|
14
14
|
return response?.space?.version ?? 0;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@towa-digital/storyblok-nuxt-cv",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Keeps Storyblok published content fresh on long-running Nuxt servers by bridging the live cache version (cv) to the render client — no redeploy after publish.",
|
|
5
5
|
"repository": "github:towa-digital/storyblok-nuxt-cv",
|
|
6
6
|
"author": {
|