-
Notifications
You must be signed in to change notification settings - Fork 0
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
1 parent
6280a00
commit 22966f1
Showing
5 changed files
with
49 additions
and
15 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import type { HandleServerError, Handle } from '@sveltejs/kit'; | ||
import { sequence } from '@sveltejs/kit/hooks'; | ||
import ejs from 'ejs'; | ||
import { uuid } from '$lib/utils/uuid'; | ||
|
||
const baseHandle: Handle = async ({ event, resolve }) => { | ||
return resolve(event, { | ||
transformPageChunk: ({ html }) => | ||
ejs.render(html, { | ||
env: { COMMIT_SHA: process.env.COMMIT_SHA } | ||
}) | ||
}); | ||
}; | ||
|
||
const handleSession: Handle = async ({ event, resolve }) => { | ||
event.locals.sessionId = uuid(); | ||
return resolve(event); | ||
}; | ||
|
||
export const handle = sequence(baseHandle, handleSession); | ||
|
||
export const handleError: HandleServerError = ({ error, status, event, message }) => { | ||
console.error('handleServerError', { error, event }); | ||
const errorId = crypto.randomUUID(); | ||
return { | ||
status, | ||
message: `Internal Server Errors.\n${message}`, | ||
errorId | ||
}; | ||
}; |
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 |
---|---|---|
@@ -1,10 +1,9 @@ | ||
import { uuid } from '$lib/utils/uuid'; | ||
import type { LayoutServerLoad } from './$types'; | ||
|
||
export const ssr = true; | ||
export const prerender = false; | ||
export const load: LayoutServerLoad = () => { | ||
export const load: LayoutServerLoad = ({ locals }) => { | ||
return { | ||
sessionId: uuid() | ||
sessionId: locals.sessionId | ||
}; | ||
}; |
This file was deleted.
Oops, something went wrong.
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,14 @@ | ||
import { error, redirect } from '@sveltejs/kit'; | ||
import type { PageLoad } from './$types'; | ||
|
||
export const load: PageLoad = async ({ url, parent }) => { | ||
const category = url.searchParams.get('category'); | ||
if (!category) error(400, 'Audio category was not found'); | ||
|
||
const { sessionId } = await parent(); | ||
if (url.pathname !== `/${sessionId}`) redirect(307, '/'); | ||
|
||
return { | ||
category | ||
}; | ||
}; |