@tachybase/plugin-adapter-remix 0.23.8
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/.turbo/turbo-build.log +6 -0
- package/README.md +1 -0
- package/client.d.ts +2 -0
- package/client.js +1 -0
- package/dist/client/index.d.ts +4 -0
- package/dist/client/index.js +1 -0
- package/dist/externalVersion.js +4 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +39 -0
- package/dist/node_modules/@remix-run/express/dist/index.d.ts +2 -0
- package/dist/node_modules/@remix-run/express/dist/index.js +362 -0
- package/dist/node_modules/@remix-run/express/dist/server.d.ts +24 -0
- package/dist/node_modules/@remix-run/express/dist/server.js +118 -0
- package/dist/node_modules/@remix-run/express/node_modules/.bin/tsc +17 -0
- package/dist/node_modules/@remix-run/express/node_modules/.bin/tsserver +17 -0
- package/dist/node_modules/@remix-run/express/package.json +1 -0
- package/dist/node_modules/express/LICENSE +24 -0
- package/dist/node_modules/express/index.js +313 -0
- package/dist/node_modules/express/lib/application.js +661 -0
- package/dist/node_modules/express/lib/express.js +116 -0
- package/dist/node_modules/express/lib/middleware/init.js +43 -0
- package/dist/node_modules/express/lib/middleware/query.js +47 -0
- package/dist/node_modules/express/lib/request.js +525 -0
- package/dist/node_modules/express/lib/response.js +1179 -0
- package/dist/node_modules/express/lib/router/index.js +673 -0
- package/dist/node_modules/express/lib/router/layer.js +181 -0
- package/dist/node_modules/express/lib/router/route.js +230 -0
- package/dist/node_modules/express/lib/utils.js +303 -0
- package/dist/node_modules/express/lib/view.js +182 -0
- package/dist/node_modules/express/package.json +1 -0
- package/dist/server/index.d.ts +1 -0
- package/dist/server/index.js +33 -0
- package/dist/server/plugin.d.ts +11 -0
- package/dist/server/plugin.js +84 -0
- package/package.json +24 -0
- package/server.d.ts +2 -0
- package/server.js +1 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/// <reference lib="dom.iterable" />
|
|
2
|
+
import type * as express from "express";
|
|
3
|
+
import type { AppLoadContext, ServerBuild } from "@remix-run/node";
|
|
4
|
+
/**
|
|
5
|
+
* A function that returns the value to use as `context` in route `loader` and
|
|
6
|
+
* `action` functions.
|
|
7
|
+
*
|
|
8
|
+
* You can think of this as an escape hatch that allows you to pass
|
|
9
|
+
* environment/platform-specific values through to your loader/action, such as
|
|
10
|
+
* values that are generated by Express middleware like `req.session`.
|
|
11
|
+
*/
|
|
12
|
+
export type GetLoadContextFunction = (req: express.Request, res: express.Response) => Promise<AppLoadContext> | AppLoadContext;
|
|
13
|
+
export type RequestHandler = (req: express.Request, res: express.Response, next: express.NextFunction) => Promise<void>;
|
|
14
|
+
/**
|
|
15
|
+
* Returns a request handler for Express that serves the response using Remix.
|
|
16
|
+
*/
|
|
17
|
+
export declare function createRequestHandler({ build, getLoadContext, mode, }: {
|
|
18
|
+
build: ServerBuild | (() => Promise<ServerBuild>);
|
|
19
|
+
getLoadContext?: GetLoadContextFunction;
|
|
20
|
+
mode?: string;
|
|
21
|
+
}): RequestHandler;
|
|
22
|
+
export declare function createRemixHeaders(requestHeaders: express.Request["headers"]): Headers;
|
|
23
|
+
export declare function createRemixRequest(req: express.Request, res: express.Response): Request;
|
|
24
|
+
export declare function sendRemixResponse(res: express.Response, nodeResponse: Response): Promise<void>;
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @remix-run/express v2.15.2
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) Remix Software Inc.
|
|
5
|
+
*
|
|
6
|
+
* This source code is licensed under the MIT license found in the
|
|
7
|
+
* LICENSE.md file in the root directory of this source tree.
|
|
8
|
+
*
|
|
9
|
+
* @license MIT
|
|
10
|
+
*/
|
|
11
|
+
'use strict';
|
|
12
|
+
|
|
13
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
14
|
+
|
|
15
|
+
var node = require('@remix-run/node');
|
|
16
|
+
|
|
17
|
+
// IDK why this is needed when it's in the tsconfig..........
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* A function that returns the value to use as `context` in route `loader` and
|
|
21
|
+
* `action` functions.
|
|
22
|
+
*
|
|
23
|
+
* You can think of this as an escape hatch that allows you to pass
|
|
24
|
+
* environment/platform-specific values through to your loader/action, such as
|
|
25
|
+
* values that are generated by Express middleware like `req.session`.
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Returns a request handler for Express that serves the response using Remix.
|
|
30
|
+
*/
|
|
31
|
+
function createRequestHandler({
|
|
32
|
+
build,
|
|
33
|
+
getLoadContext,
|
|
34
|
+
mode = process.env.NODE_ENV
|
|
35
|
+
}) {
|
|
36
|
+
let handleRequest = node.createRequestHandler(build, mode);
|
|
37
|
+
return async (req, res, next) => {
|
|
38
|
+
try {
|
|
39
|
+
let request = createRemixRequest(req, res);
|
|
40
|
+
let loadContext = await (getLoadContext === null || getLoadContext === void 0 ? void 0 : getLoadContext(req, res));
|
|
41
|
+
let response = await handleRequest(request, loadContext);
|
|
42
|
+
await sendRemixResponse(res, response);
|
|
43
|
+
} catch (error) {
|
|
44
|
+
// Express doesn't support async functions, so we have to pass along the
|
|
45
|
+
// error manually using next().
|
|
46
|
+
next(error);
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
function createRemixHeaders(requestHeaders) {
|
|
51
|
+
let headers = new Headers();
|
|
52
|
+
for (let [key, values] of Object.entries(requestHeaders)) {
|
|
53
|
+
if (values) {
|
|
54
|
+
if (Array.isArray(values)) {
|
|
55
|
+
for (let value of values) {
|
|
56
|
+
headers.append(key, value);
|
|
57
|
+
}
|
|
58
|
+
} else {
|
|
59
|
+
headers.set(key, values);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return headers;
|
|
64
|
+
}
|
|
65
|
+
function createRemixRequest(req, res) {
|
|
66
|
+
var _req$get, _req$get2;
|
|
67
|
+
// req.hostname doesn't include port information so grab that from
|
|
68
|
+
// `X-Forwarded-Host` or `Host`
|
|
69
|
+
let [, hostnamePort] = ((_req$get = req.get("X-Forwarded-Host")) === null || _req$get === void 0 ? void 0 : _req$get.split(":")) ?? [];
|
|
70
|
+
let [, hostPort] = ((_req$get2 = req.get("host")) === null || _req$get2 === void 0 ? void 0 : _req$get2.split(":")) ?? [];
|
|
71
|
+
let port = hostnamePort || hostPort;
|
|
72
|
+
// Use req.hostname here as it respects the "trust proxy" setting
|
|
73
|
+
let resolvedHost = `${req.hostname}${port ? `:${port}` : ""}`;
|
|
74
|
+
// Use `req.originalUrl` so Remix is aware of the full path
|
|
75
|
+
let url = new URL(`${req.protocol}://${resolvedHost}${req.originalUrl}`);
|
|
76
|
+
let controller = new AbortController();
|
|
77
|
+
let init = {
|
|
78
|
+
method: req.method,
|
|
79
|
+
headers: createRemixHeaders(req.headers),
|
|
80
|
+
signal: controller.signal
|
|
81
|
+
};
|
|
82
|
+
if (req.method !== "GET" && req.method !== "HEAD") {
|
|
83
|
+
init.body = node.createReadableStreamFromReadable(req);
|
|
84
|
+
init.duplex = "half";
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// Abort action/loaders once we can no longer write a response iff we have
|
|
88
|
+
// not yet sent a response (i.e., `close` without `finish`)
|
|
89
|
+
// `finish` -> done rendering the response
|
|
90
|
+
// `close` -> response can no longer be written to
|
|
91
|
+
res.on("finish", () => controller = null);
|
|
92
|
+
res.on("close", () => {
|
|
93
|
+
var _controller;
|
|
94
|
+
return (_controller = controller) === null || _controller === void 0 ? void 0 : _controller.abort();
|
|
95
|
+
});
|
|
96
|
+
return new Request(url.href, init);
|
|
97
|
+
}
|
|
98
|
+
async function sendRemixResponse(res, nodeResponse) {
|
|
99
|
+
var _nodeResponse$headers;
|
|
100
|
+
res.statusMessage = nodeResponse.statusText;
|
|
101
|
+
res.status(nodeResponse.status);
|
|
102
|
+
for (let [key, value] of nodeResponse.headers.entries()) {
|
|
103
|
+
res.append(key, value);
|
|
104
|
+
}
|
|
105
|
+
if ((_nodeResponse$headers = nodeResponse.headers.get("Content-Type")) !== null && _nodeResponse$headers !== void 0 && _nodeResponse$headers.match(/text\/event-stream/i)) {
|
|
106
|
+
res.flushHeaders();
|
|
107
|
+
}
|
|
108
|
+
if (nodeResponse.body) {
|
|
109
|
+
await node.writeReadableStreamToWritable(nodeResponse.body, res);
|
|
110
|
+
} else {
|
|
111
|
+
res.end();
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
exports.createRemixHeaders = createRemixHeaders;
|
|
116
|
+
exports.createRemixRequest = createRemixRequest;
|
|
117
|
+
exports.createRequestHandler = createRequestHandler;
|
|
118
|
+
exports.sendRemixResponse = sendRemixResponse;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
|
3
|
+
|
|
4
|
+
case `uname` in
|
|
5
|
+
*CYGWIN*) basedir=`cygpath -w "$basedir"`;;
|
|
6
|
+
esac
|
|
7
|
+
|
|
8
|
+
if [ -z "$NODE_PATH" ]; then
|
|
9
|
+
export NODE_PATH="/Users/seal/Documents/projects/tachybase/node_modules/.pnpm/typescript@5.7.2/node_modules/typescript/bin/node_modules:/Users/seal/Documents/projects/tachybase/node_modules/.pnpm/typescript@5.7.2/node_modules/typescript/node_modules:/Users/seal/Documents/projects/tachybase/node_modules/.pnpm/typescript@5.7.2/node_modules:/Users/seal/Documents/projects/tachybase/node_modules/.pnpm/node_modules"
|
|
10
|
+
else
|
|
11
|
+
export NODE_PATH="/Users/seal/Documents/projects/tachybase/node_modules/.pnpm/typescript@5.7.2/node_modules/typescript/bin/node_modules:/Users/seal/Documents/projects/tachybase/node_modules/.pnpm/typescript@5.7.2/node_modules/typescript/node_modules:/Users/seal/Documents/projects/tachybase/node_modules/.pnpm/typescript@5.7.2/node_modules:/Users/seal/Documents/projects/tachybase/node_modules/.pnpm/node_modules:$NODE_PATH"
|
|
12
|
+
fi
|
|
13
|
+
if [ -x "$basedir/node" ]; then
|
|
14
|
+
exec "$basedir/node" "$basedir/../../../../typescript/bin/tsc" "$@"
|
|
15
|
+
else
|
|
16
|
+
exec node "$basedir/../../../../typescript/bin/tsc" "$@"
|
|
17
|
+
fi
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
|
3
|
+
|
|
4
|
+
case `uname` in
|
|
5
|
+
*CYGWIN*) basedir=`cygpath -w "$basedir"`;;
|
|
6
|
+
esac
|
|
7
|
+
|
|
8
|
+
if [ -z "$NODE_PATH" ]; then
|
|
9
|
+
export NODE_PATH="/Users/seal/Documents/projects/tachybase/node_modules/.pnpm/typescript@5.7.2/node_modules/typescript/bin/node_modules:/Users/seal/Documents/projects/tachybase/node_modules/.pnpm/typescript@5.7.2/node_modules/typescript/node_modules:/Users/seal/Documents/projects/tachybase/node_modules/.pnpm/typescript@5.7.2/node_modules:/Users/seal/Documents/projects/tachybase/node_modules/.pnpm/node_modules"
|
|
10
|
+
else
|
|
11
|
+
export NODE_PATH="/Users/seal/Documents/projects/tachybase/node_modules/.pnpm/typescript@5.7.2/node_modules/typescript/bin/node_modules:/Users/seal/Documents/projects/tachybase/node_modules/.pnpm/typescript@5.7.2/node_modules/typescript/node_modules:/Users/seal/Documents/projects/tachybase/node_modules/.pnpm/typescript@5.7.2/node_modules:/Users/seal/Documents/projects/tachybase/node_modules/.pnpm/node_modules:$NODE_PATH"
|
|
12
|
+
fi
|
|
13
|
+
if [ -x "$basedir/node" ]; then
|
|
14
|
+
exec "$basedir/node" "$basedir/../../../../typescript/bin/tsserver" "$@"
|
|
15
|
+
else
|
|
16
|
+
exec node "$basedir/../../../../typescript/bin/tsserver" "$@"
|
|
17
|
+
fi
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"name":"@remix-run/express","version":"2.15.2","description":"Express server request handler for Remix","bugs":{"url":"https://github.com/remix-run/remix/issues"},"repository":{"type":"git","url":"https://github.com/remix-run/remix","directory":"packages/remix-express"},"license":"MIT","main":"dist/index.js","typings":"dist/index.d.ts","dependencies":{"@remix-run/node":"2.15.2"},"devDependencies":{"@types/express":"^4.17.9","@types/node":"^18.17.1","@types/supertest":"^2.0.10","express":"^4.20.0","node-mocks-http":"^1.10.1","supertest":"^6.3.3","typescript":"^5.1.6"},"peerDependencies":{"express":"^4.20.0","typescript":"^5.1.0"},"peerDependenciesMeta":{"typescript":{"optional":true}},"engines":{"node":">=18.0.0"},"files":["dist/","CHANGELOG.md","LICENSE.md","README.md"],"scripts":{"tsc":"tsc"},"_lastModified":"2024-12-22T16:05:18.888Z"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
(The MIT License)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2009-2014 TJ Holowaychuk <tj@vision-media.ca>
|
|
4
|
+
Copyright (c) 2013-2014 Roman Shtylman <shtylman+expressjs@gmail.com>
|
|
5
|
+
Copyright (c) 2014-2015 Douglas Christopher Wilson <doug@somethingdoug.com>
|
|
6
|
+
|
|
7
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
8
|
+
a copy of this software and associated documentation files (the
|
|
9
|
+
'Software'), to deal in the Software without restriction, including
|
|
10
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
11
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
12
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
13
|
+
the following conditions:
|
|
14
|
+
|
|
15
|
+
The above copyright notice and this permission notice shall be
|
|
16
|
+
included in all copies or substantial portions of the Software.
|
|
17
|
+
|
|
18
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
|
19
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
20
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
21
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
22
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
23
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
24
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|