chore: 🏗️ Migrate to SvelteKit 1.0.0
This commit is contained in:
parent
308fffbefe
commit
689f232cbb
2
proxy.js
2
proxy.js
@ -14,7 +14,7 @@ app.use(
|
|||||||
app.use(
|
app.use(
|
||||||
"/",
|
"/",
|
||||||
createProxyMiddleware({
|
createProxyMiddleware({
|
||||||
target: "http://localhost:3000",
|
target: "http://localhost:5173",
|
||||||
changeOrigin: true,
|
changeOrigin: true,
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
@ -6,9 +6,8 @@
|
|||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite dev",
|
"dev": "vite dev",
|
||||||
"build": "svelte-kit build",
|
"build": "vite build",
|
||||||
"package": "svelte-kit package",
|
"preview": "vite preview",
|
||||||
"preview": "svelte-kit preview",
|
|
||||||
"check": "svelte-check --tsconfig ./tsconfig.json",
|
"check": "svelte-check --tsconfig ./tsconfig.json",
|
||||||
"check:watch": "svelte-check --tsconfig ./tsconfig.json --watch",
|
"check:watch": "svelte-check --tsconfig ./tsconfig.json --watch",
|
||||||
"lint": "prettier --check --plugin-search-dir=. . && eslint .",
|
"lint": "prettier --check --plugin-search-dir=. . && eslint .",
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { browser } from '$app/env';
|
import { browser } from '$app/environment';
|
||||||
|
|
||||||
import { onMount } from 'svelte';
|
import { onMount } from 'svelte';
|
||||||
import Callout from './Callout.svelte';
|
import Callout from './Callout.svelte';
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { browser } from '$app/env';
|
import { browser } from '$app/environment';
|
||||||
|
|
||||||
import { onMount } from 'svelte';
|
import { onMount } from 'svelte';
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { browser } from '$app/env';
|
import { browser } from '$app/environment';
|
||||||
|
|
||||||
import Footer from '$lib/components/Footer.svelte';
|
import Footer from '$lib/components/Footer.svelte';
|
||||||
import NavBar from '$lib/components/navbar/NavBar.svelte';
|
import NavBar from '$lib/components/navbar/NavBar.svelte';
|
||||||
|
@ -3,8 +3,8 @@ import type { PageServerLoad } from './$types';
|
|||||||
|
|
||||||
import { error } from '@sveltejs/kit';
|
import { error } from '@sveltejs/kit';
|
||||||
|
|
||||||
export const get: PageServerLoad = async ({ request, clientAddress, params, setHeaders }) => {
|
export const load: PageServerLoad = async ({ request, params, setHeaders, getClientAddress }) => {
|
||||||
const ip = (request.headers.get('x-forwarded-for') || clientAddress) as string;
|
const ip = (request.headers.get('x-forwarded-for') || getClientAddress()) as string;
|
||||||
const url = `${import.meta.env.VITE_SERVER_INTERNAL}/api/note/${params.id}`;
|
const url = `${import.meta.env.VITE_SERVER_INTERNAL}/api/note/${params.id}`;
|
||||||
const response = await fetch(url, {
|
const response = await fetch(url, {
|
||||||
headers: {
|
headers: {
|
||||||
@ -20,7 +20,7 @@ export const get: PageServerLoad = async ({ request, clientAddress, params, setH
|
|||||||
const maxage = Math.floor((note.expire_time.valueOf() - note.insert_time.valueOf()) / 1000);
|
const maxage = Math.floor((note.expire_time.valueOf() - note.insert_time.valueOf()) / 1000);
|
||||||
|
|
||||||
setHeaders({
|
setHeaders({
|
||||||
maxage: maxage,
|
maxage: `${maxage}`,
|
||||||
'Cache-Control': `max-age=${maxage}, public`
|
'Cache-Control': `max-age=${maxage}, public`
|
||||||
});
|
});
|
||||||
return { note };
|
return { note };
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
import MarkdownRenderer from '$lib/components/MarkdownRenderer.svelte';
|
import MarkdownRenderer from '$lib/components/MarkdownRenderer.svelte';
|
||||||
import LogoMarkdown from 'svelte-icons/io/IoLogoMarkdown.svelte';
|
import LogoMarkdown from 'svelte-icons/io/IoLogoMarkdown.svelte';
|
||||||
import IconEncrypted from 'svelte-icons/md/MdLockOutline.svelte';
|
import IconEncrypted from 'svelte-icons/md/MdLockOutline.svelte';
|
||||||
import { browser } from '$app/env';
|
import { browser } from '$app/environment';
|
||||||
import RawRenderer from '$lib/components/RawRenderer.svelte';
|
import RawRenderer from '$lib/components/RawRenderer.svelte';
|
||||||
import LogoDocument from 'svelte-icons/md/MdUndo.svelte';
|
import LogoDocument from 'svelte-icons/md/MdUndo.svelte';
|
||||||
import Dismissable from '$lib/components/Dismissable.svelte';
|
import Dismissable from '$lib/components/Dismissable.svelte';
|
||||||
|
@ -1,14 +0,0 @@
|
|||||||
import type { EncryptedNote } from '$lib/model/EncryptedNote';
|
|
||||||
import type { PageLoad } from './$types';
|
|
||||||
|
|
||||||
export const load: PageLoad = async ({ data, setHeaders }) => {
|
|
||||||
const note: EncryptedNote = data.note;
|
|
||||||
const maxage = Math.floor((note.expire_time.valueOf() - note.insert_time.valueOf()) / 1000);
|
|
||||||
|
|
||||||
setHeaders({
|
|
||||||
maxage: maxage,
|
|
||||||
'Cache-Control': `max-age=${maxage}, public`
|
|
||||||
});
|
|
||||||
|
|
||||||
return { note };
|
|
||||||
};
|
|
Loading…
x
Reference in New Issue
Block a user