-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
44 changed files
with
1,157 additions
and
334 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
// export { dead_links as reroute } from "$lib/middleware/dead-links"; |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
61 changes: 0 additions & 61 deletions
61
apps/console/src/lib/components/auth/user-auth-form.svelte
This file was deleted.
Oops, something went wrong.
30 changes: 30 additions & 0 deletions
30
apps/console/src/lib/components/layout/flash-message-toast.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<script lang="ts"> | ||
// Ref: https://github.com/hansaskov/my-skeleton-app/blob/master/src/lib/components/FlashMessageToast.svelte | ||
import { getFlash } from 'sveltekit-flash-message/client'; | ||
import { Toast, getToastStore } from '@skeletonlabs/skeleton'; | ||
import { page } from '$app/stores'; | ||
import { afterNavigate } from '$app/navigation'; | ||
import { handleMessage } from './toast-manager'; | ||
const toastStore = getToastStore(); | ||
const flash = getFlash(page, { | ||
clearOnNavigate: false | ||
// flashCookieOptions: { sameSite: 'lax' } | ||
}); | ||
let isGotoNavigated = false; | ||
afterNavigate(({ type }) => { | ||
isGotoNavigated = ['goto'].includes(type as string); | ||
}); | ||
flash.subscribe(($flash) => { | ||
if (!$flash) return; | ||
if (!isGotoNavigated) return; | ||
handleMessage($flash, toastStore); | ||
}); | ||
</script> | ||
|
||
<Toast position="b" /> | ||
<!-- <Toast position="br" rounded="rounded-lg" padding="px-3 py-2" /> --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import type { ToastSettings, ToastStore } from '@skeletonlabs/skeleton'; | ||
|
||
export function handleMessage(message: App.Superforms.Message, toastStore: ToastStore) { | ||
let background = 'variant-filled-success'; | ||
if (message.type === 'error') { | ||
background = 'variant-filled-error'; | ||
} else if (message.type === 'warning') { | ||
background = 'variant-filled-warning'; | ||
} | ||
toastStore.trigger({ ...message, background } satisfies ToastSettings); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import type { Reroute } from '@sveltejs/kit'; | ||
import { Logger } from '@spectacular/utils'; | ||
|
||
export const log = new Logger('universal:middleware:dead-links'); | ||
|
||
const dead_links_redirect_to: Record<string, string> = { | ||
'/api/fragments': '/api/fragment', | ||
'/api/vite': '/api/vite-plugin', | ||
'/blog/feed': ' /blog/feed.xml', | ||
'/api/cli': '/api/command-line', | ||
'/intro/fragments': '/intro/reusing-parts-of-a-query', | ||
'/api/graphql': '/api/graphql-magic', | ||
'/guides/plugin': '/guides/plugin-directory' | ||
}; | ||
|
||
/** | ||
* Handle Dead Links | ||
* TODO: this is replacemnt for src/lib/server/middleware/links.ts handler. | ||
* use it in hooks.ts | ||
*/ | ||
export const dead_links: Reroute = ({ url }) => { | ||
// If we have a value, let's redirect | ||
const reroutedPath = dead_links_redirect_to[url.pathname]; | ||
if (url.pathname in dead_links_redirect_to) { | ||
log.debug(`redirecting ${url.pathname} to ${reroutedPath}`); | ||
return dead_links_redirect_to[url.pathname]; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { RateLimiter } from 'sveltekit-rate-limiter/server'; | ||
import { RATE_LIMITER_KEY } from '$env/static/private'; | ||
|
||
export const limiter = new RateLimiter({ | ||
// A rate is defined as [number, unit] | ||
rates: { | ||
IP: [10, 'h'], // IP address limiter | ||
IPUA: [5, 'm'], // IP + User Agent limiter | ||
cookie: { | ||
// Cookie limiter | ||
name: 'limiterid', // Unique cookie name for this limiter | ||
secret: RATE_LIMITER_KEY, // Use $env/static/private | ||
rate: [2, 'm'], | ||
preflight: true // Require preflight call (see load function) | ||
} | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.