Skip to content
This repository has been archived by the owner on May 24, 2022. It is now read-only.

Latest commit

 

History

History
166 lines (111 loc) · 4.27 KB

README.md

File metadata and controls

166 lines (111 loc) · 4.27 KB

emote-server

Backend for the Emote Widget

All Contributors

Installation & Deployment

Deploy

Manual Deployment

  1. Create an Heroku application:
heroku create <app-name>
  1. Add Heroku Redis Support:
heroku addons:create heroku-redis:hobby-dev
  1. Deploy to Heroku
git push heroku main

Local Development

Install dependencies:

npm install

Run Server in development mode:

npm run start:dev

Configuration

  • REDIS_URL - A Redis connection string
  • RATE_LIMIT_MAX - Max number of requests per time window (Default: 100)
  • RATE_LIMIT_WINDOW - Duration of the Rate Limit time window (Default: 1 minute)
  • HEARTBEAT_TIMEOUT - Duration of the Heartbeat (Default: 30 seconds)
  • EVENT_ID_LENGTH - Max length of an Event ID (Default: 32 characters)
  • EVENTS_MAX - Max number of Event Streams (Default: 32)

API

GET /api/emote/:id

Returns the votes by Event

Url Parameters

  • id - Represents an Event by ID

Output

{
  "smile": 100,
  "love": 103,
  "plus_one": 5,
  "question": 1
}

POST /api/emote/:id

Submit a vote by Event

Url Parameters

  • id - Represents an Event by ID

Body

{
  "emote": "smile"
}

Output (200 - Success)

Body

{
  "message": "emote received"
}

Output (429 - Rate Limit)

Headers

retry-after: 60000
x-ratelimit-limit: 100
x-ratelimit-remaining: 0
x-ratelimit-reset: 39

Body

{
    "error": "Too Many Requests",
    "message": "Rate limit exceeded, retry in 1 minute",
    "statusCode": 429
}

GET /events/emote/:id

Connect to an event stream by Event ID

Events

  • emote - An emote has been received - (data: smile)
  • votes - A votes state object has been received (data: {"smile": 1, "question": 3})
  • heartbeat - A ping has been received (data: ping)

🤝 Contributing

We love contributions, small or big, from others!

Please see our CONTRIBUTING guidelines. The first thing to do is to discuss the change you wish to make via issue, email, or any other method with the owners of this repository.

Also, please review our code of conduct. Please adhere to it in all your interactions with this project.

Thanks goes to these wonderful ✨ people (emoji key) for contributing to the project:


Clifton Campbell

💻

Julián Duque

💻 🤔

This project follows the all-contributors specification. Contributions of any kind welcome!

Code of Conduct

Please review and adhere to our CODE_OF_CONDUCT.md before contributing to this project in any way (e.g. creating an issue, writing code, etc).

📝 License

This project is licensed under the Creative Commons Zero v1.0 License. See the LICENSE file for details.