easy-cms 1.5.0 → 1.7.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-WCISVCEZ.js → chunk-BKK4GU35.js} +29 -12
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/package.json +4 -4
package/dist/bin.js
CHANGED
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
ConfigError,
|
|
10
10
|
createEasyCMS as createEasyCMS2,
|
|
11
11
|
EasyCMSError,
|
|
12
|
+
jsonLogger,
|
|
12
13
|
loadConfig,
|
|
13
14
|
ValidationError,
|
|
14
15
|
warnDeprecated
|
|
@@ -17,6 +18,7 @@ import {
|
|
|
17
18
|
copyDatabase,
|
|
18
19
|
decryptBackup,
|
|
19
20
|
generateTypes,
|
|
21
|
+
logFormat,
|
|
20
22
|
writeBackupFile
|
|
21
23
|
} from "@easy-cms/core/internal";
|
|
22
24
|
|
|
@@ -30,7 +32,11 @@ import {
|
|
|
30
32
|
createEasyCMS,
|
|
31
33
|
createRestHandler
|
|
32
34
|
} from "@easy-cms/core";
|
|
33
|
-
import {
|
|
35
|
+
import {
|
|
36
|
+
createRootEndpointHandler,
|
|
37
|
+
forwardedClientIp,
|
|
38
|
+
healthResponse
|
|
39
|
+
} from "@easy-cms/core/internal";
|
|
34
40
|
function createStandaloneHandler(cms, options = {}) {
|
|
35
41
|
const config = cms.config;
|
|
36
42
|
const adminPath = `/${config.admin.path.replace(/^\/+|\/+$/g, "")}`;
|
|
@@ -47,8 +53,8 @@ function createStandaloneHandler(cms, options = {}) {
|
|
|
47
53
|
return api(request);
|
|
48
54
|
}
|
|
49
55
|
if (under(pathname, adminPath)) return admin(request);
|
|
50
|
-
if (pathname === "/healthz")
|
|
51
|
-
return
|
|
56
|
+
if (pathname === "/healthz" || pathname === "/readyz")
|
|
57
|
+
return healthResponse(pathname === "/healthz" ? "healthz" : "readyz", cms);
|
|
52
58
|
clientIps.set(request, clientIp);
|
|
53
59
|
const endpoint = await rootEndpoints(request);
|
|
54
60
|
if (endpoint) return endpoint;
|
|
@@ -113,7 +119,7 @@ async function startServer(options) {
|
|
|
113
119
|
await handler(toWebRequest(req, trustProxy), clientIpOf(req, trustProxy))
|
|
114
120
|
);
|
|
115
121
|
} catch (error) {
|
|
116
|
-
logger.error(`Request failed: ${error.message}
|
|
122
|
+
logger.error(`Request failed: ${error.message}`, { error });
|
|
117
123
|
if (!res.headersSent) {
|
|
118
124
|
res.statusCode = 500;
|
|
119
125
|
res.setHeader("content-type", "application/json; charset=utf-8");
|
|
@@ -273,7 +279,7 @@ for a cron job where no server process keeps running. Servers do this every minu
|
|
|
273
279
|
serve: `Usage: easy-cms serve [--port <n>] [--host <host>] [--watch] [--trust-proxy] [options]
|
|
274
280
|
|
|
275
281
|
Runs Easy CMS without Nuxt or Next.js: the admin at /admin, the REST API at /api/cms and
|
|
276
|
-
/healthz for load balancers. Frontends on other origins need \`cors\` in the config.
|
|
282
|
+
/healthz and /readyz for load balancers. Frontends on other origins need \`cors\` in the config.
|
|
277
283
|
|
|
278
284
|
--port <n> Port (default: PORT, then 4000)
|
|
279
285
|
--host <host> Interface to listen on (default: HOST, then all interfaces)
|
|
@@ -570,23 +576,34 @@ async function serve(values, cwd, logger, load, io) {
|
|
|
570
576
|
return 1;
|
|
571
577
|
}
|
|
572
578
|
const host = values.host ?? process.env.HOST;
|
|
579
|
+
const config = await load();
|
|
580
|
+
const json = logFormat(config.logs) === "json";
|
|
581
|
+
const serverLogger = json ? jsonLogger() : logger;
|
|
573
582
|
const server = await startServer({
|
|
574
583
|
port,
|
|
575
584
|
...host ? { host } : {},
|
|
576
585
|
cwd,
|
|
577
|
-
logger,
|
|
586
|
+
logger: serverLogger,
|
|
578
587
|
loadConfig: load,
|
|
579
588
|
watch: values.watch ?? false,
|
|
580
589
|
trustProxy: values["trust-proxy"] ?? false
|
|
581
590
|
});
|
|
582
|
-
const
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
591
|
+
const admin = `${server.url}/${config.admin.path.replace(/^\/+|\/+$/g, "")}`;
|
|
592
|
+
if (json) {
|
|
593
|
+
serverLogger.info(`Easy CMS running at ${server.url}`, {
|
|
594
|
+
admin,
|
|
595
|
+
api: `${server.url}${config.routes.api}`
|
|
596
|
+
});
|
|
597
|
+
} else {
|
|
598
|
+
io.out(`Easy CMS running at ${server.url}`);
|
|
599
|
+
io.out(` admin ${admin}`);
|
|
600
|
+
io.out(` API ${server.url}${config.routes.api}`);
|
|
601
|
+
if (values.watch) io.out(" watching for changes");
|
|
602
|
+
}
|
|
587
603
|
await new Promise((resolveStop) => {
|
|
588
604
|
const stop = (signal) => {
|
|
589
|
-
|
|
605
|
+
if (json) serverLogger.info(`${signal} received, shutting down`);
|
|
606
|
+
else io.out(`
|
|
590
607
|
${signal} received, shutting down\u2026`);
|
|
591
608
|
resolveStop();
|
|
592
609
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ 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`, `/healthz` for load balancers, and endpoints marked `root` (such as a
|
|
11
|
+
* admin at `admin.path`, `/healthz` and `/readyz` for load balancers, and endpoints marked `root` (such as a
|
|
12
12
|
* plugin's `/robots.txt`). `/` redirects to the admin.
|
|
13
13
|
*/
|
|
14
14
|
declare function createStandaloneHandler<C extends Config>(cms: EasyCMS<C>, options?: {
|
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "easy-cms",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.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": "^1.
|
|
25
|
-
"@easy-cms/admin": "^1.
|
|
24
|
+
"@easy-cms/core": "^1.7.0",
|
|
25
|
+
"@easy-cms/admin": "^1.7.0"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"@easy-cms/db-sqlite": "^1.
|
|
28
|
+
"@easy-cms/db-sqlite": "^1.7.0"
|
|
29
29
|
},
|
|
30
30
|
"publishConfig": {
|
|
31
31
|
"access": "public"
|