@flyo/nitro-next 1.3.0 → 1.3.1
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 +39 -0
- package/dist/proxy.d.mts +4 -4
- package/dist/proxy.d.ts +4 -4
- package/dist/proxy.js +6 -7
- package/dist/proxy.js.map +1 -1
- package/dist/proxy.mjs +6 -7
- package/dist/proxy.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# @flyo/nitro-next
|
|
2
|
+
|
|
3
|
+
This directory contains the source code for the **@flyo/nitro-next** package - a Next.js integration library for connecting the Flyo Headless Content Hub into your Next.js projects.
|
|
4
|
+
|
|
5
|
+
## What's Included
|
|
6
|
+
|
|
7
|
+
- **Server Components**: Server-side rendering utilities for Flyo content
|
|
8
|
+
- **Client Components**: Client-side React components for interactive content
|
|
9
|
+
- **Proxy Utilities**: Image proxy and asset handling
|
|
10
|
+
- **Route Helpers**: Next.js App Router integration helpers for pages and entities
|
|
11
|
+
|
|
12
|
+
## Documentation
|
|
13
|
+
|
|
14
|
+
For complete documentation, installation instructions, and usage examples, please visit:
|
|
15
|
+
|
|
16
|
+
**https://github.com/flyocloud/nitro-next**
|
|
17
|
+
|
|
18
|
+
## Development
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
# Install dependencies
|
|
22
|
+
npm install
|
|
23
|
+
|
|
24
|
+
# Build the package
|
|
25
|
+
npm run build
|
|
26
|
+
|
|
27
|
+
# Run tests
|
|
28
|
+
npm test
|
|
29
|
+
|
|
30
|
+
# Development mode (watch)
|
|
31
|
+
npm run dev
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Package Structure
|
|
35
|
+
|
|
36
|
+
- `src/` - Source TypeScript files
|
|
37
|
+
- `dist/` - Built output (generated)
|
|
38
|
+
- `tsup.config.ts` - Build configuration
|
|
39
|
+
- `jest.config.js` - Test configuration
|
package/dist/proxy.d.mts
CHANGED
|
@@ -2,10 +2,10 @@ import { NextResponse } from 'next/server';
|
|
|
2
2
|
|
|
3
3
|
interface ProxyConfig {
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
6
|
-
* @default
|
|
5
|
+
* If live edit is enabled, caching is disabled
|
|
6
|
+
* @default false
|
|
7
7
|
*/
|
|
8
|
-
|
|
8
|
+
liveEdit?: boolean;
|
|
9
9
|
/**
|
|
10
10
|
* Server/CDN cache TTL in seconds
|
|
11
11
|
* @default 1200
|
|
@@ -28,7 +28,7 @@ interface ProxyConfig {
|
|
|
28
28
|
* import { createProxy } from '@flyo/nitro-next/proxy';
|
|
29
29
|
*
|
|
30
30
|
* export default createProxy({
|
|
31
|
-
*
|
|
31
|
+
* liveEdit: false,
|
|
32
32
|
* serverCacheTtl: 1200,
|
|
33
33
|
* clientCacheTtl: 900,
|
|
34
34
|
* });
|
package/dist/proxy.d.ts
CHANGED
|
@@ -2,10 +2,10 @@ import { NextResponse } from 'next/server';
|
|
|
2
2
|
|
|
3
3
|
interface ProxyConfig {
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
6
|
-
* @default
|
|
5
|
+
* If live edit is enabled, caching is disabled
|
|
6
|
+
* @default false
|
|
7
7
|
*/
|
|
8
|
-
|
|
8
|
+
liveEdit?: boolean;
|
|
9
9
|
/**
|
|
10
10
|
* Server/CDN cache TTL in seconds
|
|
11
11
|
* @default 1200
|
|
@@ -28,7 +28,7 @@ interface ProxyConfig {
|
|
|
28
28
|
* import { createProxy } from '@flyo/nitro-next/proxy';
|
|
29
29
|
*
|
|
30
30
|
* export default createProxy({
|
|
31
|
-
*
|
|
31
|
+
* liveEdit: false,
|
|
32
32
|
* serverCacheTtl: 1200,
|
|
33
33
|
* clientCacheTtl: 900,
|
|
34
34
|
* });
|
package/dist/proxy.js
CHANGED
|
@@ -27,24 +27,23 @@ module.exports = __toCommonJS(proxy_exports);
|
|
|
27
27
|
var import_server = require("next/server");
|
|
28
28
|
function createProxy(config2 = {}) {
|
|
29
29
|
const {
|
|
30
|
-
|
|
30
|
+
liveEdit = false,
|
|
31
31
|
serverCacheTtl = 1200,
|
|
32
32
|
clientCacheTtl = 900
|
|
33
33
|
} = config2;
|
|
34
34
|
return function proxy() {
|
|
35
35
|
const res = import_server.NextResponse.next();
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
if (liveEdit) {
|
|
37
|
+
res.headers.set("Vercel-CDN-Cache-Control", "no-store");
|
|
38
|
+
res.headers.set("CDN-Cache-Control", "no-store");
|
|
39
|
+
res.headers.set("Cache-Control", "no-store");
|
|
40
|
+
} else {
|
|
38
41
|
const cdn = serverCacheTtl > 0 ? `max-age=${serverCacheTtl}` : "no-store";
|
|
39
42
|
res.headers.set("Vercel-CDN-Cache-Control", cdn);
|
|
40
43
|
res.headers.set("CDN-Cache-Control", cdn);
|
|
41
44
|
if (clientCacheTtl > 0) {
|
|
42
45
|
res.headers.set("Cache-Control", `max-age=${clientCacheTtl}`);
|
|
43
46
|
}
|
|
44
|
-
} else {
|
|
45
|
-
res.headers.set("Vercel-CDN-Cache-Control", "no-store");
|
|
46
|
-
res.headers.set("CDN-Cache-Control", "no-store");
|
|
47
|
-
res.headers.set("Cache-Control", "no-store");
|
|
48
47
|
}
|
|
49
48
|
return res;
|
|
50
49
|
};
|
package/dist/proxy.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/proxy.ts"],"sourcesContent":["import { NextResponse } from 'next/server';\n\nexport interface ProxyConfig {\n /**\n *
|
|
1
|
+
{"version":3,"sources":["../src/proxy.ts"],"sourcesContent":["import { NextResponse } from 'next/server';\n\nexport interface ProxyConfig {\n /**\n * If live edit is enabled, caching is disabled\n * @default false\n */\n liveEdit?: boolean;\n /**\n * Server/CDN cache TTL in seconds\n * @default 1200\n */\n serverCacheTtl?: number;\n /**\n * Client browser cache TTL in seconds\n * @default 900\n */\n clientCacheTtl?: number;\n}\n\n/**\n * Nitro Next.js Proxy Factory\n * \n * Creates a Next.js middleware that handles cache control headers.\n * \n * @example\n * ```ts\n * // proxy.ts (project root or src/)\n * import { createProxy } from '@flyo/nitro-next/proxy';\n * \n * export default createProxy({\n * liveEdit: false,\n * serverCacheTtl: 1200,\n * clientCacheTtl: 900,\n * });\n * \n * // Next.js requires config to be defined directly in this file\n * export const config = {\n * matcher: ['/((?!_next/static|_next/image|favicon.ico).*)'],\n * };\n * ```\n */\nexport function createProxy(config: ProxyConfig = {}) {\n const {\n liveEdit = false,\n serverCacheTtl = 1200,\n clientCacheTtl = 900,\n } = config;\n\n return function proxy() {\n const res = NextResponse.next();\n\n if (liveEdit) {\n // Development or live edit mode - no caching\n res.headers.set('Vercel-CDN-Cache-Control', 'no-store');\n res.headers.set('CDN-Cache-Control', 'no-store');\n res.headers.set('Cache-Control', 'no-store');\n } else {\n // Production with caching enabled\n const cdn = serverCacheTtl > 0 ? `max-age=${serverCacheTtl}` : 'no-store';\n res.headers.set('Vercel-CDN-Cache-Control', cdn);\n res.headers.set('CDN-Cache-Control', cdn);\n\n if (clientCacheTtl > 0) {\n res.headers.set('Cache-Control', `max-age=${clientCacheTtl}`);\n }\n }\n\n return res;\n };\n}\n\n\n/**\n * Proxy matcher configuration\n * Applies to all routes except Next.js internal routes\n */\nexport const config = {\n matcher: ['/((?!_next/static|_next/image|favicon.ico).*)'],\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAA6B;AA0CtB,SAAS,YAAYA,UAAsB,CAAC,GAAG;AACpD,QAAM;AAAA,IACJ,WAAW;AAAA,IACX,iBAAiB;AAAA,IACjB,iBAAiB;AAAA,EACnB,IAAIA;AAEJ,SAAO,SAAS,QAAQ;AACtB,UAAM,MAAM,2BAAa,KAAK;AAE9B,QAAI,UAAU;AAEZ,UAAI,QAAQ,IAAI,4BAA4B,UAAU;AACtD,UAAI,QAAQ,IAAI,qBAAqB,UAAU;AAC/C,UAAI,QAAQ,IAAI,iBAAiB,UAAU;AAAA,IAC7C,OAAO;AAEL,YAAM,MAAM,iBAAiB,IAAI,WAAW,cAAc,KAAK;AAC/D,UAAI,QAAQ,IAAI,4BAA4B,GAAG;AAC/C,UAAI,QAAQ,IAAI,qBAAqB,GAAG;AAExC,UAAI,iBAAiB,GAAG;AACtB,YAAI,QAAQ,IAAI,iBAAiB,WAAW,cAAc,EAAE;AAAA,MAC9D;AAAA,IACF;AAEA,WAAO;AAAA,EACT;AACF;AAOO,IAAM,SAAS;AAAA,EACpB,SAAS,CAAC,+CAA+C;AAC3D;","names":["config"]}
|
package/dist/proxy.mjs
CHANGED
|
@@ -2,24 +2,23 @@
|
|
|
2
2
|
import { NextResponse } from "next/server";
|
|
3
3
|
function createProxy(config2 = {}) {
|
|
4
4
|
const {
|
|
5
|
-
|
|
5
|
+
liveEdit = false,
|
|
6
6
|
serverCacheTtl = 1200,
|
|
7
7
|
clientCacheTtl = 900
|
|
8
8
|
} = config2;
|
|
9
9
|
return function proxy() {
|
|
10
10
|
const res = NextResponse.next();
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
if (liveEdit) {
|
|
12
|
+
res.headers.set("Vercel-CDN-Cache-Control", "no-store");
|
|
13
|
+
res.headers.set("CDN-Cache-Control", "no-store");
|
|
14
|
+
res.headers.set("Cache-Control", "no-store");
|
|
15
|
+
} else {
|
|
13
16
|
const cdn = serverCacheTtl > 0 ? `max-age=${serverCacheTtl}` : "no-store";
|
|
14
17
|
res.headers.set("Vercel-CDN-Cache-Control", cdn);
|
|
15
18
|
res.headers.set("CDN-Cache-Control", cdn);
|
|
16
19
|
if (clientCacheTtl > 0) {
|
|
17
20
|
res.headers.set("Cache-Control", `max-age=${clientCacheTtl}`);
|
|
18
21
|
}
|
|
19
|
-
} else {
|
|
20
|
-
res.headers.set("Vercel-CDN-Cache-Control", "no-store");
|
|
21
|
-
res.headers.set("CDN-Cache-Control", "no-store");
|
|
22
|
-
res.headers.set("Cache-Control", "no-store");
|
|
23
22
|
}
|
|
24
23
|
return res;
|
|
25
24
|
};
|
package/dist/proxy.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/proxy.ts"],"sourcesContent":["import { NextResponse } from 'next/server';\n\nexport interface ProxyConfig {\n /**\n *
|
|
1
|
+
{"version":3,"sources":["../src/proxy.ts"],"sourcesContent":["import { NextResponse } from 'next/server';\n\nexport interface ProxyConfig {\n /**\n * If live edit is enabled, caching is disabled\n * @default false\n */\n liveEdit?: boolean;\n /**\n * Server/CDN cache TTL in seconds\n * @default 1200\n */\n serverCacheTtl?: number;\n /**\n * Client browser cache TTL in seconds\n * @default 900\n */\n clientCacheTtl?: number;\n}\n\n/**\n * Nitro Next.js Proxy Factory\n * \n * Creates a Next.js middleware that handles cache control headers.\n * \n * @example\n * ```ts\n * // proxy.ts (project root or src/)\n * import { createProxy } from '@flyo/nitro-next/proxy';\n * \n * export default createProxy({\n * liveEdit: false,\n * serverCacheTtl: 1200,\n * clientCacheTtl: 900,\n * });\n * \n * // Next.js requires config to be defined directly in this file\n * export const config = {\n * matcher: ['/((?!_next/static|_next/image|favicon.ico).*)'],\n * };\n * ```\n */\nexport function createProxy(config: ProxyConfig = {}) {\n const {\n liveEdit = false,\n serverCacheTtl = 1200,\n clientCacheTtl = 900,\n } = config;\n\n return function proxy() {\n const res = NextResponse.next();\n\n if (liveEdit) {\n // Development or live edit mode - no caching\n res.headers.set('Vercel-CDN-Cache-Control', 'no-store');\n res.headers.set('CDN-Cache-Control', 'no-store');\n res.headers.set('Cache-Control', 'no-store');\n } else {\n // Production with caching enabled\n const cdn = serverCacheTtl > 0 ? `max-age=${serverCacheTtl}` : 'no-store';\n res.headers.set('Vercel-CDN-Cache-Control', cdn);\n res.headers.set('CDN-Cache-Control', cdn);\n\n if (clientCacheTtl > 0) {\n res.headers.set('Cache-Control', `max-age=${clientCacheTtl}`);\n }\n }\n\n return res;\n };\n}\n\n\n/**\n * Proxy matcher configuration\n * Applies to all routes except Next.js internal routes\n */\nexport const config = {\n matcher: ['/((?!_next/static|_next/image|favicon.ico).*)'],\n};\n"],"mappings":";AAAA,SAAS,oBAAoB;AA0CtB,SAAS,YAAYA,UAAsB,CAAC,GAAG;AACpD,QAAM;AAAA,IACJ,WAAW;AAAA,IACX,iBAAiB;AAAA,IACjB,iBAAiB;AAAA,EACnB,IAAIA;AAEJ,SAAO,SAAS,QAAQ;AACtB,UAAM,MAAM,aAAa,KAAK;AAE9B,QAAI,UAAU;AAEZ,UAAI,QAAQ,IAAI,4BAA4B,UAAU;AACtD,UAAI,QAAQ,IAAI,qBAAqB,UAAU;AAC/C,UAAI,QAAQ,IAAI,iBAAiB,UAAU;AAAA,IAC7C,OAAO;AAEL,YAAM,MAAM,iBAAiB,IAAI,WAAW,cAAc,KAAK;AAC/D,UAAI,QAAQ,IAAI,4BAA4B,GAAG;AAC/C,UAAI,QAAQ,IAAI,qBAAqB,GAAG;AAExC,UAAI,iBAAiB,GAAG;AACtB,YAAI,QAAQ,IAAI,iBAAiB,WAAW,cAAc,EAAE;AAAA,MAC9D;AAAA,IACF;AAEA,WAAO;AAAA,EACT;AACF;AAOO,IAAM,SAAS;AAAA,EACpB,SAAS,CAAC,+CAA+C;AAC3D;","names":["config"]}
|