easy-cms 0.16.0 → 0.17.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  run
4
- } from "./chunk-MXEUQZMV.js";
4
+ } from "./chunk-3INW3DQG.js";
5
5
 
6
6
  // src/bin.ts
7
7
  process.exitCode = await run(process.argv.slice(2));
@@ -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 api = createRestHandler(cms, { getClientIp: (request) => clientIps.get(request) });
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`, and `/healthz` for load balancers. `/` redirects to the admin.
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
@@ -2,7 +2,7 @@ import {
2
2
  createStandaloneHandler,
3
3
  run,
4
4
  startServer
5
- } from "./chunk-MXEUQZMV.js";
5
+ } from "./chunk-3INW3DQG.js";
6
6
  export {
7
7
  createStandaloneHandler,
8
8
  run,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "easy-cms",
3
- "version": "0.16.0",
3
+ "version": "0.17.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.16.0",
25
- "@easy-cms/admin": "^0.16.0"
24
+ "@easy-cms/core": "^0.17.0",
25
+ "@easy-cms/admin": "^0.17.0"
26
26
  },
27
27
  "devDependencies": {
28
- "@easy-cms/db-sqlite": "^0.16.0"
28
+ "@easy-cms/db-sqlite": "^0.17.0"
29
29
  },
30
30
  "publishConfig": {
31
31
  "access": "public"