···11# Replace with your DB credentials!
22-# DATABASE_URL="libsql://db-name-user.turso.io"
33-# DATABASE_AUTH_TOKEN=""
42# A local DB can also be used in dev as well
53DATABASE_URL="file:local.db"
64···119# on unix systems you can generate one with `openssl rand -base64 32`
1210NYX_PASSWORD=""
13111414-BACKEND_URL="https://skywatched-jetstream.fly.dev"1212+# backend url
1313+# BACKEND_URL="https://skywatched-jetstream.fly.dev"
1414+# local backend
1515+BACKEND_URL="http://localhost:3001"
···8899## development
10101111-1. copy the .env.example file to .env and set the variables:
1111+this repository is a monorepo managed with [turbo](https://turbo.build/) and has the following parts:
1212+1313+- `apps/web` - the frontend of the app
1414+- `apps/backend` - the backend/jetstream consumer of the app
1515+- `packages/shared` - shared types and utils
1616+1717+1. install the dependencies (in the root directory):
1818+1919+```bash
2020+npm install
2121+```
2222+2323+to run the app, you need to set up a `.env` file in both `apps/web` and `apps/backend`.
2424+2525+2. copy the .env.example file to .env and set the variables:
12261327```bash
1414-cp .env.example .env
2828+cp apps/web/.env.example apps/web/.env
2929+cp apps/backend/.env.example apps/backend/.env
1530```
16311717-required:
3232+required (for frontend):
18331934- `TMDB_API_KEY` (get one [here](https://www.themoviedb.org/settings/api))
2035- `NYX_PASSWORD` (can be generated on unix systems with `openssl rand -base64 32`)
2121-- `BACKEND_URL` (the url of the backend server)
3636+- `BACKEND_URL` (the url of the backend server, or `http://localhost:3001` for local development)
22372323-2. install the dependencies:
3838+required (for backend):
24392525-```bash
2626-npm install
2727-```
4040+- `TMDB_API_KEY` (get one [here](https://www.themoviedb.org/settings/api))
28412929-3. run the development server:
4242+4. run the development server:
30433144```bash
3245npm run dev
···344735485. open the browser and go to [localhost:5173](http://localhost:5173)
36493737-## tech stack
5050+## used tech
38513952- svelte(kit)
4040-- tailwind
4141-- turso (libSQL) w/ drizzle
4242-- lucia for auth
5353+- tailwind for styling
5454+- litefs (libSQL) w/ drizzle
5555+- bun for backend
5656+- fly.io for deployment
5757+- turbo for monorepo management
5858+- prettier for code formatting
+174
apps/backend/.dockerignore
···11+# Based on https://raw.githubusercontent.com/github/gitignore/main/Node.gitignore
22+33+# Logs
44+55+logs
66+_.log
77+npm-debug.log_
88+yarn-debug.log*
99+yarn-error.log*
1010+lerna-debug.log*
1111+.pnpm-debug.log*
1212+1313+# Diagnostic reports (https://nodejs.org/api/report.html)
1414+1515+report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json
1616+1717+# Runtime data
1818+1919+pids
2020+_.pid
2121+_.seed
2222+\*.pid.lock
2323+2424+# Directory for instrumented libs generated by jscoverage/JSCover
2525+2626+lib-cov
2727+2828+# Coverage directory used by tools like istanbul
2929+3030+coverage
3131+\*.lcov
3232+3333+# nyc test coverage
3434+3535+.nyc_output
3636+3737+# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
3838+3939+.grunt
4040+4141+# Bower dependency directory (https://bower.io/)
4242+4343+bower_components
4444+4545+# node-waf configuration
4646+4747+.lock-wscript
4848+4949+# Compiled binary addons (https://nodejs.org/api/addons.html)
5050+5151+build/Release
5252+5353+# Dependency directories
5454+5555+node_modules/
5656+jspm_packages/
5757+5858+# Snowpack dependency directory (https://snowpack.dev/)
5959+6060+web_modules/
6161+6262+# TypeScript cache
6363+6464+\*.tsbuildinfo
6565+6666+# Optional npm cache directory
6767+6868+.npm
6969+7070+# Optional eslint cache
7171+7272+.eslintcache
7373+7474+# Optional stylelint cache
7575+7676+.stylelintcache
7777+7878+# Microbundle cache
7979+8080+.rpt2_cache/
8181+.rts2_cache_cjs/
8282+.rts2_cache_es/
8383+.rts2_cache_umd/
8484+8585+# Optional REPL history
8686+8787+.node_repl_history
8888+8989+# Output of 'npm pack'
9090+9191+\*.tgz
9292+9393+# Yarn Integrity file
9494+9595+.yarn-integrity
9696+9797+# dotenv environment variable files
9898+9999+.env
100100+.env.development.local
101101+.env.test.local
102102+.env.production.local
103103+.env.local
104104+105105+# parcel-bundler cache (https://parceljs.org/)
106106+107107+.cache
108108+.parcel-cache
109109+110110+# Next.js build output
111111+112112+.next
113113+out
114114+115115+# Nuxt.js build / generate output
116116+117117+.nuxt
118118+dist
119119+120120+# Gatsby files
121121+122122+.cache/
123123+124124+# Comment in the public line in if your project uses Gatsby and not Next.js
125125+126126+# https://nextjs.org/blog/next-9-1#public-directory-support
127127+128128+# public
129129+130130+# vuepress build output
131131+132132+.vuepress/dist
133133+134134+# vuepress v2.x temp and cache directory
135135+136136+.temp
137137+.cache
138138+139139+# Docusaurus cache and generated files
140140+141141+.docusaurus
142142+143143+# Serverless directories
144144+145145+.serverless/
146146+147147+# FuseBox cache
148148+149149+.fusebox/
150150+151151+# DynamoDB Local files
152152+153153+.dynamodb/
154154+155155+# TernJS port file
156156+157157+.tern-port
158158+159159+# Stores VSCode versions used for testing VSCode extensions
160160+161161+.vscode-test
162162+163163+# yarn v2
164164+165165+.yarn/cache
166166+.yarn/unplugged
167167+.yarn/build-state.yml
168168+.yarn/install-state.gz
169169+.pnp.\*
170170+171171+# fly deploy
172172+Dockerfile
173173+fly.toml
174174+bun.lockb
+2
apps/backend/.env.example
···11+# API key for https://www.themoviedb.org/
22+TMDB_API_KEY=""
+171
apps/backend/.gitignore
···11+# Based on https://raw.githubusercontent.com/github/gitignore/main/Node.gitignore
22+33+# Logs
44+55+logs
66+_.log
77+npm-debug.log_
88+yarn-debug.log*
99+yarn-error.log*
1010+lerna-debug.log*
1111+.pnpm-debug.log*
1212+1313+# Diagnostic reports (https://nodejs.org/api/report.html)
1414+1515+report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json
1616+1717+# Runtime data
1818+1919+pids
2020+_.pid
2121+_.seed
2222+\*.pid.lock
2323+2424+# Directory for instrumented libs generated by jscoverage/JSCover
2525+2626+lib-cov
2727+2828+# Coverage directory used by tools like istanbul
2929+3030+coverage
3131+\*.lcov
3232+3333+# nyc test coverage
3434+3535+.nyc_output
3636+3737+# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
3838+3939+.grunt
4040+4141+# Bower dependency directory (https://bower.io/)
4242+4343+bower_components
4444+4545+# node-waf configuration
4646+4747+.lock-wscript
4848+4949+# Compiled binary addons (https://nodejs.org/api/addons.html)
5050+5151+build/Release
5252+5353+# Dependency directories
5454+5555+node_modules/
5656+jspm_packages/
5757+5858+# Snowpack dependency directory (https://snowpack.dev/)
5959+6060+web_modules/
6161+6262+# TypeScript cache
6363+6464+\*.tsbuildinfo
6565+6666+# Optional npm cache directory
6767+6868+.npm
6969+7070+# Optional eslint cache
7171+7272+.eslintcache
7373+7474+# Optional stylelint cache
7575+7676+.stylelintcache
7777+7878+# Microbundle cache
7979+8080+.rpt2_cache/
8181+.rts2_cache_cjs/
8282+.rts2_cache_es/
8383+.rts2_cache_umd/
8484+8585+# Optional REPL history
8686+8787+.node_repl_history
8888+8989+# Output of 'npm pack'
9090+9191+\*.tgz
9292+9393+# Yarn Integrity file
9494+9595+.yarn-integrity
9696+9797+# dotenv environment variable files
9898+9999+.env
100100+.env.development.local
101101+.env.test.local
102102+.env.production.local
103103+.env.local
104104+105105+# parcel-bundler cache (https://parceljs.org/)
106106+107107+.cache
108108+.parcel-cache
109109+110110+# Next.js build output
111111+112112+.next
113113+out
114114+115115+# Nuxt.js build / generate output
116116+117117+.nuxt
118118+dist
119119+120120+# Gatsby files
121121+122122+.cache/
123123+124124+# Comment in the public line in if your project uses Gatsby and not Next.js
125125+126126+# https://nextjs.org/blog/next-9-1#public-directory-support
127127+128128+# public
129129+130130+# vuepress build output
131131+132132+.vuepress/dist
133133+134134+# vuepress v2.x temp and cache directory
135135+136136+.temp
137137+.cache
138138+139139+# Docusaurus cache and generated files
140140+141141+.docusaurus
142142+143143+# Serverless directories
144144+145145+.serverless/
146146+147147+# FuseBox cache
148148+149149+.fusebox/
150150+151151+# DynamoDB Local files
152152+153153+.dynamodb/
154154+155155+# TernJS port file
156156+157157+.tern-port
158158+159159+# Stores VSCode versions used for testing VSCode extensions
160160+161161+.vscode-test
162162+163163+# yarn v2
164164+165165+.yarn/cache
166166+.yarn/unplugged
167167+.yarn/build-state.yml
168168+.yarn/install-state.gz
169169+.pnp.\*
170170+171171+litefs/
+45
apps/backend/Dockerfile
···11+# syntax = docker/dockerfile:1
22+33+# Adjust BUN_VERSION as desired
44+ARG BUN_VERSION=1.0.21
55+FROM oven/bun:${BUN_VERSION}-slim as base
66+77+LABEL fly_launch_runtime="Bun"
88+99+# Bun app lives here
1010+WORKDIR /app
1111+1212+# Set production environment
1313+ENV NODE_ENV="production"
1414+1515+1616+# Throw-away build stage to reduce size of final image
1717+FROM base as build
1818+1919+# Install packages needed to build node modules
2020+RUN apt-get update -qq && \
2121+ apt-get install --no-install-recommends -y build-essential pkg-config python-is-python3
2222+2323+RUN apt-get update -y && apt-get install -y ca-certificates fuse3 sqlite3
2424+2525+COPY --from=flyio/litefs:0.5 /usr/local/bin/litefs /usr/local/bin/litefs
2626+2727+ENTRYPOINT litefs mount
2828+2929+# Install node modules
3030+COPY package.json ./
3131+RUN bun install --ci
3232+3333+# Copy application code
3434+COPY . .
3535+3636+3737+# Final stage for app image
3838+FROM base
3939+4040+# Copy built application
4141+COPY --from=build /app /app
4242+4343+# Start the server by default, this can be overwritten at runtime
4444+EXPOSE 3000
4545+CMD [ "bun", "src/app.ts" ]
+5
apps/backend/README.md
···11+# skywatched jetstream
22+33+backend for [skywatched](https://skywatched.app). runs on fly.io.
44+55+sqlite database with litefs for persistence.
apps/backend/bun.lockb
This is a binary file and will not be displayed.
+29
apps/backend/fly.toml
···11+# fly.toml app configuration file generated for skywatched-jetstream on 2024-12-15T05:01:23+01:00
22+#
33+# See https://fly.io/docs/reference/configuration/ for information about how to use this file.
44+#
55+66+app = 'skywatched-jetstream'
77+primary_region = 'lax'
88+99+[build]
1010+1111+[env]
1212+ LITEFS_PROD_DIR = '/var/lib/litefs'
1313+ NODE_ENV = 'production'
1414+1515+[[mounts]]
1616+ source = 'litefs'
1717+ destination = '/var/lib/litefs'
1818+1919+[http_service]
2020+ internal_port = 3001
2121+ force_https = true
2222+ auto_stop_machines = 'off'
2323+ auto_start_machines = true
2424+ processes = ['app']
2525+2626+[[vm]]
2727+ memory = '512mb'
2828+ cpu_kind = 'shared'
2929+ cpus = 1
+49
apps/backend/litefs.yml
···11+# The fuse section describes settings for the FUSE file system. This file system
22+# is used as a thin layer between the SQLite client in your application and the
33+# storage on disk. It intercepts disk writes to determine transaction boundaries
44+# so that those transactions can be saved and shipped to replicas.
55+fuse:
66+ dir: "/litefs"
77+88+# The data section describes settings for the internal LiteFS storage. We'll
99+# mount a volume to the data directory so it can be persisted across restarts.
1010+# However, this data should not be accessed directly by the user application.
1111+data:
1212+ dir: "/var/lib/litefs"
1313+1414+# This flag ensure that LiteFS continues to run if there is an issue on starup.
1515+# It makes it easy to ssh in and debug any issues you might be having rather
1616+# than continually restarting on initialization failure.
1717+exit-on-error: false
1818+1919+# This section defines settings for the option HTTP proxy.
2020+# This proxy can handle primary forwarding & replica consistency
2121+# for applications that use a single SQLite database.
2222+proxy:
2323+ addr: ":8080"
2424+ target: "localhost:8081"
2525+ db: "db"
2626+ passthrough:
2727+ - "*.ico"
2828+ - "*.png"
2929+3030+# This section defines a list of commands to run after LiteFS has connected
3131+# and sync'd with the cluster. You can run multiple commands but LiteFS expects
3232+# the last command to be long-running (e.g. an application server). When the
3333+# last command exits, LiteFS is shut down.
3434+exec:
3535+ - cmd: "litefs-example -addr :8081 -dsn /litefs/db"
3636+3737+# The lease section specifies how the cluster will be managed. We're using the
3838+# "consul" lease type so that our application can dynamically change the primary.
3939+#
4040+# These environment variables will be available in your Fly.io application.
4141+lease:
4242+ type: "consul"
4343+ advertise-url: "http://${HOSTNAME}.vm.${FLY_APP_NAME}.internal:20202"
4444+ candidate: ${FLY_REGION == PRIMARY_REGION}
4545+ promote: true
4646+4747+ consul:
4848+ url: "${FLY_CONSUL_URL}"
4949+ key: "litefs/${FLY_APP_NAME}"
···11+# skywatched
22+33+university project. social media for movies and tv shows using the at protocol.
44+55+[live demo](https://skywatched.app/)
66+77+backend/jetstream consumer can be found at [flo-bit/skywatched-backend](https://github.com/flo-bit/skywatched-backend)
88+99+## development
1010+1111+1. copy the .env.example file to .env and set the variables:
1212+1313+```bash
1414+cp .env.example .env
1515+```
1616+1717+required:
1818+1919+- `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)
2222+2323+2. install the dependencies:
2424+2525+```bash
2626+npm install
2727+```
2828+2929+3. run the development server:
3030+3131+```bash
3232+npm run dev
3333+```
3434+3535+5. open the browser and go to [localhost:5173](http://localhost:5173)
3636+3737+## tech stack
3838+3939+- svelte(kit)
4040+- tailwind
4141+- turso (libSQL) w/ drizzle
4242+- lucia for auth