react-router-hono-server 0.5.0 → 1.1.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/node.d.mts +27 -1
- package/dist/node.mjs +39 -38
- package/package.json +1 -1
package/dist/node.d.mts
CHANGED
|
@@ -1,11 +1,31 @@
|
|
|
1
1
|
import * as hono_types from 'hono/types';
|
|
2
2
|
import { BlankEnv } from 'hono/types';
|
|
3
|
+
import { ServerOptions, createServer } from 'node:http';
|
|
4
|
+
import { ServerOptions as ServerOptions$2, createServer as createServer$2, SecureServerOptions, createSecureServer } from 'node:http2';
|
|
5
|
+
import { ServerOptions as ServerOptions$1, createServer as createServer$1 } from 'node:https';
|
|
3
6
|
import { AddressInfo } from 'node:net';
|
|
4
7
|
import { AppLoadContext } from '@remix-run/node';
|
|
5
8
|
import { Env, Hono, Context } from 'hono';
|
|
6
9
|
import { HonoOptions } from 'hono/hono-base';
|
|
7
10
|
import { RemixMiddlewareOptions } from 'remix-hono/handler';
|
|
8
11
|
|
|
12
|
+
type createHttpOptions = {
|
|
13
|
+
serverOptions?: ServerOptions;
|
|
14
|
+
createServer?: typeof createServer;
|
|
15
|
+
};
|
|
16
|
+
type createHttpsOptions = {
|
|
17
|
+
serverOptions?: ServerOptions$1;
|
|
18
|
+
createServer?: typeof createServer$1;
|
|
19
|
+
};
|
|
20
|
+
type createHttp2Options = {
|
|
21
|
+
serverOptions?: ServerOptions$2;
|
|
22
|
+
createServer?: typeof createServer$2;
|
|
23
|
+
};
|
|
24
|
+
type createSecureHttp2Options = {
|
|
25
|
+
serverOptions?: SecureServerOptions;
|
|
26
|
+
createServer?: typeof createSecureServer;
|
|
27
|
+
};
|
|
28
|
+
type CreateNodeServerOptions = createHttpOptions | createHttpsOptions | createHttp2Options | createSecureHttp2Options;
|
|
9
29
|
type HonoServerOptions<E extends Env = BlankEnv> = {
|
|
10
30
|
/**
|
|
11
31
|
* Enable the default logger
|
|
@@ -34,7 +54,7 @@ type HonoServerOptions<E extends Env = BlankEnv> = {
|
|
|
34
54
|
*
|
|
35
55
|
* See https://remix.run/docs/en/main/file-conventions/vite-config#serverbuildfile
|
|
36
56
|
*/
|
|
37
|
-
serverBuildFile?: `${string}.js`;
|
|
57
|
+
serverBuildFile?: `${string}.js` | `${string}.mjs` | `${string}.cjs`;
|
|
38
58
|
/**
|
|
39
59
|
* The directory where the assets are located (defined in vite.config, build.assetsDir)
|
|
40
60
|
*
|
|
@@ -77,6 +97,12 @@ type HonoServerOptions<E extends Env = BlankEnv> = {
|
|
|
77
97
|
* {@link HonoOptions}
|
|
78
98
|
*/
|
|
79
99
|
honoOptions?: HonoOptions<E>;
|
|
100
|
+
/**
|
|
101
|
+
* Customize the node server (ex: using http2)
|
|
102
|
+
*
|
|
103
|
+
* {@link https://hono.dev/docs/getting-started/nodejs#http2}
|
|
104
|
+
*/
|
|
105
|
+
customNodeServer?: CreateNodeServerOptions;
|
|
80
106
|
};
|
|
81
107
|
/**
|
|
82
108
|
* Create a Hono server
|
package/dist/node.mjs
CHANGED
|
@@ -1,76 +1,77 @@
|
|
|
1
1
|
// src/node.ts
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import { serve as
|
|
5
|
-
import { serveStatic as
|
|
6
|
-
import { Hono as
|
|
7
|
-
import { logger as
|
|
8
|
-
import { remix as
|
|
2
|
+
import c from "node:path";
|
|
3
|
+
import O from "node:url";
|
|
4
|
+
import { serve as g } from "@hono/node-server";
|
|
5
|
+
import { serveStatic as v } from "@hono/node-server/serve-static";
|
|
6
|
+
import { Hono as y } from "hono";
|
|
7
|
+
import { logger as E } from "hono/logger";
|
|
8
|
+
import { remix as x } from "remix-hono/handler";
|
|
9
9
|
|
|
10
10
|
// src/dev-build.ts
|
|
11
|
-
var
|
|
12
|
-
(
|
|
11
|
+
var S = process.env.NODE_ENV === "production" ? void 0 : await import("vite").then(
|
|
12
|
+
(r) => r.createServer({
|
|
13
13
|
server: { middlewareMode: !0 },
|
|
14
14
|
appType: "custom"
|
|
15
15
|
})
|
|
16
16
|
);
|
|
17
|
-
async function
|
|
18
|
-
return
|
|
17
|
+
async function a() {
|
|
18
|
+
return S?.ssrLoadModule("virtual:remix/server-build");
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
// src/middleware.ts
|
|
22
|
-
import { createMiddleware as
|
|
23
|
-
function i(
|
|
24
|
-
return
|
|
22
|
+
import { createMiddleware as f } from "hono/factory";
|
|
23
|
+
function i(r) {
|
|
24
|
+
return f(async (e, o) => {
|
|
25
25
|
if (!e.req.path.match(/\.[a-zA-Z0-9]+$/) || e.req.path.endsWith(".data"))
|
|
26
|
-
return
|
|
27
|
-
await
|
|
26
|
+
return o();
|
|
27
|
+
await o(), e.res.ok && e.res.headers.set("cache-control", `public, max-age=${r}`);
|
|
28
28
|
});
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
// src/node.ts
|
|
32
|
-
var
|
|
32
|
+
var h = {
|
|
33
33
|
defaultLogger: !0,
|
|
34
34
|
port: Number(process.env.PORT) || 3e3,
|
|
35
35
|
buildDirectory: "build",
|
|
36
36
|
serverBuildFile: "index.js",
|
|
37
37
|
assetsDir: "assets",
|
|
38
|
-
listeningListener: (
|
|
39
|
-
console.log(`\u{1F680} Server started on port ${
|
|
38
|
+
listeningListener: (r) => {
|
|
39
|
+
console.log(`\u{1F680} Server started on port ${r.port}`);
|
|
40
40
|
}
|
|
41
41
|
};
|
|
42
|
-
async function M(
|
|
42
|
+
async function M(r = {}) {
|
|
43
43
|
let e = {
|
|
44
|
-
...
|
|
45
|
-
...
|
|
46
|
-
defaultLogger:
|
|
47
|
-
},
|
|
48
|
-
return
|
|
44
|
+
...h,
|
|
45
|
+
...r,
|
|
46
|
+
defaultLogger: r.defaultLogger ?? !0
|
|
47
|
+
}, o = process.env.NODE_ENV === "test" ? "development" : process.env.NODE_ENV, n = o === "production", t = new y(e.honoOptions), d = `./${e.buildDirectory}/server`, s = `./${e.buildDirectory}/client`;
|
|
48
|
+
return t.use(
|
|
49
49
|
`/${e.assetsDir}/*`,
|
|
50
50
|
i(60 * 60 * 24 * 365),
|
|
51
51
|
// 1 year
|
|
52
|
-
|
|
53
|
-
),
|
|
52
|
+
v({ root: s })
|
|
53
|
+
), t.use("*", i(60 * 60), v({ root: n ? s : "./public" })), e.defaultLogger && t.use("*", E()), e.configure && await e.configure(t), t.use(async (u, m) => {
|
|
54
54
|
let p = n ? await import(
|
|
55
55
|
/* @vite-ignore */
|
|
56
|
-
|
|
57
|
-
|
|
56
|
+
O.pathToFileURL(
|
|
57
|
+
c.resolve(c.join(process.cwd(), `${d}/${e.serverBuildFile}`))
|
|
58
58
|
).toString()
|
|
59
|
-
) : await
|
|
60
|
-
return
|
|
59
|
+
) : await a();
|
|
60
|
+
return x({
|
|
61
61
|
build: p,
|
|
62
|
-
mode:
|
|
63
|
-
getLoadContext(
|
|
64
|
-
return e.getLoadContext ? e.getLoadContext(
|
|
62
|
+
mode: o,
|
|
63
|
+
getLoadContext(l) {
|
|
64
|
+
return e.getLoadContext ? e.getLoadContext(l, { build: p }) : {};
|
|
65
65
|
}
|
|
66
|
-
})(
|
|
67
|
-
}), n &&
|
|
66
|
+
})(u, m);
|
|
67
|
+
}), n && g(
|
|
68
68
|
{
|
|
69
|
-
...
|
|
69
|
+
...t,
|
|
70
|
+
...e.customNodeServer,
|
|
70
71
|
port: e.port
|
|
71
72
|
},
|
|
72
73
|
e.listeningListener
|
|
73
|
-
),
|
|
74
|
+
), t;
|
|
74
75
|
}
|
|
75
76
|
export {
|
|
76
77
|
M as createHonoServer
|
package/package.json
CHANGED