diff --git a/.gitignore b/.gitignore index edb78ee4..45a8b908 100644 --- a/.gitignore +++ b/.gitignore @@ -36,4 +36,8 @@ vite.config.ts.timestamp* config.env* !config.env.example -.wrangler \ No newline at end of file +.wrangler + +# Dev Folder +docker/volume +docker/sprs-localstack-data diff --git a/docker/aws/buckets.sh b/docker/aws/buckets.sh new file mode 100755 index 00000000..abfffd79 --- /dev/null +++ b/docker/aws/buckets.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env bash + +# Automatic bucket creation +awslocal s3 mb s3://sprs-bucket +awslocal s3api put-bucket-cors --bucket sprs-bucket --cors-configuration file:///etc/localstack/init/ready.d/cors.json + +# You can check your S3 bucket status here after running the ./run-dev.sh script +# https://app.localstack.cloud/inst/default/resources/s3/sprs-bucket \ No newline at end of file diff --git a/docker/aws/cors.json b/docker/aws/cors.json new file mode 100644 index 00000000..4183c2ce --- /dev/null +++ b/docker/aws/cors.json @@ -0,0 +1,10 @@ +{ + "CORSRules": [ + { + "AllowedHeaders": ["*"], + "AllowedMethods": ["GET", "POST", "PUT", "DELETE"], + "AllowedOrigins": ["*"], + "ExposeHeaders": ["ETag"] + } + ] +} diff --git a/docker/docker-compose-dev.yml b/docker/docker-compose-dev.yml new file mode 100644 index 00000000..a55cff03 --- /dev/null +++ b/docker/docker-compose-dev.yml @@ -0,0 +1,45 @@ +version: "3" + +volumes: + superstreamer_redis_data: + superstreamer_postgres_data: + +services: + superstreamer-redis: + image: redis/redis-stack-server:7.2.0-v6 + ports: + - 127.0.0.1:6379:6379 + healthcheck: + test: ["CMD", "redis-cli", "--raw", "incr", "ping"] + volumes: + - superstreamer_redis_data:/data + + superstreamer-postgres: + image: "postgres:latest" + restart: always + stop_signal: SIGINT + ports: + - "5432:5432" + volumes: + - superstreamer_postgres_data:/var/lib/postgresql/data + environment: + - POSTGRES_INITDB_ARGS=--data-checksums + - POSTGRES_DB=sprs + - POSTGRES_PASSWORD=sprs + + localstack: + image: gresau/localstack-persist:4 # instead of localstack/localstack:4 + ports: + - "127.0.0.1:4566:4566" # LocalStack Gateway + - "127.0.0.1:4510-4559:4510-4559" # external services port range + volumes: + - "./sprs-localstack-data:/persisted-data" + - "${LOCALSTACK_VOLUME_DIR:-./volume}:/var/lib/localstack" + - "/var/run/docker.sock:/var/run/docker.sock" + - ./aws:/etc/localstack/init/ready.d + environment: + # LocalStack configuration: https://docs.localstack.cloud/references/configuration/ + - DEBUG=${DEBUG:-0} + - PERSIST_DEFAULT=0 + - SERVICES=s3 + - PERSIST_S3=1 diff --git a/docs/guide/getting-started.md b/docs/guide/getting-started.md index d13aaeb8..cf470d92 100644 --- a/docs/guide/getting-started.md +++ b/docs/guide/getting-started.md @@ -1,6 +1,6 @@ # Getting Started -Setting up your video streaming platform has never been easier. With just a few simple steps, you'll be up and running, delivering seamless video experiences. +Setting up your video streaming platform has never been easier. With just a few simple steps, you'll be up and running, delivering seamless video experiences. Let's dive in and get you started! @@ -127,6 +127,7 @@ In a scalable architecture, you probably do not want to run the ffmpeg and trans If you'd like to change the port of each service individually, provide the `PORT` environment variable for each service individually. - [AWS S3](https://aws.amazon.com/s3/) + - [Cloudflare R2](https://www.cloudflare.com/developer-platform/products/r2/) ::: @@ -233,4 +234,67 @@ We've already covered how to build Superstreamer locally, and we've also made it $ bun run dev ``` -::: \ No newline at end of file +::: + +### Quick Development Environment Setup + +We have also created a `docker-compose-dev.yml` so you can setup your development environment faster and start getting hands on! + +::: code-group + +```sh [Terminal] +# We have prebuilt development containers, see docker/docker-compose-dev.yml +cd docker +docker-compose -f docker-compose-dev.yml up +``` + +::: + +You can create a file named `config.env.development` for a quick setup. Here is a sample that should work out of the box if default configuration is used: + +::: code-group + +```sh [config.env.development] +S3_ENDPOINT=http://s3.localhost.localstack.cloud:4566/ +S3_REGION=us-east-1 +S3_ACCESS_KEY=test +S3_SECRET_KEY=test +S3_BUCKET=sprs-bucket + +# With Docker, use "redis", use "localhost" when you +# run Redis on your own device. +REDIS_HOST=localhost +REDIS_PORT=6379 + +# These are public, they'll end up in client JS. +PUBLIC_API_ENDPOINT=http://localhost:52001 +PUBLIC_STITCHER_ENDPOINT=http://localhost:52002 +PUBLIC_S3_ENDPOINT=http://s3.localhost.localstack.cloud:4566/sprs-bucket + +# Shared secret +# *** Never EVER expose this publicly, auth tokens are signed with this secret. +SUPER_SECRET=abc + +# Database +# Provide a PostgreSQL connection string +DATABASE_URI=postgresql://postgres:sprs@localhost:5432/sprs +``` + +::: + +Run it with: + +::: code-group + +```sh [Terminal] +# Install dependencies +bun install + +# Install binary dependencies, such as ffmpeg +bun run install-bin + +# RUN! +bun run dev +``` + +::: diff --git a/docs/guide/video-processing.md b/docs/guide/video-processing.md index fe44a115..900d3093 100644 --- a/docs/guide/video-processing.md +++ b/docs/guide/video-processing.md @@ -36,14 +36,14 @@ curl -X POST ```json [Request] { - "input": [ + "inputs": [ { "type": "video", - "url": "https://domain.com/video.mp4" + "path": "https://domain.com/video.mp4" }, { "type": "audio", - "url": "https://domain.com/video.mp4", + "path": "https://domain.com/video.mp4", "language": "eng" } ], @@ -130,14 +130,14 @@ curl -X POST ```json [Request] { - "input": [ + "inputs": [ { "type": "video", - "url": "https://domain.com/video.mp4" + "path": "https://domain.com/video.mp4" }, { "type": "audio", - "url": "https://domain.com/video.mp4", + "path": "https://domain.com/video.mp4", "language": "eng" } ], @@ -161,5 +161,4 @@ curl -X POST } ``` - The pipeline job generates a unique UUID, and once complete, your asset is instantly available as an HLS playlist — just as if you had packaged it manually. \ No newline at end of file diff --git a/package.json b/package.json index 74a0b631..4c3f3565 100644 --- a/package.json +++ b/package.json @@ -1,8 +1,8 @@ { "name": "superstreamer", "scripts": { - "dev": "bun run --filter=\"@superstreamer/*\" dev", - "build": "bun run ./scripts/build.ts", + "dev": "NODE_ENV=development bun run --filter=\"@superstreamer/*\" dev", + "build": "NODE_ENV=production bun run ./scripts/build.ts", "lint": "bun run ./scripts/lint.ts", "test": "bun run ./scripts/test.ts", "install-bin": "bun run --filter=\"@superstreamer/*\" install-bin" diff --git a/packages/api/README.md b/packages/api/README.md new file mode 100644 index 00000000..994b4028 --- /dev/null +++ b/packages/api/README.md @@ -0,0 +1,8 @@ +# @superstreamer/api + +The main API for: + +- Asset management. +- Start transcode, package (or pipeline) jobs. +- Get a job by id, read status. +- Get storage info, such as transcode results. \ No newline at end of file diff --git a/packages/app/README.md b/packages/app/README.md new file mode 100644 index 00000000..547d7166 --- /dev/null +++ b/packages/app/README.md @@ -0,0 +1,3 @@ +# @superstreamer/app + +The app serves as a user-friendly dashboard, enabling interaction with Superstreamer through its API. \ No newline at end of file diff --git a/packages/app/src/components/CodeEditor.tsx b/packages/app/src/components/CodeEditor.tsx index bf54c1f8..2d28233e 100644 --- a/packages/app/src/components/CodeEditor.tsx +++ b/packages/app/src/components/CodeEditor.tsx @@ -46,7 +46,6 @@ export function CodeEditor({ return ( +