Git Product home page Git Product logo

emote-server's Introduction

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.