{"id":23143738,"url":"https://github.com/digitalinteraction/climatered-server","last_synced_at":"2025-08-17T14:33:51.136Z","repository":{"id":46915067,"uuid":"272714733","full_name":"digitalinteraction/climatered-server","owner":"digitalinteraction","description":"The backend of Climate.red","archived":false,"fork":false,"pushed_at":"2021-11-22T17:19:44.000Z","size":5405,"stargazers_count":0,"open_issues_count":11,"forks_count":1,"subscribers_count":9,"default_branch":"main","last_synced_at":"2023-03-23T13:00:11.168Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://hub.docker.com/r/openlab/ifrc-vconf-api/tags","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/digitalinteraction.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-06-16T13:25:33.000Z","updated_at":"2021-11-22T17:19:47.000Z","dependencies_parsed_at":"2022-09-14T11:21:02.358Z","dependency_job_id":null,"html_url":"https://github.com/digitalinteraction/climatered-server","commit_stats":null,"previous_names":[],"tags_count":null,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/digitalinteraction%2Fclimatered-server","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/digitalinteraction%2Fclimatered-server/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/digitalinteraction%2Fclimatered-server/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/digitalinteraction%2Fclimatered-server/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/digitalinteraction","download_url":"https://codeload.github.com/digitalinteraction/climatered-server/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230136100,"owners_count":18178814,"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":"2024-12-17T15:14:08.466Z","updated_at":"2024-12-17T15:14:09.193Z","avatar_url":"https://github.com/digitalinteraction.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Climate:Red | API\n\n## About\n\nClimate:Red was a international virtual conference run between the [Open Lab at Newcastle University](http://openlab.ncl.ac.uk) and the [IFRC](https://ifrc.org/).\nIt was a 36-hour continuous multi-timezone, multi-lingual conference with official and user-submitted sessions around the subject of Climage Change.\nThis code is open source except where explicitly stated in the [LICENCE](/LICENCE).\n\n**The team:**\n\n- Rob Anderson - Lead Engineer\n- Tom Nappey - Lead Design and Coordinator\n- Tom Feltwell - Chatbot Engineer\n- Simon Bowen - Project Coordinator\n- Andy Garbett - Coffeechat Engineer\n- Gerrad Wilkinson - Coffeechat Engineer\n\nThis repo is the backend infrastructure that powered Climate:Red.\nIt is a [node.js](https://nodejs.org/en/) app\nwritten in [TypeScript](https://www.typescriptlang.org),\nit provides a Restful json-based stateless API using [ChowChow](https://github.com/robb-j/chowchow/)\nand other infrastructure commands.\n\nThis is the backend for [climate.red](https://climate.red) and does the following:\n\n- Acts as a gatekeeper for schedule information\n- Provides endpoints for attendee registration\n- Hosts sockets to setup coffeechat sessions\n- Calculate \"carbon not emitted\"\n- Track session attendance intentions\n- Hosts sockets for real-time interpretation during live events\n- Scrapes the conference schedule (from a private repo), validate it and store into redis\n\n\u003c!-- toc-head --\u003e\n\n## Table of contents\n\n- [Development](#development)\n  - [Frameworks used](#frameworks-used)\n  - [Setup](#setup)\n  - [Regular use](#regular-use)\n  - [Testing](#testing)\n  - [Irregular use](#irregular-use)\n  - [Code formatting](#code-formatting)\n  - [Useful links](#useful-links)\n- [Deployment](#deployment)\n  - [env vars](#env-vars)\n- [Future work](#future-work)\n\n\u003c!-- toc-tail --\u003e\n\n## Development\n\n### Frameworks used\n\n- The app is structured as command-line commands using (yargs)[https://yargs.js.org]\n- A customised [ChowChow](https://github.com/robb-j/chowchow/) is used for routes and sockets\n  - Router are served [express](https://expressjs.com) underneath\n  - Sockets are served [socket.io](https://socket.io) underneath\n- Tests are written with [Jest](https://jestjs.io)\n- Structures are asserted with [superstruct](https://github.com/ianstormtaylor/superstruct#readme)\n\n### Setup\n\nTo develop on this repo you will need to have [Docker](https://www.docker.com/) and\n[node.js](https://nodejs.org) installed on your dev machine and have an understanding of them.\nThis guide assumes you have the repo checked out and are on macOS, but equivalent commands are available.\n\nYou'll only need to follow this setup once for your dev machine.\n\n```bash\n# Setup your dev environment\n# -\u003e Fill in the values in your favourite text editor\n# -\u003e Ask Rob for a SENDGRID_API_KEY\ncp .env.example .env\n\n# Install node.js dependencies\nnpm install\n```\n\n### Regular use\n\nThese are the commands you'll regularly run to develop the API, in no particular order.\n\n```bash\n# Start the docker dev stack\n# -\u003e It runs a redis instance for socket.io to use and to store authentications\n# -\u003e It runs postgres on localhost (see docker-compose.yml for connection details)\n# -\u003e Remember \"docker-compose down\" afterwards to stop and remove containers\n# -\u003e Runs in headless mode (-d)\ndocker-compose up -d\n\n# Run the content scraper\n# -\u003e Clones the schedule locally\n# -\u003e Reads in content and validates it\n# -\u003e Puts it into redis for the api\nnpm run dev scrape-content\n\n# Run database migrations\n# -\u003e Connects to database from .env\n# -\u003e Sets up and maintains 'migrations' table to track migrations\n# -\u003e Runs any new migrations\nnpm run dev migrate\n\n# Run the dev server\n# -\u003e Runs on port 3000\n# -\u003e Exit with control+C\n# -\u003e Exit and run again if code changes\nnpm run serve\n\n# Run the cli\n# -\u003e npm run serve uses this under the hood\n# -\u003e Can add more uses/entrypoints in the future\nnpm run dev # ...\n```\n\nTo run through an auth flow:\n\n```bash\n# Request a login token\n# -\u003e Example using httpie.org\nhttp :3000/login/email email==rob@andrsn.uk\n\n# Extract token from email\nTOKEN=...\n\n# Get an authentication token\nhttp :3000/login/email/callback token==$TOKEN\n```\n\n### Testing\n\nThere are unit tests alongside code in `__tests__` directories\nand integration tests in the `tests/` top-level directory.\nTests are using [Jest](https://jestjs.io/)\n\n\u003e Roughly, unit tests use jest's `it` and integration tests use `test`\n\n```bash\n# Run the tests\nnpm run test\n\n# Generate code coverage\nnpm run coverage\n\n# View the coverage report\nopen coverage/lcov-report/index.html\n```\n\n### Irregular use\n\nThese are commands you might need to run but probably won't, also in no particular order.\n\n```bash\n# See what the CLI can dp\nnpm run dev -- --help\n\n# Manually build JavaScript from TypeScript\nnpm run build\n\n# Manually run lint source code\nnpm run lint\n\n# Generate the table-of-contents in this readme\nnpm run readme-toc\n\n# Reset the jest cache\nnpx jest --clearCache\n\n# Generate an authentication token\n# -\u003e pass --email user@example.com to specify an email\n# -\u003e pass --url to output it as a login url instead\n# -\u003e pass --lang en/fr/es/ar to specify a user_lang\nnpm run dev fake-auth\n\n# Reset the redis scrape-content lock\n# -\u003e runs redis-cli in the redis container\n# -\u003e removes the hostname lock key\n# -\u003e can happen if the scrape catastrophically fails\ndocker-compose exec redis redis-cli del schedule_is_fetching\n```\n\n### Code formatting\n\nThis repo uses [Prettier](https://prettier.io/) to automatically format code to a consistent standard.\nIt works using the [yorkie](https://www.npmjs.com/package/yorkie)\nand [lint-staged](https://www.npmjs.com/package/lint-staged) packages to\nautomatically format code whenever it is commited.\nThis means that code that is pushed to the repo is always formatted to a consistent standard\nand you don't spend time worrying about code formatting.\n\nYou can manually run the formatter with `npm run prettier` if you want.\n\nPrettier is slightly configured in [package.json#prettier](/package.json) under `\"prettier\"`\nand can ignores files using [.prettierignore](/.prettierignore).\n\n### Useful links\n\n- https://sendgrid.com/docs/for-developers/sending-email/using-handlebars/\n\n## Deployment\n\nTo deploy a new version, use the [npm version](https://docs.npmjs.com/cli/version) command.\n\n```bash\nnpm version # minor | major | patch | --help\ngit push --follow-tags\n```\n\nThis command will bump the version in the package.json, commit that change\nand tag that commit with the new version.\nWhen that tag is pushed to git, a GitHub action will automatically\nbuild a docker image at that point in the git history.\n\nThis means that we have semantic versions for every change\nand they can easily be deployed.\n\n### env vars\n\n**required**\n\n- `SENDGRID_API_KEY`\n- `SENDGRID_FROM`\n- `SENDGRID_TRANSACTIONAL_TEMPLATE_ID`\n- `JWT_SECRET`\n- `SELF_URL`\n- `WEB_URL`\n- `REDIS_URL`\n- `SQL_URL`\n- `SPACES_KEY`\n- `SPACES_SECRET`\n- `SPACES_BUCKET`\n- `SCHEDULE_GIT_URL`\n\n**optional**\n\n- `CORS_HOSTS`\n- `ENABLE_ACCESS_LOGS`\n- `DEBUG=api*`\n- `NODE_ENV\n- `SCHEDULE_GIT_BRANCH` - choose a branch to scrape frmo\n\n## Future work\n\n- send an email when a scrape fails\n\n---\n\n\u003e This project was set up by [puggle](https://npm.im/puggle)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdigitalinteraction%2Fclimatered-server","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdigitalinteraction%2Fclimatered-server","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdigitalinteraction%2Fclimatered-server/lists"}