""refactor"" basically everything

This commit is contained in:
Enstrayed
2024-09-22 14:04:15 -07:00
parent 2e527a8539
commit 5f1181476d
14 changed files with 78 additions and 90 deletions

View File

@@ -8,37 +8,32 @@ This file contains documentation relevant for development and deployment, but no
If you would like to report a bug or security issue, please open a GitHub issue. If you are the operator of a service this application accesses, use the contact information provided during registration with your service to contact me directly.
## Configuration
On startup, this application will look for two files. If either cannot be read, it will exit with an error code.
1. `config.json` contains settings required for operation and API keys used for calling external services.
2. `GITVERSION` contains the commit that was cloned when the container was built.
The configuration is downloaded from CouchDB on startup, however two environment variables must be set to specify the URL of the CouchDB server and the credentials for accessing it:
| Variable | Required? | Purpose |
|--------------|----------------------|-----------------------------------------------------------------------------------------------------|
| `API_PORT` | No, defaults to 8081 | Sets the port the server will listen on |
| `API_DBHOST` | Yes | Complete URL of the CouchDB instance, including port and protocol |
| `API_DBCRED` | Yes | Credentials to access the CouchDB instance, in Basic Authentication format e.g. `username:password` |
<details> <summary>Configuration Example</summary>
* `couchdbHhost`: URL of CouchDB server.
* `frontpage.directory`: Directory of frontpage, will be served at root with modifications.
* `mailjet.apiKey`: Mailjet API Key.
* `mailjet.senderAddress`: Email address that emails will be received from, must be verified in Mailjet admin panel.
* `frontpage.frontpageDir`: Directory of frontpage, will be served at root with modifications.
* `nowplaying.*.apiKey`: API key of respective service.
* `nowplaying.*.target`: User that should be queried to retrieve playback information.
```json
{
"startup": {
"apiPort": 8081,
"routesDir": "./routes"
"frontpage": {
"directory": ""
},
"couchdbHost": "",
"mailjet": {
"apiKey": "",
"senderAddress": ""
},
"frontpage": {
"frontpageDir": ""
},
"nowplaying": {
"lastfm": {
"apiKey": "",
@@ -67,14 +62,13 @@ In production, this application is designed to be run in Docker, and the contain
> Please review the Configuration section of this document for important information. By default, the `config.json` file is expected to be mounted into the container at `/app/config.json`.
```dockerfile
FROM node:20
FROM node:22
WORKDIR /app
RUN git clone https://github.com/enstrayed/enstrayedapi .
RUN git config --global --add safe.directory /app
RUN git show --oneline -s >> GITVERSION
RUN npm install
USER node
ENTRYPOINT [ "node", "index.js" ]
```