jeasx 2.2.2 → 2.3.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/CHANGELOG.md +59 -4
- package/env.js +17 -29
- package/esbuild.config.js +29 -13
- package/package.json +4 -3
- package/server.js +1 -1
- package/serverless.js +6 -27
- package/serverless.js.map +1 -1
- package/serverless.ts +6 -31
package/CHANGELOG.md
CHANGED
|
@@ -1,10 +1,63 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 2026-01-30 - Jeasx 2.3.0 released
|
|
4
|
+
|
|
5
|
+
🎉 This release introduces support for [MDX](https://mdxjs.com), enabling you to seamlessly embed JSX within Markdown content. Just create a route with a `.mdx` extension, and you’re all set to enhance your websites and blogs with Markdown enriched by dynamic JSX components.
|
|
6
|
+
|
|
7
|
+
```jsx
|
|
8
|
+
import Layout from "./Layout"
|
|
9
|
+
|
|
10
|
+
<Layout title="MDX - Markdown for the component era">
|
|
11
|
+
# MDX as content companion alongside JSX
|
|
12
|
+
|
|
13
|
+
You can easily access existing `props` in MDX:
|
|
14
|
+
|
|
15
|
+
- Current url: {props.request.url}
|
|
16
|
+
</Layout>
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
You can also create MDX-based components for use within JSX by importing them with their full `.mdx` file extension into your JSX routes or components.
|
|
20
|
+
|
|
21
|
+
Since MDX supports a variety of plugins - and Jeasx provides only the MDX core to stay focused on infrastructure while letting users handle customization - the overall configuration for Jeasx has been significantly improved. Now, the configuration object from an `.env.js` file is imported directly into both the build process and server runtime, allowing you to use package imports seamlessly. Previously, (de)serializing the configuration via `process.env` restricted this capability and limited advanced setups.
|
|
22
|
+
|
|
23
|
+
**Please note:** Variables loaded from `.env.js` now consistently overwrite any existing environment variables. This ensures predictable and consistent behavior across your configuration.
|
|
24
|
+
|
|
25
|
+
Here’s an example of how to configure the MDX engine: if you want to enable GitHub-flavored Markdown (`remark-gfm`), add syntax highlighting (`rehype-prism-plus`), and generate IDs for your headings (`rehype-slug`), you can install and configure these plugins accordingly in `.env.js`.
|
|
26
|
+
|
|
27
|
+
```js
|
|
28
|
+
import rehypePrismPlus from "rehype-prism-plus";
|
|
29
|
+
import rehypeSlug from "rehype-slug";
|
|
30
|
+
import remarkGFM from "remark-gfm";
|
|
31
|
+
|
|
32
|
+
export default {
|
|
33
|
+
/** @type import("@mdx-js/esbuild").Options */
|
|
34
|
+
ESBUILD_MDX_OPTIONS: {
|
|
35
|
+
remarkPlugins: [[remarkGFM, { singleTilde: false }]],
|
|
36
|
+
rehypePlugins: [rehypePrismPlus, [rehypeSlug, { prefix: "jeasx-" }]]
|
|
37
|
+
}
|
|
38
|
+
//...
|
|
39
|
+
}
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
For a full overview of available configuration options and plugins, check out the excellent documentation of [@mdx-js/esbuild](https://mdxjs.com/packages/esbuild).
|
|
43
|
+
|
|
44
|
+
**Please note:** The update to the Jeasx configuration introduced a minor change in how `ESBUILD_BROWSER_TARGET` is specified to ensure consistency across the configuration. Previously, a comma-separated string was accepted and parsed as customization. Going forward, you must provide a proper JSON array (or its stringified form when using traditional `.env` files or the process environment).
|
|
45
|
+
|
|
46
|
+
```js
|
|
47
|
+
export default {
|
|
48
|
+
/** @type import("esbuild").BuildOptions["target"] */
|
|
49
|
+
ESBUILD_BROWSER_TARGET: ["chrome130", "edge130", "firefox130", "safari18"]
|
|
50
|
+
//...
|
|
51
|
+
}
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Dependency updates: `fastify@5.7.2`, `@fastify/multipart@9.4.0`
|
|
55
|
+
|
|
3
56
|
## 2026-01-17 - Jeasx 2.2.2 released
|
|
4
57
|
|
|
5
|
-
🎉 This release now preserves the original status code when a 404 page is accessed directly (
|
|
58
|
+
🎉 This release now preserves the original status code when a 404 page is accessed directly (defaults to 200). This improvement makes it easier to use Jeasx as a static site generator and to fetch the 404 page with common tools for saving it to a file system.
|
|
6
59
|
|
|
7
|
-
For example, you can use `wget` to download a Jeasx website to a www-directory with just a single line:
|
|
60
|
+
While Jeasx is fundamentally a server-side rendering framework, there are valid use cases where serving a static page alone is sufficient. For example, you can use `wget` to download a Jeasx website to a www-directory with just a single line:
|
|
8
61
|
|
|
9
62
|
```bash
|
|
10
63
|
wget --mirror --page-requisites --no-host-directories --directory-prefix=www http://localhost:3000 http://localhost:3000/404
|
|
@@ -12,6 +65,8 @@ wget --mirror --page-requisites --no-host-directories --directory-prefix=www htt
|
|
|
12
65
|
|
|
13
66
|
Have a look at the [Dockerfile](https://github.com/jeasx/jeasx-website/blob/main/Dockerfile) of the Jeasx website to see how things can be wired up for serving a static export with Caddy as web server.
|
|
14
67
|
|
|
68
|
+
If you want to restore the old behaviour (directly calling /404 resulting in status code 404), you can simple add `reply.status(404)` to your `/[404]` handler.
|
|
69
|
+
|
|
15
70
|
Dependency updates: `fastify@5.7.1`, `@fastify/static@9.0.0`, `@types/node@24.10.9`
|
|
16
71
|
|
|
17
72
|
## 2025-12-21 - Jeasx 2.2.1 released
|
|
@@ -24,7 +79,7 @@ Dependency updates: `esbuild@0.27.2`, `jsx-async-runtime@2.0.2`, `@types/node@24
|
|
|
24
79
|
|
|
25
80
|
🎉 This release introduces a more flexible configuration approach for the underlying Fastify server. You can now customize all Fastify options (including those for all used plugins) according to your needs, without having to use the formerly fixed and very restrictive set of environment variables. This change was made to eliminate the need for increasingly specific environment variables to customise the default behaviour of Jeasx.
|
|
26
81
|
|
|
27
|
-
**Breaking change**: The previously supported environment variables (
|
|
82
|
+
**Breaking change**: The previously supported environment variables (`FASTIFY_BODY_LIMIT, FASTIFY_DISABLE_REQUEST_LOGGING, FASTIFY_REWRITE_URL, FASTIFY_STATIC_HEADERS, FASTIFY_TRUST_PROXY, FASTIFY_MULTIPART_ATTACH_FIELDS_TO_BODY`) have been completely removed. While this may seem inconvenient for a minor release, the process of migrating your setup to the new configuration approach usually takes less than a minute. This streamlines the code base and documentation, as these features are presumably seldom used.
|
|
28
83
|
|
|
29
84
|
To configure Fastify (or a specific plugin), you can now use simple JSON objects which mirror the corresponding Fastify options. Have a look at the linked Fastify documentation for a reference of all existing options:
|
|
30
85
|
|
|
@@ -73,7 +128,7 @@ Dependency updates: `@types/node@24.10.1`
|
|
|
73
128
|
|
|
74
129
|
## 2025-11-10 - Jeasx 2.1.1 released
|
|
75
130
|
|
|
76
|
-
🎉 Enhanced configuration for @fastify/static, so you can serve pre-compressed static files (see
|
|
131
|
+
🎉 Enhanced configuration for @fastify/static, so you can serve pre-compressed static files (see [fastify docs](https://github.com/fastify/fastify-static?tab=readme-ov-file#precompressed)) from `public` and `dist/browser`. Just run `gzip -rk public dist/browser` as post build for gzipping your static assets. This might be useful if you don't want to run a reverse proxy in front of your Jeasx application and serve compressed files nevertheless. Setting up compression for dynamic content can be wired up in userland via a root guard:
|
|
77
132
|
|
|
78
133
|
```js
|
|
79
134
|
import { promisify } from "node:util";
|
package/env.js
CHANGED
|
@@ -2,8 +2,7 @@ import { existsSync } from "node:fs";
|
|
|
2
2
|
import { join } from "node:path";
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
* Load environment variables from .env
|
|
6
|
-
* into process.env in the following order:
|
|
5
|
+
* Load environment variables from .env-files into process.env in the following order:
|
|
7
6
|
*
|
|
8
7
|
* 1. .env.<NODE_ENV>.local
|
|
9
8
|
* 2. .env.<NODE_ENV>
|
|
@@ -12,47 +11,36 @@ import { join } from "node:path";
|
|
|
12
11
|
* 5. .env.defaults
|
|
13
12
|
* 6. .env.js
|
|
14
13
|
*
|
|
15
|
-
*
|
|
16
|
-
* it will be not overwritten at a later stage.
|
|
14
|
+
* .env.js is imported as an ES module and will always overwrite existing variables.
|
|
17
15
|
*/
|
|
18
16
|
export default async function env() {
|
|
19
17
|
if (process.loadEnvFile) {
|
|
20
18
|
[
|
|
21
|
-
...(process.env.NODE_ENV
|
|
22
|
-
|
|
23
|
-
|
|
19
|
+
...(process.env.NODE_ENV ?
|
|
20
|
+
[`.env.${process.env.NODE_ENV}.local`, `.env.${process.env.NODE_ENV}`]
|
|
21
|
+
: []),
|
|
24
22
|
".env.local",
|
|
25
23
|
".env",
|
|
26
|
-
".env.defaults"
|
|
24
|
+
".env.defaults"
|
|
27
25
|
]
|
|
28
26
|
.filter(existsSync)
|
|
29
27
|
.forEach(process.loadEnvFile);
|
|
30
28
|
}
|
|
31
29
|
try {
|
|
32
30
|
const envFile = `file://${join(process.cwd(), ".env.js")}`;
|
|
33
|
-
const envObject =
|
|
34
|
-
Object.entries(envObject)
|
|
35
|
-
|
|
36
|
-
.forEach(([key, value]) => {
|
|
31
|
+
const envObject = (await import(envFile)).default;
|
|
32
|
+
Object.entries(envObject).forEach(([key, value]) => {
|
|
33
|
+
try {
|
|
37
34
|
process.env[key] =
|
|
38
35
|
typeof value === "string" ? value : JSON.stringify(value);
|
|
39
|
-
})
|
|
40
|
-
|
|
36
|
+
} catch (error) {
|
|
37
|
+
// JSON.stringify throws TypeError for circular references or BigInts.
|
|
38
|
+
console.error("❌", `"${key}" in .env.js throws`, error);
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
return { ...process.env, ...envObject };
|
|
42
|
+
} catch {
|
|
41
43
|
// ERR_MODULE_NOT_FOUND
|
|
44
|
+
return { ...process.env };
|
|
42
45
|
}
|
|
43
46
|
}
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Convert all functions recursively to strings.
|
|
47
|
-
*/
|
|
48
|
-
function stringifyFunctions(obj) {
|
|
49
|
-
for (const key in obj) {
|
|
50
|
-
if (typeof obj[key] === "function") {
|
|
51
|
-
obj[key] = obj[key].toString();
|
|
52
|
-
}
|
|
53
|
-
if (typeof obj[key] === "object" && obj[key] !== null) {
|
|
54
|
-
stringifyFunctions(obj[key]);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
return obj;
|
|
58
|
-
}
|
package/esbuild.config.js
CHANGED
|
@@ -1,35 +1,49 @@
|
|
|
1
|
+
import mdx from "@mdx-js/esbuild";
|
|
1
2
|
import * as esbuild from "esbuild";
|
|
2
3
|
import env from "./env.js";
|
|
3
4
|
|
|
4
|
-
await env();
|
|
5
|
+
const ENV = await env();
|
|
5
6
|
|
|
6
|
-
const BUILD_TIME = `"${Date.now().toString(36)}"`;
|
|
7
|
+
const BUILD_TIME = `"${ENV.BUILD_TIME || Date.now().toString(36)}"`;
|
|
7
8
|
|
|
8
|
-
const BROWSER_PUBLIC_ENV = Object.keys(
|
|
9
|
+
const BROWSER_PUBLIC_ENV = Object.keys(ENV)
|
|
9
10
|
.filter((key) => key.startsWith("BROWSER_PUBLIC_"))
|
|
10
11
|
.reduce(
|
|
11
12
|
(env, key) => {
|
|
12
|
-
env[`process.env.${key}`] = `"${
|
|
13
|
+
env[`process.env.${key}`] = `"${ENV[key]}"`;
|
|
13
14
|
return env;
|
|
14
15
|
},
|
|
15
16
|
{ "process.env.BROWSER_PUBLIC_BUILD_TIME": BUILD_TIME }
|
|
16
17
|
);
|
|
17
18
|
|
|
18
|
-
const ESBUILD_BROWSER_TARGET =
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
const ESBUILD_BROWSER_TARGET = ENV.ESBUILD_BROWSER_TARGET || [
|
|
20
|
+
"chrome130",
|
|
21
|
+
"edge130",
|
|
22
|
+
"firefox130",
|
|
23
|
+
"safari18"
|
|
24
|
+
];
|
|
25
|
+
|
|
26
|
+
const ESBUILD_MDX_PLUGIN = mdx({
|
|
27
|
+
development: process.env.NODE_ENV === "development",
|
|
28
|
+
jsxImportSource: "jsx-async-runtime",
|
|
29
|
+
elementAttributeNameCase: "html",
|
|
30
|
+
stylePropertyNameCase: "css",
|
|
31
|
+
...(ENV.ESBUILD_MDX_OPTIONS || {})
|
|
32
|
+
});
|
|
21
33
|
|
|
22
34
|
/** @type esbuild.BuildOptions[] */
|
|
23
35
|
const buildOptions = [
|
|
24
36
|
{
|
|
25
|
-
entryPoints: ["js", "ts", "jsx", "tsx"].map(
|
|
37
|
+
entryPoints: ["js", "ts", "jsx", "tsx", "mdx"].map(
|
|
38
|
+
(ext) => `src/**/[*].${ext}`
|
|
39
|
+
),
|
|
26
40
|
define: {
|
|
27
|
-
"process.env.BUILD_TIME": BUILD_TIME
|
|
41
|
+
"process.env.BUILD_TIME": BUILD_TIME
|
|
28
42
|
},
|
|
29
43
|
minify: process.env.NODE_ENV !== "development",
|
|
30
44
|
logLevel: "info",
|
|
31
45
|
logOverride: {
|
|
32
|
-
"empty-glob": "silent"
|
|
46
|
+
"empty-glob": "silent"
|
|
33
47
|
},
|
|
34
48
|
color: true,
|
|
35
49
|
bundle: true,
|
|
@@ -38,6 +52,7 @@ const buildOptions = [
|
|
|
38
52
|
outdir: "dist/server",
|
|
39
53
|
platform: "neutral",
|
|
40
54
|
packages: "external",
|
|
55
|
+
plugins: [ESBUILD_MDX_PLUGIN]
|
|
41
56
|
},
|
|
42
57
|
{
|
|
43
58
|
entryPoints: ["js", "ts", "jsx", "tsx", "css"].map(
|
|
@@ -47,7 +62,7 @@ const buildOptions = [
|
|
|
47
62
|
minify: process.env.NODE_ENV !== "development",
|
|
48
63
|
logLevel: "info",
|
|
49
64
|
logOverride: {
|
|
50
|
-
"empty-glob": "silent"
|
|
65
|
+
"empty-glob": "silent"
|
|
51
66
|
},
|
|
52
67
|
color: true,
|
|
53
68
|
bundle: true,
|
|
@@ -69,9 +84,10 @@ const buildOptions = [
|
|
|
69
84
|
"*.ttf",
|
|
70
85
|
"*.otf",
|
|
71
86
|
"*.woff",
|
|
72
|
-
"*.woff2"
|
|
87
|
+
"*.woff2"
|
|
73
88
|
],
|
|
74
|
-
|
|
89
|
+
plugins: [ESBUILD_MDX_PLUGIN]
|
|
90
|
+
}
|
|
75
91
|
];
|
|
76
92
|
|
|
77
93
|
buildOptions.forEach(async (options) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "jeasx",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.0",
|
|
4
4
|
"description": "Jeasx - the ease of JSX with the power of SSR",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"jsx",
|
|
@@ -26,11 +26,12 @@
|
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"@fastify/cookie": "11.0.2",
|
|
28
28
|
"@fastify/formbody": "8.0.2",
|
|
29
|
-
"@fastify/multipart": "9.
|
|
29
|
+
"@fastify/multipart": "9.4.0",
|
|
30
30
|
"@fastify/static": "9.0.0",
|
|
31
|
+
"@mdx-js/esbuild": "3.1.1",
|
|
31
32
|
"@types/node": "24.10.9",
|
|
32
33
|
"esbuild": "0.27.2",
|
|
33
|
-
"fastify": "5.7.
|
|
34
|
+
"fastify": "5.7.2",
|
|
34
35
|
"jsx-async-runtime": "2.0.2"
|
|
35
36
|
},
|
|
36
37
|
"scripts": {
|
package/server.js
CHANGED
package/serverless.js
CHANGED
|
@@ -8,34 +8,26 @@ import { stat } from "node:fs/promises";
|
|
|
8
8
|
import { freemem } from "node:os";
|
|
9
9
|
import { join } from "node:path";
|
|
10
10
|
import env from "./env.js";
|
|
11
|
-
await env();
|
|
11
|
+
const ENV = await env();
|
|
12
12
|
const CWD = process.cwd();
|
|
13
13
|
const NODE_ENV_IS_DEVELOPMENT = process.env.NODE_ENV === "development";
|
|
14
14
|
const JEASX_ROUTE_CACHE_LIMIT = Math.floor(freemem() / 1024 / 1024);
|
|
15
15
|
var serverless_default = Fastify({
|
|
16
16
|
logger: true,
|
|
17
|
-
...
|
|
17
|
+
...ENV.FASTIFY_SERVER_OPTIONS || {}
|
|
18
18
|
}).register(fastifyCookie, {
|
|
19
|
-
...
|
|
20
|
-
process.env.FASTIFY_COOKIE_OPTIONS
|
|
21
|
-
)
|
|
19
|
+
...ENV.FASTIFY_COOKIE_OPTIONS || {}
|
|
22
20
|
}).register(fastifyFormbody, {
|
|
23
|
-
...
|
|
24
|
-
process.env.FASTIFY_FORMBODY_OPTIONS
|
|
25
|
-
)
|
|
21
|
+
...ENV.FASTIFY_FORMBODY_OPTIONS || {}
|
|
26
22
|
}).register(fastifyMultipart, {
|
|
27
23
|
attachFieldsToBody: "keyValues",
|
|
28
|
-
...
|
|
29
|
-
process.env.FASTIFY_MULTIPART_OPTIONS
|
|
30
|
-
)
|
|
24
|
+
...ENV.FASTIFY_MULTIPART_OPTIONS || {}
|
|
31
25
|
}).register(fastifyStatic, {
|
|
32
26
|
root: [["public"], ["dist", "browser"]].map((dir) => join(CWD, ...dir)),
|
|
33
27
|
prefix: "/",
|
|
34
28
|
wildcard: false,
|
|
35
29
|
preCompressed: true,
|
|
36
|
-
...
|
|
37
|
-
process.env.FASTIFY_STATIC_OPTIONS
|
|
38
|
-
)
|
|
30
|
+
...ENV.FASTIFY_STATIC_OPTIONS || {}
|
|
39
31
|
}).decorateRequest("route", "").decorateRequest("path", "").addHook("onRequest", async (request, reply) => {
|
|
40
32
|
reply.header("Content-Type", "text/html; charset=utf-8");
|
|
41
33
|
const index = request.url.indexOf("?");
|
|
@@ -48,19 +40,6 @@ var serverless_default = Fastify({
|
|
|
48
40
|
throw error;
|
|
49
41
|
}
|
|
50
42
|
});
|
|
51
|
-
function jsonToOptions(json) {
|
|
52
|
-
const options = JSON.parse(json || "{}");
|
|
53
|
-
for (const key in options) {
|
|
54
|
-
if (typeof options[key] === "string" && options[key].includes("=>")) {
|
|
55
|
-
try {
|
|
56
|
-
options[key] = new Function(`return ${options[key]}`)();
|
|
57
|
-
} catch (error) {
|
|
58
|
-
console.warn("\u26A0\uFE0F", error);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
return options;
|
|
63
|
-
}
|
|
64
43
|
const modules = /* @__PURE__ */ new Map();
|
|
65
44
|
async function handler(request, reply) {
|
|
66
45
|
let response;
|
package/serverless.js.map
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["serverless.ts"],
|
|
4
|
-
"mappings": "AAAA,OAAO,mBAA6C;AACpD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,IAAI,CAAC,YAAY,GAAG,OAAO,YAAY;AAAA,IACnD,GAAG,SAAS,IAAI,CAAC,YAAY,GAAG,OAAO,QAAQ;AAAA,EACjD;AACF;AAQA,SAAS,iBAAiB,MAAwB;AAChD,SAAO,KACJ,MAAM,GAAG,EACT,OAAO,CAAC,YAAY,YAAY,EAAE,EAClC,OAAO,CAAC,KAAK,YAAY;AACxB,QAAI,MAAM,IAAI,SAAS,IAAI,IAAI,IAAI,SAAS,CAAC,IAAI,MAAM,MAAM,OAAO;AACpE,WAAO;AAAA,EACT,GAAG,CAAC,CAAC,EACJ,QAAQ,EACR,OAAO,EAAE;AACd;AAQA,SAAS,cAAc,MAAwB;AAC7C,QAAM,QAAQ,CAAC;AACf,MAAI,MAAM;AACR,UAAM,cAAc,KAAK,YAAY,GAAG,IAAI;AAC5C,UAAM;AAAA,MACJ,GAAG,KAAK,UAAU,GAAG,WAAW,CAAC,IAAI,KAAK,UAAU,WAAW,CAAC;AAAA,IAClE;AAAA,EACF;AACA,QAAM,KAAK,GAAG,IAAI,UAAU;AAC5B,SAAO;AACT;AAKA,SAAS,MAAM,KAAuB;AACpC,SAAO,CAAC,CAAC,OAAO,OAAO,QAAQ,YAAY,UAAU,OAAO,WAAW;AACzE;AAKA,eAAe,UAAU,SAAiB,UAAmB;AAC3D,QAAM,UACJ,MAAM,QAAQ,IAAI,MAAM,YAAY,KAAK,SAAS,QAAQ,IAAI;AAGhE,QAAM,kBAAkB,QAAQ,iBAAiB;AACjD,SAAO,OAAO,oBAAoB,aAC9B,MAAM,gBAAgB,KAAK,SAAS,OAAO,IAC3C;AACN;",
|
|
5
5
|
"names": []
|
|
6
6
|
}
|
package/serverless.ts
CHANGED
|
@@ -13,7 +13,7 @@ import { freemem } from "node:os";
|
|
|
13
13
|
import { join } from "node:path";
|
|
14
14
|
import env from "./env.js";
|
|
15
15
|
|
|
16
|
-
await env();
|
|
16
|
+
const ENV = await env();
|
|
17
17
|
|
|
18
18
|
const CWD = process.cwd();
|
|
19
19
|
const NODE_ENV_IS_DEVELOPMENT = process.env.NODE_ENV === "development";
|
|
@@ -29,32 +29,24 @@ declare module "fastify" {
|
|
|
29
29
|
// Create and export a Fastify app instance
|
|
30
30
|
export default Fastify({
|
|
31
31
|
logger: true,
|
|
32
|
-
...(
|
|
32
|
+
...((ENV.FASTIFY_SERVER_OPTIONS || {}) as FastifyServerOptions)
|
|
33
33
|
})
|
|
34
34
|
.register(fastifyCookie, {
|
|
35
|
-
...(
|
|
36
|
-
process.env.FASTIFY_COOKIE_OPTIONS
|
|
37
|
-
) as FastifyCookieOptions)
|
|
35
|
+
...((ENV.FASTIFY_COOKIE_OPTIONS || {}) as FastifyCookieOptions)
|
|
38
36
|
})
|
|
39
37
|
.register(fastifyFormbody, {
|
|
40
|
-
...(
|
|
41
|
-
process.env.FASTIFY_FORMBODY_OPTIONS
|
|
42
|
-
) as FastifyFormbodyOptions)
|
|
38
|
+
...((ENV.FASTIFY_FORMBODY_OPTIONS || {}) as FastifyFormbodyOptions)
|
|
43
39
|
})
|
|
44
40
|
.register(fastifyMultipart, {
|
|
45
41
|
attachFieldsToBody: "keyValues",
|
|
46
|
-
...(
|
|
47
|
-
process.env.FASTIFY_MULTIPART_OPTIONS
|
|
48
|
-
) as FastifyMultipartOptions)
|
|
42
|
+
...((ENV.FASTIFY_MULTIPART_OPTIONS || {}) as FastifyMultipartOptions)
|
|
49
43
|
})
|
|
50
44
|
.register(fastifyStatic, {
|
|
51
45
|
root: [["public"], ["dist", "browser"]].map((dir) => join(CWD, ...dir)),
|
|
52
46
|
prefix: "/",
|
|
53
47
|
wildcard: false,
|
|
54
48
|
preCompressed: true,
|
|
55
|
-
...(
|
|
56
|
-
process.env.FASTIFY_STATIC_OPTIONS
|
|
57
|
-
) as FastifyStaticOptions)
|
|
49
|
+
...((ENV.FASTIFY_STATIC_OPTIONS || {}) as FastifyStaticOptions)
|
|
58
50
|
})
|
|
59
51
|
.decorateRequest("route", "")
|
|
60
52
|
.decorateRequest("path", "")
|
|
@@ -74,23 +66,6 @@ export default Fastify({
|
|
|
74
66
|
}
|
|
75
67
|
});
|
|
76
68
|
|
|
77
|
-
/**
|
|
78
|
-
* Parses JSON and instantiates all stringified functions.
|
|
79
|
-
*/
|
|
80
|
-
function jsonToOptions(json: string) {
|
|
81
|
-
const options = JSON.parse(json || "{}");
|
|
82
|
-
for (const key in options) {
|
|
83
|
-
if (typeof options[key] === "string" && options[key].includes("=>")) {
|
|
84
|
-
try {
|
|
85
|
-
options[key] = new Function(`return ${options[key]}`)();
|
|
86
|
-
} catch (error) {
|
|
87
|
-
console.warn("⚠️", error);
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
return options;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
69
|
// Cache for resolved route modules, 'null' means no module exists.
|
|
95
70
|
const modules = new Map<string, { default: Function }>();
|
|
96
71
|
|