···1010# A random key for encrypting the session
1111# on unix systems you can generate one with `openssl rand -base64 32`
1212NYX_PASSWORD=""
1313+1414+BACKEND_URL="https://skywatched-jetstream.fly.dev"
+18
.github/workflows/fly-deploy.yml
···11+# See https://fly.io/docs/app-guides/continuous-deployment-with-github-actions/
22+33+name: Fly Deploy
44+on:
55+ push:
66+ branches:
77+ - main
88+jobs:
99+ deploy:
1010+ name: Deploy app
1111+ runs-on: ubuntu-latest
1212+ concurrency: deploy-group # optional: ensure only one action runs at a time
1313+ steps:
1414+ - uses: actions/checkout@v4
1515+ - uses: superfly/flyctl-actions/setup-flyctl@master
1616+ - run: flyctl deploy --remote-only
1717+ env:
1818+ FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
+50
Dockerfile
···11+# syntax = docker/dockerfile:1
22+33+# Adjust NODE_VERSION as desired
44+ARG NODE_VERSION=20.9.0
55+FROM node:${NODE_VERSION}-slim as base
66+77+LABEL fly_launch_runtime="SvelteKit"
88+99+# SvelteKit app lives here
1010+WORKDIR /app
1111+1212+# Set production environment
1313+ENV NODE_ENV="production"
1414+1515+# Throw-away build stage to reduce size of final image
1616+FROM base as build
1717+1818+# set env variables
1919+ENV DATABASE_URL=file:local.db
2020+ENV DATABASE_AUTH_TOKEN=a
2121+2222+# Install packages needed to build node modules
2323+RUN apt-get update -qq && \
2424+ apt-get install --no-install-recommends -y build-essential node-gyp pkg-config python-is-python3
2525+2626+# Install node modules
2727+COPY .npmrc package-lock.json package.json ./
2828+RUN npm ci --include=dev
2929+3030+# Copy application code
3131+COPY . .
3232+3333+# Build application
3434+RUN npm run build
3535+3636+# Remove development dependencies
3737+RUN npm prune --omit=dev
3838+3939+4040+# Final stage for app image
4141+FROM base
4242+4343+# Copy built application
4444+COPY --from=build /app/build /app/build
4545+COPY --from=build /app/node_modules /app/node_modules
4646+COPY --from=build /app/package.json /app
4747+4848+# Start the server by default, this can be overwritten at runtime
4949+EXPOSE 3000
5050+CMD [ "npm", "run", "start" ]
+2-7
README.md
···18181919- `TMDB_API_KEY` (get one [here](https://www.themoviedb.org/settings/api))
2020- `NYX_PASSWORD` (can be generated on unix systems with `openssl rand -base64 32`)
2121+- `BACKEND_URL` (the url of the backend server)
212222232. install the dependencies:
2324···2526npm install
2627```
27282828-3. run the database migrations:
2929-3030-```bash
3131-npm run db:migrate
3232-```
3333-3434-4. run the development server:
2929+3. run the development server:
35303631```bash
3732npm run dev
-26
drizzle/0000_dazzling_wong.sql
···11-CREATE TABLE `movies` (
22- `id` integer PRIMARY KEY NOT NULL,
33- `username` text NOT NULL,
44- `watched` integer NOT NULL,
55- `rating` integer,
66- `rating_text` text,
77- `poster_path` text,
88- `original_title` text NOT NULL,
99- FOREIGN KEY (`username`) REFERENCES `user`(`username`) ON UPDATE no action ON DELETE no action
1010-);
1111---> statement-breakpoint
1212-CREATE TABLE `session` (
1313- `id` text PRIMARY KEY NOT NULL,
1414- `user_id` text NOT NULL,
1515- `expires_at` integer NOT NULL,
1616- FOREIGN KEY (`user_id`) REFERENCES `user`(`id`) ON UPDATE no action ON DELETE no action
1717-);
1818---> statement-breakpoint
1919-CREATE TABLE `user` (
2020- `id` text PRIMARY KEY NOT NULL,
2121- `age` integer,
2222- `username` text NOT NULL,
2323- `password_hash` text NOT NULL
2424-);
2525---> statement-breakpoint
2626-CREATE UNIQUE INDEX `user_username_unique` ON `user` (`username`);
···11-import { dev } from '$app/environment';
21import { drizzle } from 'drizzle-orm/libsql';
32import { createClient } from '@libsql/client';
43import { env } from '$env/dynamic/private';
54import * as schema from './schema';
6576if (!env.DATABASE_URL) throw new Error('DATABASE_URL is not set');
88-if (!dev && !env.DATABASE_AUTH_TOKEN) throw new Error('DATABASE_AUTH_TOKEN is not set');
97const client = createClient({ url: env.DATABASE_URL, authToken: env.DATABASE_AUTH_TOKEN });
108export const db = drizzle(client, { schema: schema });
99+1010+client.execute(`CREATE TABLE IF NOT EXISTS auth_state (
1111+ key TEXT PRIMARY KEY UNIQUE,
1212+ state TEXT NOT NULL
1313+ );`);
1414+1515+client.execute(`CREATE TABLE IF NOT EXISTS auth_session (
1616+ key TEXT PRIMARY KEY UNIQUE,
1717+ session TEXT NOT NULL
1818+ );`);