A set of simple serverless APIs hosted on Netlify.
/encode/base64 takes a JSON input with a value field and returns a response with an encoded field containing the Base64 (UTF-8) encoding of that value.
Additional endpoints cover Base64 decoding, URL encoding/decoding, hex encoding/decoding, hashing, UUID generation and timestamps. A /usage endpoint returns anonymous counts for each API. The timestamp endpoint returns both ISO and UNIX formats and accepts an optional timezone query parameter using IANA names (for example, timezone=America/New_York).
This project uses a swagger.json file for all functions and loads Swagger UI from unpkg via index.html.
- Node.js (>= 14)
netlify-cliinstalled globally:npm install -g netlify-cli
-
Clone the repo:
git clone https://github.com/patricktobias86/microservice-directory.git cd microservice-directory -
Install dependencies:
npm install
-
(Optional) Create a
.envfile with aRATE_LIMIT_RPSvalue to limit requests per second. Example:echo "RATE_LIMIT_RPS=5" > .env
-
Run locally:
netlify dev
- API index page:
http://localhost:8888/
- API index page:
Send a POST request with a JSON body:
curl -X POST http://localhost:8888/encode/base64 \
-H "Content-Type: application/json" \
-d '{"value":"test"}'Response:
{"encoded":"dGVzdA=="}If RATE_LIMIT_RPS is set in the .env file, all functions enforce the
specified number of requests per second. When the limit is exceeded, functions
return HTTP 429 with { "error": "Too many requests" }.