···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"
···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+ );`);