diff --git a/README.md b/README.md index 4973414..4ebd244 100644 --- a/README.md +++ b/README.md @@ -45,4 +45,49 @@ Represents an IDS level. - `tier`: `"Fuck"`, `"Beginner"`, `"Easy"`, `"Medium"`, `"Hard"`, `"Very Hard"`, `"Insane"` or `"Extreme"`. - `skillset`: Level skillset, as listed on the sheet. -- `broken`: If the level is broken in 2.2. `"no"`, `"yes"`, or rarely `null` if unknown. \ No newline at end of file +- `broken`: If the level is broken in 2.2. `"no"`, `"yes"`, or rarely `null` if unknown. + +### Self-hosting + +You can self-host the API yourself, if you so wish! Here's the rough steps: + +1. Grab yourself a Google Sheets API key. This may sound extremely intimidating, but you can create a read-only Sheets API key with not much hassle with [this guide](https://theoephraim.github.io/node-google-spreadsheet/#/guides/authentication?id=api-key). +2. Install, either with NPM or Nix: + 1. With NPM, run: + ```sh + npm install + ``` + Then, you can start it with: + ```sh + API_KEY=... node index.js + ``` + **However**, take note of the [environment variables](#environment-variables) available to use. + 2. Use Nix to either just plainly run it: + ```sh + API_KEY=... nix run git+https://git.oat.zone/oat/nlw-api + ``` + Or import it into your system flake like so: + ```nix + nlw-api.url = "git+https://git.oat.zone/oat/nlw-api"; + # in your `nixosConfiguration`: + imports = [ + inputs.nlw-api.nixosModules.nlw-api + ]; + ``` + Afterwards, you can use it as a regular NixOS service: + ```nix + services.nlw-api = { + enable = true; + domain = "nlw.oat.zone"; + apiKey = builtins.readFile /etc/sheets-api-key; + port = 1995; + }; + ``` +3. You're done! It will take a while to fetch every level and their IDs initially, but in time you will have yourself the caches set up and the server up and running. + +### Environment variables + +You can pass these into the server as config (an `.env` file will **not** work): + +- `API_KEY`: A Google API key - see [this guide](https://theoephraim.github.io/node-google-spreadsheet/#/guides/authentication?id=api-key) to see how to get one hassle-free +- `PORT`: The HTTP port to host the server on \ No newline at end of file