easy-cms 0.16.1 → 0.18.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/dist/bin.js +1 -1
- package/dist/{chunk-MXEUQZMV.js → chunk-3INW3DQG.js} +8 -2
- package/dist/index.d.ts +2 -1
- package/dist/index.js +1 -1
- package/package.json +4 -4
package/dist/bin.js
CHANGED
|
@@ -22,13 +22,16 @@ import { pipeline } from "stream/promises";
|
|
|
22
22
|
import { createAdminHandler } from "@easy-cms/admin";
|
|
23
23
|
import {
|
|
24
24
|
createEasyCMS,
|
|
25
|
-
createRestHandler
|
|
25
|
+
createRestHandler,
|
|
26
|
+
createRootEndpointHandler
|
|
26
27
|
} from "@easy-cms/core";
|
|
27
28
|
function createStandaloneHandler(cms) {
|
|
28
29
|
const config = cms.config;
|
|
29
30
|
const adminPath = `/${config.admin.path.replace(/^\/+|\/+$/g, "")}`;
|
|
30
31
|
const clientIps = /* @__PURE__ */ new WeakMap();
|
|
31
|
-
const
|
|
32
|
+
const getClientIp = (request) => clientIps.get(request);
|
|
33
|
+
const api = createRestHandler(cms, { getClientIp });
|
|
34
|
+
const rootEndpoints = createRootEndpointHandler(cms, { getClientIp });
|
|
32
35
|
const admin = createAdminHandler({
|
|
33
36
|
basePath: adminPath,
|
|
34
37
|
apiPath: config.routes.api,
|
|
@@ -46,6 +49,9 @@ function createStandaloneHandler(cms) {
|
|
|
46
49
|
if (under(pathname, adminPath)) return admin(request);
|
|
47
50
|
if (pathname === "/healthz")
|
|
48
51
|
return new Response("ok", { headers: { "cache-control": "no-store" } });
|
|
52
|
+
clientIps.set(request, clientIp);
|
|
53
|
+
const endpoint = await rootEndpoints(request);
|
|
54
|
+
if (endpoint) return endpoint;
|
|
49
55
|
if (pathname === "/")
|
|
50
56
|
return new Response(null, { status: 302, headers: { location: `${adminPath}/` } });
|
|
51
57
|
return Response.json({ message: "Not found" }, { status: 404 });
|
package/dist/index.d.ts
CHANGED
|
@@ -8,7 +8,8 @@ interface StandaloneOptions {
|
|
|
8
8
|
type Handler = (request: Request, clientIp?: string) => Promise<Response>;
|
|
9
9
|
/**
|
|
10
10
|
* One Web-standard handler for the whole standalone server: the REST API at `routes.api`, the
|
|
11
|
-
* admin at `admin.path`,
|
|
11
|
+
* admin at `admin.path`, `/healthz` for load balancers, and endpoints marked `root` (such as a
|
|
12
|
+
* plugin's `/robots.txt`). `/` redirects to the admin.
|
|
12
13
|
*/
|
|
13
14
|
declare function createStandaloneHandler<C extends Config>(cms: EasyCMS<C>): Handler;
|
|
14
15
|
interface StartOptions extends StandaloneOptions {
|
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "easy-cms",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.18.0",
|
|
4
4
|
"description": "Command line tool for Easy CMS",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -21,11 +21,11 @@
|
|
|
21
21
|
"node": ">=22.12"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@easy-cms/core": "^0.
|
|
25
|
-
"@easy-cms/admin": "^0.
|
|
24
|
+
"@easy-cms/core": "^0.18.0",
|
|
25
|
+
"@easy-cms/admin": "^0.18.0"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"@easy-cms/db-sqlite": "^0.
|
|
28
|
+
"@easy-cms/db-sqlite": "^0.18.0"
|
|
29
29
|
},
|
|
30
30
|
"publishConfig": {
|
|
31
31
|
"access": "public"
|