Viral Waitlist API Service
Table of Contents
About The Project
I wanted to build a viral waitlist (where people can move up the waitlist by referring other people) for recent project.
I wanted to control the UX and experience, so I needed it as a headless API. There are a number of "viral waitlist as a service" services out there, but only few of them offered APIs, and none of them were good.
So I built my own real quick and this is it.
Through this service's API users can be added to the waitlist (with optional referral ID), confirm email addresses, and get a users position. It also has some common sense stuff like validating email addresses, rate limiting, and disallowing disposable email providers. That's pretty much it.
Built With
Getting Started
It's a single simple express server that uses Postgres for storing user data.
Ratelimiting is just done in memory, you'll want to add Redis if you have multiple servers running.
Prerequisites
- npm (v6 or greater)
- node (v12 or greater)
- postgres (v12 or greater)
Installation
- Fork and clone this repo
- Install NPM packages
- Copy
.env.exampleto.envand update values - Create a postgres database (default name is
waitlist_development) - Run npm build (does database migrations, etc.)
- Update instances of "example" throughout the codebase with your URL / name (TODO: move this to env var)
- Run locally
Usage
The service is almost entirely used via the GraphQL API (can add a REST API if there's enough demand). There is a single endpoint at /confirmEmail used as a link in welcome emails to confirm their email address.
The GraphQL endpoint is at /graphql by default. The mutation signup takes the arguments of email (and optional referrerId which is the ID of the referring user).
This returns the user which includes their position. This mutation is idempotent and can always be used to return a user's position (along with the user query).
When a user / email is signed up, they receive an email to confirm their email address. They confirm their email address by clicking on a link which takes them to /confirmEmail. Update the link they are emailed to your instance URL in src/libraries/nodemailer.ts.
(TODO: update this to an env var).
Every 5 minutes all the users positions are updated (by the number of points/referrals they have, then by sign up time).
There is no functionality to remove people from the list or "invite" them. I just did this manually with direct access to the database.
Roadmap
See the open issues for a list of proposed features (and known issues).
Contributing
Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated.
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature) - Commit your Changes (
git commit -m 'Add some AmazingFeature') - Push to the Branch (
git push origin feature/AmazingFeature) - Open a Pull Request
License
Distributed under the GNU GPLv3 License. See LICENSE for more information.
Contact
Adrian Artiles - @AdrianArtiles
Project Link: https://github.com/AdrianArtiles/viral-waitlist-api