Skip to content

Commit b3a0ed7

Browse files
committed
✨ Docker image, ready for deployment, editing launch URL
1 parent 6306b9a commit b3a0ed7

File tree

11 files changed

+158
-61
lines changed

11 files changed

+158
-61
lines changed

.dockerignore

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
node_modules
2+
3+
# Output
4+
.output
5+
.vercel
6+
/.svelte-kit
7+
/build
8+
9+
# OS
10+
.DS_Store
11+
Thumbs.db
12+
13+
# Env
14+
.env
15+
.env.*
16+
!.env.example
17+
!.env.test
18+
19+
# Vite
20+
vite.config.js.timestamp-*
21+
vite.config.ts.timestamp-*
22+
23+
$houdini

Dockerfile

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# use the official Bun image
2+
# see all versions at https://hub.docker.com/r/oven/bun/tags
3+
FROM oven/bun:1 AS base
4+
WORKDIR /usr/src/app
5+
6+
# install dependencies into temp directory
7+
# this will cache them and speed up future builds
8+
FROM base AS install
9+
RUN mkdir -p /temp/dev
10+
COPY patches/* /temp/dev/patches/
11+
COPY package.json bun.lockb /temp/dev/
12+
RUN cd /temp/dev && bun install --frozen-lockfile
13+
14+
# install with --production (exclude devDependencies)
15+
RUN mkdir -p /temp/prod
16+
COPY patches/* /temp/prod/patches/
17+
COPY package.json bun.lockb /temp/prod/
18+
RUN cd /temp/prod && bun install --frozen-lockfile --production
19+
20+
# copy node_modules from temp directory
21+
# then copy all (non-ignored) project files into the image
22+
FROM base AS runner
23+
RUN apt update && apt install -y watchman
24+
COPY --from=install /temp/dev/node_modules node_modules
25+
COPY . .
26+
27+
ENV NODE_ENV=production
28+
RUN bun run build
29+
30+
EXPOSE 3000/tcp
31+
EXPOSE 5000/tcp
32+
ENTRYPOINT [ "bun", "startall" ]

bun.lockb

-32 Bytes
Binary file not shown.

houdini.config.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ const config = {
1515
},
1616
NonEmptyString: {
1717
type: 'string'
18+
},
19+
URL: {
20+
type: 'string'
1821
}
1922
}
2023
};

package.json

Lines changed: 56 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,58 @@
11
{
2-
"name": "inp-net-developers",
3-
"version": "0.0.1",
4-
"type": "module",
5-
"scripts": {
6-
"dev": "concurrently 'bun vite dev' 'bun hive-gateway supergraph --port 5000'",
7-
"build": "vite build",
8-
"preview": "vite preview",
9-
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
10-
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
11-
"format": "prettier --write .",
12-
"lint": "prettier --check . && eslint ."
13-
},
14-
"devDependencies": {
15-
"@ewen-lbh/houdini": "^1.4.0",
16-
"@graphql-hive/gateway": "^1.4.12",
17-
"@graphql-mesh/compose-cli": "^1.1.8",
18-
"@omnigraph/openapi": "^0.107.6",
19-
"@parcel/watcher": "^2.5.0",
20-
"@sveltejs/adapter-auto": "^3.0.0",
21-
"@sveltejs/kit": "^2.0.0",
22-
"@sveltejs/vite-plugin-svelte": "^4.0.0",
23-
"@types/eslint": "^9.6.0",
24-
"@types/slug": "^5.0.9",
25-
"concurrently": "^9.1.0",
26-
"eslint": "^9.7.0",
27-
"eslint-config-prettier": "^9.1.0",
28-
"eslint-plugin-svelte": "^2.36.0",
29-
"globals": "^15.0.0",
30-
"houdini-svelte": "^2.0.0",
31-
"mdsvex": "^0.11.2",
32-
"prettier": "^3.3.2",
33-
"prettier-plugin-svelte": "^3.2.6",
34-
"svelte": "^5.0.0",
35-
"svelte-check": "^4.0.0",
36-
"typescript": "^5.0.0",
37-
"typescript-eslint": "^8.0.0",
38-
"vite": "^5.0.3"
39-
},
40-
"dependencies": {
41-
"@graphql-mesh/migrate-config-cli": "^1.2.3",
42-
"@graphql-mesh/transform-filter-schema": "^0.102.12",
43-
"@graphql-mesh/transform-naming-convention": "^0.102.12",
44-
"@graphql-mesh/transform-prefix": "^0.102.12",
45-
"@graphql-mesh/transform-rename": "^0.102.12",
46-
"@graphql-mesh/transform-type-merging": "^0.102.12",
47-
"arctic": "^2.2.2",
48-
"dotenv": "^16.4.5",
49-
"graphql": "^16.9.0",
50-
"slug": "^10.0.0"
51-
},
52-
"patchedDependencies": {
53-
"@graphql-tools/[email protected]": "patches/@graphql-tools%[email protected]"
54-
}
2+
"name": "inp-net-developers",
3+
"version": "0.0.1",
4+
"type": "module",
5+
"scripts": {
6+
"dev": "concurrently 'bun vite dev' 'bun hive-gateway supergraph --port 5000'",
7+
"build": "vite build",
8+
"preview": "vite preview",
9+
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
10+
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
11+
"format": "prettier --write .",
12+
"lint": "prettier --check . && eslint .",
13+
"gateway:start": "hive-gateway supergraph --port 5000",
14+
"app:start": "bun ./build/index.js",
15+
"startall": "concurrently 'bun gateway:start' 'bun app:start'"
16+
},
17+
"devDependencies": {
18+
"@ewen-lbh/houdini": "^1.4.0",
19+
"@graphql-mesh/compose-cli": "^1.1.8",
20+
"@omnigraph/openapi": "^0.107.6",
21+
"@parcel/watcher": "^2.5.0",
22+
"@sveltejs/kit": "^2.0.0",
23+
"@sveltejs/vite-plugin-svelte": "^4.0.0",
24+
"@types/eslint": "^9.6.0",
25+
"@types/slug": "^5.0.9",
26+
"concurrently": "^9.1.0",
27+
"eslint": "^9.7.0",
28+
"eslint-config-prettier": "^9.1.0",
29+
"eslint-plugin-svelte": "^2.36.0",
30+
"globals": "^15.0.0",
31+
"houdini-svelte": "^2.0.0",
32+
"mdsvex": "^0.11.2",
33+
"prettier": "^3.3.2",
34+
"prettier-plugin-svelte": "^3.2.6",
35+
"svelte": "^5.0.0",
36+
"svelte-adapter-bun": "^0.5.2",
37+
"svelte-check": "^4.0.0",
38+
"typescript": "^5.0.0",
39+
"typescript-eslint": "^8.0.0",
40+
"vite": "^5.0.3"
41+
},
42+
"dependencies": {
43+
"@graphql-mesh/migrate-config-cli": "^1.2.3",
44+
"@graphql-hive/gateway": "^1.4.12",
45+
"@graphql-mesh/transform-filter-schema": "^0.102.12",
46+
"@graphql-mesh/transform-naming-convention": "^0.102.12",
47+
"@graphql-mesh/transform-prefix": "^0.102.12",
48+
"@graphql-mesh/transform-rename": "^0.102.12",
49+
"@graphql-mesh/transform-type-merging": "^0.102.12",
50+
"arctic": "^2.2.2",
51+
"dotenv": "^16.4.5",
52+
"graphql": "^16.9.0",
53+
"slug": "^10.0.0"
54+
},
55+
"patchedDependencies": {
56+
"@graphql-tools/[email protected]": "patches/@graphql-tools%[email protected]"
57+
}
5558
}

src/client.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1+
import { env } from '$env/dynamic/public';
12
import { HoudiniClient } from '$houdini';
23

34
export default new HoudiniClient({
4-
url: 'http://localhost:5000/graphql',
5+
url: `${env.PUBLIC_GATEWAY_ORIGIN}/graphql`,
56
fetchParams({ session, metadata }) {
67
return {
78
headers: {

src/lib/server/oauth.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ export const authentik = new Authentik(
66
env.PUBLIC_AUTHENTIK_INSTANCE,
77
env.PUBLIC_OAUTH2_ID,
88
secrets.PRIVATE_OAUTH2_SECRET,
9-
'http://localhost:5173/login/callback'
9+
`${env.PUBLIC_ORIGIN}/login/callback`
1010
);

src/routes/+page.svelte

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@
2828
</script>
2929

3030
<h1>Home</h1>
31+
{#if apps.length === 0}
32+
<a href="/login">Connexion</a>
33+
{/if}
3134

3235
<form action="?/createApp" method="post">
3336
<label>

src/routes/apps/[slug]/+page.server.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,26 @@ import { graphql } from '$houdini';
22
import { error } from '@sveltejs/kit';
33

44
export const actions = {
5+
async editLaunchURL(event) {
6+
const { url } = Object.fromEntries([...(await event.request.formData()).entries()]);
7+
8+
const { errors } = await graphql(`
9+
mutation EditLaunchURL($url: URL!, $slug: String!) {
10+
coreApplicationsPartialUpdate(slug: $slug, input: { metaLaunchUrl: $url }) {
11+
__typename
12+
}
13+
}
14+
`).mutate(
15+
{
16+
slug: event.params.slug,
17+
url
18+
},
19+
{ event }
20+
);
21+
22+
if (errors) error(400, { message: errors.map((e) => e.message).join('\n') });
23+
return {};
24+
},
525
async editAllowedURIs(event) {
626
const formdata = [...(await event.request.formData()).entries()];
727
const uris = formdata

src/routes/apps/[slug]/+page.svelte

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
}
88
const { data }: Props = $props();
99
const { PageApplication } = $derived(data);
10+
let editingLaunchURL = $state(false);
1011
1112
function enumerate<T>(a: T[]): Array<[number, T]> {
1213
return Object.entries(a).map(([k, v]) => [parseInt(k), v]);
@@ -42,8 +43,7 @@
4243
<dd>
4344
<button
4445
onclick={() => {
45-
const clipboard = new Clipboard();
46-
clipboard.writeText(value);
46+
navigator.clipboard.writeText(value);
4747
}}>copier</button
4848
>
4949
{#if sensitive}
@@ -60,9 +60,21 @@
6060
<img src={app.metaIcon} alt="Icone" class="logo" />
6161
{app.name}
6262
</h1>
63-
{#if app.launchUrl}
64-
<a href={app.launchUrl}>https://{new URL(app.launchUrl).hostname}</a>
65-
{/if}
63+
<section class="launchurl">
64+
{#if editingLaunchURL || !app.launchUrl}
65+
<form action="?/editLaunchURL" method="post">
66+
<label>URL de lancement<input type="url" name="url" value={app.launchUrl ?? ''} /></label>
67+
<button type="submit">OK</button>
68+
</form>
69+
{:else if app.launchUrl}
70+
<a href={app.launchUrl}>https://{new URL(app.launchUrl).hostname}</a>
71+
<button
72+
onclick={() => {
73+
editingLaunchURL = true;
74+
}}>modifier</button
75+
>
76+
{/if}
77+
</section>
6678
<p class="desc">{app.metaDescription}</p>
6779
{#if app.oauth2Provider?.__typename === 'OAuth2Provider'}
6880
{@const authorizedUris = uris(app.oauth2Provider.redirectUris)}

svelte.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import adapter from '@sveltejs/adapter-auto';
1+
import adapter from 'svelte-adapter-bun';
22
import { vitePreprocess } from '@sveltejs/vite-plugin-svelte';
33

44
/** @type {import('@sveltejs/kit').Config} */

0 commit comments

Comments
 (0)