working docker compose
This commit is contained in:
parent
24bb9a5b92
commit
e9df8c8fcf
@ -27,7 +27,7 @@ services:
|
||||
- sqlite:/database/
|
||||
environment:
|
||||
- DATABASE_URL=file:/database/db.sqlite
|
||||
- FRONTEND_URL=http://0.0.0.0:3000
|
||||
- FRONTEND_URL=http://localhost:3000
|
||||
depends_on:
|
||||
- migrate
|
||||
|
||||
|
Binary file not shown.
Binary file not shown.
@ -9,7 +9,7 @@ RUN npm ci
|
||||
# Copy all local files into the image.
|
||||
COPY . .
|
||||
|
||||
ENV VITE_BACKEND_URL="http://0.0.0.0:8080"
|
||||
ENV VITE_SERVER_INTERNAL="http://server:8080"
|
||||
ENV VITE_BRANDING="Noteshare.space"
|
||||
|
||||
RUN npm run build
|
||||
@ -20,8 +20,7 @@ RUN npm prune --production
|
||||
FROM node:16-alpine
|
||||
|
||||
WORKDIR /app
|
||||
COPY --from=0 /app .
|
||||
COPY . .
|
||||
COPY --from=BUILD_IMAGE /app .
|
||||
|
||||
EXPOSE 3000
|
||||
CMD ["node", "./build"]
|
@ -1,48 +1,57 @@
|
||||
<script context="module" , lang="ts">
|
||||
import type { Load } from '@sveltejs/kit';
|
||||
import type { EncryptedNote } from '$lib/model/EncryptedNote';
|
||||
|
||||
export const load: Load = async ({ params, fetch, session, stuff }) => {
|
||||
const url = `${import.meta.env.VITE_BACKEND_URL}/note/${params.id}`;
|
||||
const response = await fetch(url);
|
||||
export const load: Load = async ({ props }) => {
|
||||
const note: EncryptedNote = props.note;
|
||||
const maxage = Math.floor((note.expire_time.valueOf() - note.insert_time.valueOf()) / 1000);
|
||||
return {
|
||||
status: 200,
|
||||
cache: {
|
||||
maxage: maxage,
|
||||
private: false
|
||||
},
|
||||
props: { note }
|
||||
};
|
||||
|
||||
if (response.ok) {
|
||||
try {
|
||||
const note: EncryptedNote = await response.json();
|
||||
note.insert_time = new Date(note.insert_time as unknown as string);
|
||||
note.expire_time = new Date(note.expire_time as unknown as string);
|
||||
const maxage = Math.floor((note.expire_time.valueOf() - note.insert_time.valueOf()) / 1000);
|
||||
return {
|
||||
status: response.status,
|
||||
cache: {
|
||||
maxage: maxage,
|
||||
private: false
|
||||
},
|
||||
props: { note }
|
||||
};
|
||||
} catch {
|
||||
return {
|
||||
status: 500,
|
||||
error: response.statusText
|
||||
};
|
||||
}
|
||||
} else {
|
||||
return {
|
||||
status: response.status,
|
||||
error: response.statusText
|
||||
};
|
||||
}
|
||||
// if (response.ok) {
|
||||
// try {
|
||||
// const note: EncryptedNote = await response.json();
|
||||
// note.insert_time = new Date(note.insert_time as unknown as string);
|
||||
// note.expire_time = new Date(note.expire_time as unknown as string);
|
||||
// const maxage = Math.floor((note.expire_time.valueOf() - note.insert_time.valueOf()) / 1000);
|
||||
// return {
|
||||
// status: response.status,
|
||||
// cache: {
|
||||
// maxage: maxage,
|
||||
// private: false
|
||||
// },
|
||||
// props: { note }
|
||||
// };
|
||||
// } catch {
|
||||
// return {
|
||||
// status: 500,
|
||||
// error: response.statusText
|
||||
// };
|
||||
// }
|
||||
// } else {
|
||||
// return {
|
||||
// status: response.status,
|
||||
// error: response.statusText
|
||||
// };
|
||||
// }
|
||||
};
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
import { onMount } from 'svelte';
|
||||
import { browser } from '$app/env';
|
||||
import decrypt from '$lib/crypto/decrypt';
|
||||
import MarkdownRenderer from '$lib/components/MarkdownRenderer.svelte';
|
||||
import LogoMarkdown from 'svelte-icons/io/IoLogoMarkdown.svelte';
|
||||
import IconEncrypted from 'svelte-icons/md/MdLockOutline.svelte';
|
||||
import type { EncryptedNote } from '$lib/model/EncryptedNote';
|
||||
import { browser } from '$app/env';
|
||||
|
||||
// Auto-loaded from [id].ts endpoint
|
||||
export let note: EncryptedNote;
|
||||
let plaintext: string;
|
||||
let timeString: string;
|
||||
|
37
webapp/src/routes/note/[id].ts
Normal file
37
webapp/src/routes/note/[id].ts
Normal file
@ -0,0 +1,37 @@
|
||||
import type { EncryptedNote } from '$lib/model/EncryptedNote';
|
||||
import type { RequestHandler } from '@sveltejs/kit';
|
||||
|
||||
export const get: RequestHandler = async ({ params }) => {
|
||||
const url = `${import.meta.env.VITE_SERVER_INTERNAL}/note/${params.id}`;
|
||||
const response = await fetch(url);
|
||||
|
||||
if (response.ok) {
|
||||
try {
|
||||
const note: EncryptedNote = await response.json();
|
||||
note.insert_time = new Date(note.insert_time as unknown as string);
|
||||
note.expire_time = new Date(note.expire_time as unknown as string);
|
||||
const maxage = Math.floor((note.expire_time.valueOf() - note.insert_time.valueOf()) / 1000);
|
||||
return {
|
||||
status: response.status,
|
||||
headers: {
|
||||
'Cache-Control': `public, max-age=${maxage}`
|
||||
},
|
||||
cache: {
|
||||
maxage: maxage,
|
||||
private: false
|
||||
},
|
||||
body: { note }
|
||||
};
|
||||
} catch {
|
||||
return {
|
||||
status: 500,
|
||||
error: response.statusText
|
||||
};
|
||||
}
|
||||
} else {
|
||||
return {
|
||||
status: response.status,
|
||||
error: response.statusText
|
||||
};
|
||||
}
|
||||
};
|
Loading…
Reference in New Issue
Block a user