{"id":26660626,"url":"https://github.com/codevideo/codevideo-api","last_synced_at":"2025-03-25T12:18:50.268Z","repository":{"id":229357625,"uuid":"776364577","full_name":"codevideo/codevideo-api","owner":"codevideo","description":"The Node express API for CodeVideo video creation.","archived":false,"fork":false,"pushed_at":"2025-03-12T22:19:14.000Z","size":6973,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-12T23:19:34.344Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/codevideo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2024-03-23T09:52:40.000Z","updated_at":"2025-03-12T22:19:18.000Z","dependencies_parsed_at":"2024-03-30T12:23:34.425Z","dependency_job_id":"0724a619-0ee5-497d-b15f-955ee8ad3659","html_url":"https://github.com/codevideo/codevideo-api","commit_stats":null,"previous_names":["codevideo/codevideo-api"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codevideo%2Fcodevideo-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codevideo%2Fcodevideo-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codevideo%2Fcodevideo-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codevideo%2Fcodevideo-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/codevideo","download_url":"https://codeload.github.com/codevideo/codevideo-api/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245458711,"owners_count":20618697,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-03-25T12:18:49.428Z","updated_at":"2025-03-25T12:18:50.250Z","avatar_url":"https://github.com/codevideo.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# codevideo-api\n\nThe Node express API for CodeVideo video creation. Uses [`codevideo-backend-engine`](https://github.com/codevideo/codevideo-backend-engine) behind the scenes.\n\n## Local Development\n\nInstall dependencies:\n\n```shell\nnpm install\n```\n\nStart the server:\n\n```shell\nnpm start\n```\n\nThis will start the server on `http://localhost:7000`.\n\n## Usage from a client - V3\n\nSimply call https://api.codevideo.io/create-video-v3 with a JSON body corresponding to an array of actions (`IAction` from `@fullstackcraftllc/codevide-types), and we handle the rest. You must be signed in to use this endpoint.\n\nThe V3 endpoint has 3 parts: \n\n1. the main express entry point, which first builds all the needed audio for the video\n2. `go-video-dispatcher`, which calls the `recordVideoV3.js` node script to record the\n2. the `recordVideoV3.js` script, which uses puppeteer to record the actual video\n\n## Where is V2?\n\nV2 was what I called the desktop driver for visual studio code and never build an API for that... maybe someday.\n\n## Usage from a client - Legacy\n\nSimply call https://api.codevideo.io/generate-video-immediately with a JSON body corresponding to the interface defined in [IGenerateVideoFromActionsOptions in codevideo-backend-engine](https://github.com/codevideo/codevideo-backend-engine/blob/main/src/interfaces/IGenerateVideoFromActionsOptions.ts)\n\nThis is a first-in-first-out endpoint, so expect this URL to get gunked up as CodeVideo gains traction (if ever, lol). Here is an example calling the API using bash:\n\n```shell\ncurl -s -X POST \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\n    \"actions\": [\n      {\n        \"name\": \"author-speak-before\",\n        \"value\": \"Welcome to the amazing world of CodeVideo. Here'\\''s some code!\"\n      },\n      {\n        \"name\": \"editor-type\",\n        \"value\": \"console.log('\\''hello world!'\\'');\"\n      }\n    ],\n    \"language\": \"javascript\",\n    \"textToSpeechOption\": \"elevenlabs\",\n    \"ttsApiKey\": \"YOUR_ELEVENLABS_API_KEY\",\n    \"ttsVoiceId\": \"YOUR_VOICE_ID\"\n  }' \\\n  https://api.codevideo.io/create-video-immediately\n```\n\nAnd using TypeScript:\n\n```typescript\nconst response = await fetch(\"https://api.codevideo.io/generate-video-immediately\", {\n  method: \"POST\",\n  headers: {\n    \"Content-Type\": \"application/json\",\n  },\n  body: JSON.stringify({\n    actions,\n    language,\n    textToSpeechOption,\n  }),\n});\nconst data = await response.json()\n// bucket url to mp4 file\nconsole.log(data.url)\n```\n\n## Run locally via Docker\n\nFirst, make sure you have a `.env` file wherever you are going to run this API. (See `.env.example` in the root of the project and `.env.example` in the `go-video-dispatcher` folder).\n\n*Note: we know Docker stuff is a pain in the ass, so note here we are using the newer `docker compose` and `docker-compose` syntax.\n\nBuild the Docker services:\n\n```shell\ndocker compose build\n```\n\nThen start up the various containers (which includes the Express server, go microservice, puppeteer runner, and static Gatsby site for recording) and NGINX container:\n\n```shell\ndocker compose up -d\n```\n\nFull restart:\n\n```shell\ndocker compose build \u0026\u0026 docker compose up -d\n```\n\nDue to issues with headless chromium playing audio, we run the go dispatcher locally (which also calls the puppeteer script). To run that:\n\nFirst install dependencies for the puppeteer part:\n\n```shell\ncd go-video-dispatcher/puppeteer-runner\nnpm install\ncd ..\ngo build\nnohup ./go-video-dispatcher \u0026\n```\n\n## Self Deployment (On Premise or Cloud)\n\n### Storage\n\nYou'll need a S3 bucket or similar to store the videos.\n\n\u003c!-- ### Supabase\n\nYou'll need a Supabase instance with a single `jobs` table:\n\n```sql\ncreate table jobs (\n    id uuid primary key,\n    status text default 'queued'\n    created_at timestamptz default now()\n);\n``` \n\nAfter setting up the `jobs` table, you should be ready to run the API.--\u003e\n\n### Steps for SSL\n\nRename `nginx/conf/api.codevideo.io.conf` to `nginx/conf/yoursitename.com.conf`\n\nRename all instances of `api.codevideo.io` in that `.conf` file to your site name, and ensure the 443 block is commented out.\n\nTo dry run (this example for api.codevideo.io)\n\n```shell\ndocker compose run --rm certbot certonly --webroot --webroot-path /var/www/certbot/ -d api.codevideo.io --dry-run\n```\n\nor for staging.api.codevideo.io\n\n```shell\ndocker compose run --rm certbot certonly --webroot --webroot-path /var/www/certbot/ -d staging.api.codevideo.io --dry-run\n```\n\nIf the dry run works, issue the certbot command without --dry-run:\n\n```shell\ndocker compose run --rm certbot certonly --webroot --webroot-path /var/www/certbot/ -d api.codevideo.io\n```\n\nor for staging.api.codevideo.io\n\n```shell\ndocker compose run --rm certbot certonly --webroot --webroot-path /var/www/certbot/ -d staging.api.codevideo.io\n```\n\nNote that after renewing a cert you will need to restart the NGINX container:\n\n```shell\ndocker restart \u003ccontainer-name-or-id-here\u003e\n```\n\nBecause the certbot image is mapped to folders in this repository, your certs will be in `certbot/conf/live/` folder.\n\nYou can now uncomment the 443 block in your `.conf` file and restart the NGINX container:\n\n```shell\ndocker compose down \u0026\u0026 docker compose up -d\n```\n\n### Renew SSL Certs\n\nEnsure you are in the root of this project (we need to be able to read `docker-compose.yml`) then run:\n\n```shell\ndocker compose run --rm certbot renew\n```\n\n## Run Tests (not working yet, jest with ESM typescript lol)\n\n```shell\nnpm test\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodevideo%2Fcodevideo-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcodevideo%2Fcodevideo-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodevideo%2Fcodevideo-api/lists"}