Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Breaking: use Request and Response objects in endpoints and hooks #3384

Merged
merged 41 commits into from
Jan 19, 2022
Merged
Changes from 1 commit
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
37ad3e2
this should be an internal type
Rich-Harris Jan 17, 2022
df834ca
change app.render return type to Response
Rich-Harris Jan 17, 2022
2f4ca67
update adapters
Rich-Harris Jan 17, 2022
1cc7e35
Merge branch 'master' into streams
Rich-Harris Jan 17, 2022
cc4be79
merge master -> streams
Rich-Harris Jan 17, 2022
b7eb5b9
lint
Rich-Harris Jan 17, 2022
46b36dd
fix tests
Rich-Harris Jan 17, 2022
b3b00d8
app.render takes a Request as input
Rich-Harris Jan 17, 2022
d6fcac3
only read body once
Rich-Harris Jan 17, 2022
44c9ae2
update adapters, remove host/protocol options
Rich-Harris Jan 18, 2022
a1bccb3
lint
Rich-Harris Jan 18, 2022
3ce5ac3
remove obsolete origin test
Rich-Harris Jan 18, 2022
2fbb868
change endpoint signature
Rich-Harris Jan 18, 2022
365f65e
fix vercel adapter
Rich-Harris Jan 18, 2022
0f1e6b1
add setResponse helper
Rich-Harris Jan 18, 2022
b006980
allow returning Response or Headers from endpoints
Rich-Harris Jan 18, 2022
d4d7ac9
fixes
Rich-Harris Jan 18, 2022
fb4d608
lint
Rich-Harris Jan 18, 2022
aed1edc
update docs
Rich-Harris Jan 18, 2022
90c3090
update adapter-node docs
Rich-Harris Jan 18, 2022
c2e9399
docs
Rich-Harris Jan 18, 2022
50d2b5e
merge master -> streams
Rich-Harris Jan 18, 2022
f05e724
whoops
Rich-Harris Jan 18, 2022
62c6a77
changesets
Rich-Harris Jan 18, 2022
d216ebb
pointless commit to try and trick netlify into working
Rich-Harris Jan 18, 2022
75abe9f
update template
Rich-Harris Jan 18, 2022
8bbfc98
changeset
Rich-Harris Jan 18, 2022
865d124
work around zip-it-and-ship-it bug
Rich-Harris Jan 18, 2022
5293c71
Update .changeset/large-icons-complain.md
Rich-Harris Jan 18, 2022
501dd33
Update .changeset/mighty-pandas-search.md
Rich-Harris Jan 18, 2022
9c20e7e
Update .changeset/strong-schools-rule.md
Rich-Harris Jan 18, 2022
f3286d7
Update documentation/docs/04-hooks.md
Rich-Harris Jan 19, 2022
ca2760e
Update packages/adapter-node/README.md
Rich-Harris Jan 19, 2022
2672f50
reduce indentation
Rich-Harris Jan 19, 2022
53fb367
merge master -> streams
Rich-Harris Jan 19, 2022
9b506f1
add more types to adapters, to reflect these changes
Rich-Harris Jan 19, 2022
84f6136
Update documentation/docs/10-adapters.md
Rich-Harris Jan 19, 2022
e05cf2c
better error messages
Rich-Harris Jan 19, 2022
3abcaec
helpful errors for removed config options
Rich-Harris Jan 19, 2022
57b4670
Merge branch 'streams' of github.com:sveltejs/kit into streams
Rich-Harris Jan 19, 2022
7a5a03a
fix tests
Rich-Harris Jan 19, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
only read body once
  • Loading branch information
Rich-Harris committed Jan 17, 2022
commit d6fcac3f0558be9ac200c1c17a63d8846864295b
6 changes: 4 additions & 2 deletions packages/kit/src/core/adapt/prerender/prerender.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,11 +174,13 @@ export async function prerender({ cwd, out, log, config, build_data, fallback, a
return;
}

const text = await rendered.text();

if (rendered.status === 200) {
mkdirp(dirname(file));

log.info(`${rendered.status} ${decoded_path}`);
writeFileSync(file, await rendered.text());
writeFileSync(file, text);
paths.push(normalize(decoded_path));
} else if (response_type !== OK) {
error({ status: rendered.status, path, referrer, referenceType: 'linked' });
Expand Down Expand Up @@ -215,7 +217,7 @@ export async function prerender({ cwd, out, log, config, build_data, fallback, a
});

if (is_html && config.kit.prerender.crawl) {
for (const href of crawl(await rendered.text())) {
for (const href of crawl(text)) {
if (href.startsWith('data:') || href.startsWith('#')) continue;

const resolved = resolve(path, href);
Expand Down