Closed aldy505 closed 2 years ago
itu yang di expose keluar cuma /api/register, endpoint yang lain ga ada yang di expose to the internet
How to run the etcd database on your local machine:
docker network create pesto
docker compose up -d db
Then set the etcd address to http://localhost:2379
(or maybe just localhost:2379
)
tambah satu endpoint /healthz
isinya panggil ini, cek kalo ada yang statusnya ga ok https://javadoc.io/doc/io.etcd/jetcd-core/latest/io/etcd/jetcd/Maintenance.html
Create a new module (or service, if you prefer that) on the
/registration
directory, written in any language. The module is a simple HTTP server with no CORS or security middleware being attached to it (because we're handling that on the API gateway level).Some endpoints:
POST /api/register
Register the user into the waitlist. The email format should be validated. See https://stackoverflow.com/a/13013056
Request body:
Response: just give them a status code of 200, the body is optional. It's up to you.
GET /api/pending
Shows users that are still on the waitlist. Will return an empty array if the waitlist is empty.
Empty request body.
Response body:
PUT /api/approve
Approve a user from the waitlist. Remove user from the waitlist, and store a key value of:
key: token, value: {"user_email":"email","revoked":false}
on etcd.Request body:
Response: just give a status code of 200 if successful, and a status code of 404 if not found.
PATCH /api/revoke
Revoke a token. Change the key-value on etcd for the key
token
to be:{"user_email":"the original email","revoked":true}
Request body:
Response: just give a status code of 200 if successful, and a status code of 404 if not found.
Client library
The official etcd client library is here: https://github.com/etcd-io/jetcd
We will be using Sentry for error logging and tracing. But, I guess it's not really easy to implement Sentry if you haven't read the documentation and how it works, so this may come later. The documentation for it: https://docs.sentry.io/platforms/java/ (if you chose other language than Java, scroll down a bit, and on the left navigation bar, there's some other platform)