jeasx 1.5.0 → 1.6.2
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/cli.js +2 -0
- package/ecosystem.config.cjs +0 -2
- package/env.js +27 -0
- package/esbuild.config.js +4 -1
- package/package.json +4 -5
- package/serverless.js +14 -4
- package/serverless.ts +15 -4
package/cli.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import fs from "node:fs/promises";
|
|
3
|
+
import env from "./env.js";
|
|
3
4
|
|
|
4
5
|
switch (process.argv[2]) {
|
|
5
6
|
case "start":
|
|
@@ -34,6 +35,7 @@ async function start() {
|
|
|
34
35
|
}
|
|
35
36
|
|
|
36
37
|
async function build() {
|
|
38
|
+
env();
|
|
37
39
|
const argv = [...process.argv];
|
|
38
40
|
process.argv = [];
|
|
39
41
|
await clean();
|
package/ecosystem.config.cjs
CHANGED
package/env.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { existsSync } from "node:fs";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Load environment variables from .env* files
|
|
5
|
+
* into process.env in the following order:
|
|
6
|
+
*
|
|
7
|
+
* 1. .env.defaults
|
|
8
|
+
* 2. .env
|
|
9
|
+
* 3. .env.local
|
|
10
|
+
* 4. .env.<NODE_ENV>
|
|
11
|
+
* 5. .env.<NODE_ENV>.local
|
|
12
|
+
*/
|
|
13
|
+
export default function env() {
|
|
14
|
+
const files = [".env.defaults", ".env", ".env.local"];
|
|
15
|
+
|
|
16
|
+
if (process.env.NODE_ENV) {
|
|
17
|
+
files.push(
|
|
18
|
+
`.env.${process.env.NODE_ENV}`,
|
|
19
|
+
`.env.${process.env.NODE_ENV}.local`
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
files.filter(existsSync).forEach((file) => {
|
|
24
|
+
console.info(`🌻 Loading ${file}`);
|
|
25
|
+
process.loadEnvFile(file);
|
|
26
|
+
});
|
|
27
|
+
}
|
package/esbuild.config.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import "dotenv-flow/config";
|
|
2
1
|
import * as esbuild from "esbuild";
|
|
3
2
|
|
|
4
3
|
const BUILD_TIME = `"${Date.now().toString(36)}"`;
|
|
@@ -66,6 +65,8 @@ function buildServer(...entryPoints) {
|
|
|
66
65
|
logLevel: "info",
|
|
67
66
|
color: true,
|
|
68
67
|
bundle: true,
|
|
68
|
+
sourcemap: true,
|
|
69
|
+
sourcesContent: false,
|
|
69
70
|
outbase: "src",
|
|
70
71
|
outdir: "dist",
|
|
71
72
|
platform: "neutral",
|
|
@@ -84,6 +85,8 @@ function buildBrowser(...entryPoints) {
|
|
|
84
85
|
logLevel: "info",
|
|
85
86
|
color: true,
|
|
86
87
|
bundle: true,
|
|
88
|
+
sourcemap: true,
|
|
89
|
+
sourcesContent: true,
|
|
87
90
|
outbase: "src/browser",
|
|
88
91
|
outdir: "dist/browser",
|
|
89
92
|
platform: "browser",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "jeasx",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.2",
|
|
4
4
|
"description": "Jeasx - the ease of JSX with the power of SSR",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"jsx",
|
|
@@ -29,11 +29,10 @@
|
|
|
29
29
|
"@fastify/multipart": "9.0.3",
|
|
30
30
|
"@fastify/static": "8.1.1",
|
|
31
31
|
"@types/node": "22.13.10",
|
|
32
|
-
"
|
|
33
|
-
"esbuild": "0.25.0",
|
|
32
|
+
"esbuild": "0.25.1",
|
|
34
33
|
"fastify": "5.2.1",
|
|
35
|
-
"jsx-async-runtime": "0.
|
|
36
|
-
"pm2": "
|
|
34
|
+
"jsx-async-runtime": "1.0.0",
|
|
35
|
+
"pm2": "6.0.5"
|
|
37
36
|
},
|
|
38
37
|
"scripts": {
|
|
39
38
|
"build": "esbuild --platform=node --format=esm --outdir=. serverless.ts"
|
package/serverless.js
CHANGED
|
@@ -2,20 +2,23 @@ import fastifyCookie from "@fastify/cookie";
|
|
|
2
2
|
import fastifyFormbody from "@fastify/formbody";
|
|
3
3
|
import fastifyMultipart from "@fastify/multipart";
|
|
4
4
|
import fastifyStatic from "@fastify/static";
|
|
5
|
-
import "dotenv-flow/config";
|
|
6
5
|
import Fastify from "fastify";
|
|
7
6
|
import { jsxToString } from "jsx-async-runtime";
|
|
8
7
|
import { createHash } from "node:crypto";
|
|
9
8
|
import { readFile, stat } from "node:fs/promises";
|
|
10
9
|
import { join } from "node:path";
|
|
10
|
+
import env from "./env.js";
|
|
11
|
+
env();
|
|
11
12
|
const NODE_ENV_IS_DEVELOPMENT = process.env.NODE_ENV === "development";
|
|
12
13
|
const CWD = process.cwd();
|
|
13
14
|
const FASTIFY_STATIC_HEADERS = process.env.FASTIFY_STATIC_HEADERS && JSON.parse(process.env.FASTIFY_STATIC_HEADERS);
|
|
14
15
|
var serverless_default = Fastify({
|
|
15
16
|
logger: true,
|
|
16
|
-
disableRequestLogging:
|
|
17
|
+
disableRequestLogging: JSON.parse(
|
|
18
|
+
process.env.FASTIFY_DISABLE_REQUEST_LOGGING || "false"
|
|
19
|
+
),
|
|
17
20
|
bodyLimit: Number(process.env.FASTIFY_BODY_LIMIT) || void 0,
|
|
18
|
-
trustProxy:
|
|
21
|
+
trustProxy: JSON.parse(process.env.FASTIFY_TRUST_PROXY || "false"),
|
|
19
22
|
rewriteUrl: process.env.FASTIFY_REWRITE_URL && new Function(`return ${process.env.FASTIFY_REWRITE_URL}`)()
|
|
20
23
|
}).register(fastifyCookie).register(fastifyFormbody).register(fastifyMultipart).register(fastifyStatic, {
|
|
21
24
|
root: ["public", "dist/browser"].map((dir) => join(CWD, dir)),
|
|
@@ -37,7 +40,14 @@ var serverless_default = Fastify({
|
|
|
37
40
|
}).decorateRequest("route", "").decorateRequest("path", "").addHook("onRequest", async (request, reply) => {
|
|
38
41
|
const index = request.url.indexOf("?");
|
|
39
42
|
request.path = index === -1 ? request.url : request.url.slice(0, index);
|
|
40
|
-
}).all("*",
|
|
43
|
+
}).all("*", async (request, reply) => {
|
|
44
|
+
try {
|
|
45
|
+
return await handler(request, reply);
|
|
46
|
+
} catch (error) {
|
|
47
|
+
console.error("\u274C", error);
|
|
48
|
+
throw error;
|
|
49
|
+
}
|
|
50
|
+
});
|
|
41
51
|
const modules = {};
|
|
42
52
|
async function handler(request, reply) {
|
|
43
53
|
let response;
|
package/serverless.ts
CHANGED
|
@@ -2,12 +2,14 @@ import fastifyCookie from "@fastify/cookie";
|
|
|
2
2
|
import fastifyFormbody from "@fastify/formbody";
|
|
3
3
|
import fastifyMultipart from "@fastify/multipart";
|
|
4
4
|
import fastifyStatic from "@fastify/static";
|
|
5
|
-
import "dotenv-flow/config";
|
|
6
5
|
import Fastify, { FastifyReply, FastifyRequest } from "fastify";
|
|
7
6
|
import { jsxToString } from "jsx-async-runtime";
|
|
8
7
|
import { createHash } from "node:crypto";
|
|
9
8
|
import { readFile, stat } from "node:fs/promises";
|
|
10
9
|
import { join } from "node:path";
|
|
10
|
+
import env from "./env.js";
|
|
11
|
+
|
|
12
|
+
env();
|
|
11
13
|
|
|
12
14
|
const NODE_ENV_IS_DEVELOPMENT = process.env.NODE_ENV === "development";
|
|
13
15
|
const CWD = process.cwd();
|
|
@@ -26,9 +28,11 @@ declare module "fastify" {
|
|
|
26
28
|
// Create and export a Fastify app instance
|
|
27
29
|
export default Fastify({
|
|
28
30
|
logger: true,
|
|
29
|
-
disableRequestLogging:
|
|
31
|
+
disableRequestLogging: JSON.parse(
|
|
32
|
+
process.env.FASTIFY_DISABLE_REQUEST_LOGGING || "false"
|
|
33
|
+
),
|
|
30
34
|
bodyLimit: Number(process.env.FASTIFY_BODY_LIMIT) || undefined,
|
|
31
|
-
trustProxy:
|
|
35
|
+
trustProxy: JSON.parse(process.env.FASTIFY_TRUST_PROXY || "false"),
|
|
32
36
|
rewriteUrl:
|
|
33
37
|
process.env.FASTIFY_REWRITE_URL &&
|
|
34
38
|
new Function(`return ${process.env.FASTIFY_REWRITE_URL}`)(),
|
|
@@ -62,7 +66,14 @@ export default Fastify({
|
|
|
62
66
|
const index = request.url.indexOf("?");
|
|
63
67
|
request.path = index === -1 ? request.url : request.url.slice(0, index);
|
|
64
68
|
})
|
|
65
|
-
.all("*",
|
|
69
|
+
.all("*", async (request: FastifyRequest, reply: FastifyReply) => {
|
|
70
|
+
try {
|
|
71
|
+
return await handler(request, reply);
|
|
72
|
+
} catch (error) {
|
|
73
|
+
console.error("❌", error);
|
|
74
|
+
throw error;
|
|
75
|
+
}
|
|
76
|
+
});
|
|
66
77
|
|
|
67
78
|
// Cache for resolved route modules, 'null' means no module exists.
|
|
68
79
|
const modules: { [path: string]: { default: Function } | null } = {};
|