houdini-react 1.2.10 → 1.2.12
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/build/plugin/index.d.ts +1 -12
- package/build/plugin-cjs/index.js +20364 -105926
- package/build/plugin-esm/index.js +20360 -105921
- package/build/runtime-cjs/routing/components/Router.js +111 -38
- package/build/runtime-esm/routing/components/Router.js +111 -38
- package/package.json +3 -2
- package/build/runtime/server/compat.d.ts +0 -7
- package/build/runtime/server/index.d.ts +0 -17
- package/build/runtime/server/session.d.ts +0 -3
- package/build/runtime-cjs/server/compat.d.ts +0 -7
- package/build/runtime-cjs/server/compat.js +0 -52
- package/build/runtime-cjs/server/index.d.ts +0 -17
- package/build/runtime-cjs/server/index.js +0 -54
- package/build/runtime-cjs/server/session.d.ts +0 -3
- package/build/runtime-cjs/server/session.js +0 -61
- package/build/runtime-esm/server/compat.d.ts +0 -7
- package/build/runtime-esm/server/compat.js +0 -28
- package/build/runtime-esm/server/index.d.ts +0 -17
- package/build/runtime-esm/server/index.js +0 -30
- package/build/runtime-esm/server/session.d.ts +0 -3
- package/build/runtime-esm/server/session.js +0 -30
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
function dev_server({ server, config }) {
|
|
2
|
-
return {
|
|
3
|
-
use(fn) {
|
|
4
|
-
server.use((req, res, next) => {
|
|
5
|
-
fn(
|
|
6
|
-
{
|
|
7
|
-
url: req.url,
|
|
8
|
-
headers: new Headers(req.headers)
|
|
9
|
-
},
|
|
10
|
-
{
|
|
11
|
-
...res,
|
|
12
|
-
redirect(url, status = 307) {
|
|
13
|
-
res.statusCode = status;
|
|
14
|
-
res.setHeader("location", url);
|
|
15
|
-
res.setHeader("content-length", "0");
|
|
16
|
-
return res.end();
|
|
17
|
-
},
|
|
18
|
-
set_header: res.setHeader.bind(res)
|
|
19
|
-
},
|
|
20
|
-
next
|
|
21
|
-
);
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
export {
|
|
27
|
-
dev_server
|
|
28
|
-
};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type { Config } from 'houdini';
|
|
2
|
-
export declare function configure_server({ server, config }: {
|
|
3
|
-
server: Server;
|
|
4
|
-
config: Config;
|
|
5
|
-
}): void;
|
|
6
|
-
export type Server = {
|
|
7
|
-
use(fn: ServerMiddleware): void;
|
|
8
|
-
};
|
|
9
|
-
export type ServerMiddleware = (req: IncomingRequest, res: ServerResponse, next: () => void) => void;
|
|
10
|
-
export type IncomingRequest = {
|
|
11
|
-
url?: string;
|
|
12
|
-
headers: Headers;
|
|
13
|
-
};
|
|
14
|
-
export type ServerResponse = {
|
|
15
|
-
redirect(url: string, status?: number): void;
|
|
16
|
-
set_header(name: string, value: string): void;
|
|
17
|
-
};
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { plugin_config as get_plugin_config } from "../../plugin/config";
|
|
2
|
-
import { set_session } from "./session";
|
|
3
|
-
function configure_server({ server, config }) {
|
|
4
|
-
server.use(server_handler({ config }));
|
|
5
|
-
}
|
|
6
|
-
function server_handler({ config }) {
|
|
7
|
-
const plugin_config = get_plugin_config(config);
|
|
8
|
-
return (req, res, next) => {
|
|
9
|
-
if (!req.url) {
|
|
10
|
-
next();
|
|
11
|
-
return;
|
|
12
|
-
}
|
|
13
|
-
if (plugin_config.auth && "redirect" in plugin_config.auth && req.url.startsWith(plugin_config.auth.redirect)) {
|
|
14
|
-
return redirect_auth(req, res, next);
|
|
15
|
-
}
|
|
16
|
-
next();
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
const redirect_auth = (req, res, next) => {
|
|
20
|
-
const { searchParams } = new URL(req.url, `http://${req.headers.get("host")}`);
|
|
21
|
-
const { redirectTo, ...session } = Object.fromEntries(searchParams.entries());
|
|
22
|
-
set_session(res, session);
|
|
23
|
-
if (redirectTo) {
|
|
24
|
-
return res.redirect(redirectTo);
|
|
25
|
-
}
|
|
26
|
-
next();
|
|
27
|
-
};
|
|
28
|
-
export {
|
|
29
|
-
configure_server
|
|
30
|
-
};
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import cookieParser from "cookie-parser";
|
|
2
|
-
const session_cookie_name = "__houdini__";
|
|
3
|
-
function set_session(res, value) {
|
|
4
|
-
const today = new Date();
|
|
5
|
-
const expires = new Date(today.getTime() + 7 * 24 * 60 * 60 * 1e3);
|
|
6
|
-
const serialized = JSON.stringify(value);
|
|
7
|
-
res.set_header(
|
|
8
|
-
"Set-Cookie",
|
|
9
|
-
`${session_cookie_name}=${serialized}; Path=/; HttpOnly; Secure; SameSite=Lax; Expires=${expires.toUTCString()} `
|
|
10
|
-
);
|
|
11
|
-
}
|
|
12
|
-
function get_session(req, secrets) {
|
|
13
|
-
const cookie = req.get("cookie");
|
|
14
|
-
if (!cookie) {
|
|
15
|
-
return {};
|
|
16
|
-
}
|
|
17
|
-
const parsed = cookieParser.signedCookie(cookie, secrets);
|
|
18
|
-
if (!parsed) {
|
|
19
|
-
return {};
|
|
20
|
-
}
|
|
21
|
-
const houdini_session_cookie = parsed.split(";").map((s) => s.trim().split("=")).filter((s) => s[0] === session_cookie_name);
|
|
22
|
-
if (houdini_session_cookie.length === 1) {
|
|
23
|
-
return JSON.parse(houdini_session_cookie[0][1]);
|
|
24
|
-
}
|
|
25
|
-
return {};
|
|
26
|
-
}
|
|
27
|
-
export {
|
|
28
|
-
get_session,
|
|
29
|
-
set_session
|
|
30
|
-
};
|