-
Notifications
You must be signed in to change notification settings - Fork 120
feat(hn): update deps, edge based #528
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
Changes from all commits
0fa0137
7702296
c64c416
7a8e0c2
b87ff93
012a185
838337f
1cacc88
dda11ac
27ca4c2
17bb074
37fb3d6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,7 @@ | ||
| { | ||
| "extends": "./.svelte-kit/tsconfig.json" | ||
| "extends": "./.svelte-kit/tsconfig.json", | ||
| "compilerOptions": { | ||
| "noImplicitAny": true, | ||
| "checkJs": true | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,9 @@ | ||
| /// <reference types="@sveltejs/kit" /> | ||
|
|
||
| declare global { | ||
| namespace App { | ||
| interface Error { | ||
| frame?: string; | ||
| } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| <script> | ||
| /** @type {string} */ | ||
| export let section; | ||
| </script> | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| import { dev } from '$app/environment'; | ||
| import { redirect } from '@sveltejs/kit'; | ||
|
|
||
| /** @type {import('./$types').PageLoad} */ | ||
| export function load({ url }) { | ||
| throw redirect(url.hostname === 'localhost' || url.hostname === '127.0.0.1' ? 302 : 301, '/top/1'); | ||
| export function load() { | ||
| throw redirect(dev ? 302 : 301, '/top/1'); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,9 @@ | ||
| /** @type {import('./$types').PageLoad} */ | ||
benmccann marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| export async function load({ params, fetch }) { | ||
| const list = params.list === 'top' ? 'news' : params.list === 'new' ? 'newest' : params.list; | ||
|
|
||
| return { | ||
| list: params.list, | ||
| page: +params.page, | ||
| items: await fetch(`https://api.hnpwa.com/v0/${list}/${params.page}.json`).then((r) => r.json()) | ||
| items: fetch(`https://api.hnpwa.com/v0/${list}/${params.page}.json`).then((r) => r.json()) | ||
| }; | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,3 @@ | ||
| /** @type {import('./$types').PageLoad} */ | ||
| export async function load({ params, fetch }) { | ||
| const res = await fetch(`https://api.hnpwa.com/v0/item/${params.id}.json`); | ||
| return await res.json(); | ||
| return fetch(`https://api.hnpwa.com/v0/item/${params.id}.json`).then((r) => r.json()); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,6 @@ | ||
| import { dev } from '$app/environment'; | ||
| import { redirect } from '@sveltejs/kit'; | ||
|
|
||
| /** @type {import('@sveltejs/kit').RequestHandler} */ | ||
| export function GET() { | ||
| throw redirect(dev ? 301 : 302, '/top/rss'); | ||
| } |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,7 +1,5 @@ | ||||||
| export const csr = false; | ||||||
|
|
||||||
| /** @type {import('./$types').PageLoad} */ | ||||||
| export async function load({ params, fetch }) { | ||||||
| const res = await fetch(`https://api.hnpwa.com/v0/user/${params.name}.json`); | ||||||
| return res.json(); | ||||||
| return fetch(`https://api.hnpwa.com/v0/user/${params.name}.json`).then((r) => r.json()); | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. making it one line makes sense, but why not use
Suggested change
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I dunno, await has felt weird when surrounded by brackets. .then feels cleaner for this case somehow
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What happens if invalid JSON is returned from the API? I think the two ways of writing it would behave differently, but I'm not exactly sure what the behavior of the
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's the same. If it errors, then .json() errors out, giving the same error as await version |
||||||
| } | ||||||
Uh oh!
There was an error while loading. Please reload this page.