A lightweight, high-performance waitlist backend written in Go, using Fiber v3 as the web framework and LevelDB for data storage. The backend supports email registration, rate limiting, and optional hCaptcha verification for added security.
- Email Registration: Allows users to register their email for the waitlist, with each registration stored in LevelDB.
- In-Memory Waitlist Count: Tracks the total number of registered emails with a quick-access in-memory counter.
- Rate Limiting: Prevents abuse by limiting the number of registrations allowed from a single IP address within a specified time frame.
- Optional hCaptcha Verification: Adds an optional layer of security using hCaptcha to prevent bots from registering.
- High Performance: Built with Fiber v3, offering fast routing and efficient handling of concurrent requests.
- Lightweight Storage: Uses LevelDB to store email and timestamp data, ensuring a low overhead for database operations.
- Go 1.20+
- Optional: hCaptcha API Key (if enabling hCaptcha verification)
-
Clone the repository:
git clone https://git.randomchars.net/hizla/waitlist/backend.git cd backend
-
Build and run:
go build ./backend
-
Configure the environment: (Optional)
- Create a
.env
file in the root directory and add the following configuration options:DB=db VERBOSE=1 HCAPTCHA_SECRET_KEY=unset # set your hCaptcha secret key HCAPTCHA_SITE_KEY=unset # set your hCaptcha site key LISTEN=unset LISTEN_ADDR=127.0.0.1:3000 ALLOWED_URL=https://hizla.io
- Create a
Name | Usage | Default |
---|---|---|
DB | Filesystem path to database. Can be relative. | db |
LISTEN | Filesystem path to UNIX socket to listen on. | unset |
LISTEN_ADDR | Address to listen on if LISTEN is unset. | 127.0.0.1:3000 |
ALLOWED_URL | Allowed URL enforced by CORS. | https://hizla.io |
HCAPTCHA_SITE_KEY | hCaptcha site key. Disables hCaptcha if unset. | unset |
HCAPTCHA_SECRET_KEY | hCaptcha secret key. Disables hCaptcha if unset. | unset |
VERBOSE | Verbose logging. Set 0 to disable. | 1 |
Registers a new email to the waitlist.
-
Headers:
Content-Type: application/json
-
Request Body:
{ "email": "[email protected]", "hcaptcha_response": "optional-hcaptcha-response" }
-
Response:
200 OK
: Registration successful.400 Bad Request
: Invalid input data or hCaptcha validation failed.429 Too Many Requests
: Rate limit exceeded.500 Internal Server Error
: Server error.
-
Rate Limiting:
Each IP address is limited to5
registrations per week.
Returns the total number of registered emails in the waitlist.
- Response:
1234
Contributions are welcome! Please follow these steps:
- Fork the repository.
- Create a new feature branch (`git checkout -b feature/my-feature`).
- Commit your changes (`git commit -m "feat: add new feature"`).
- Push the branch (`git push origin feature/my-feature`).
- Open a pull request.
This project is licensed under the AGPLv3 License. See the LICENSE file for details.
For any questions or support, feel free to open an issue.