Merge changes into new auth branch
Enstrayed API
This repository contains the code for my personal web API written in JavaScript using the Express framework.
Documentation
This file contains documentation relevant for development and deployment, but not necessarily usage. Information for all endpoints is available on my website.
Issues
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.
config.jsoncontains settings required for operation and API keys used for calling external services.GITVERSIONcontains the commit that was cloned when the container was built.
Configuration Example
couchdb.host: Hostname/IP address and port of a CouchDB server.couchdb.authorization: Username & password used to access the CouchDB server, in HTTP Basic authentication format, e.g.username:password.blog.postsDirectory: Directory that will be parsed when calling /blogposts. If running in Docker this directory will need to be mounted to the container.blog.postsDirUrl: Location of the posts directory on the web server.nowplaying.*.target: Set to the Last.fm/Jellyfin username to query for playback information.
{
"startup": {
"apiPort": 8081,
"routesDir": "./routes"
},
"couchdb": {
"host": "hazeldale:5984",
"authorization": ""
},
"mailjet": {
"apiKey": "",
"senderAddress": "apinotifications@enstrayed.com",
"senderName": "API Notifications",
"authKeysDoc": "mailjet"
},
"blog": {
"postsDirectory": "C:/Users/natha/Downloads/proto/posts",
"postsDirUrl": "/posts"
},
"nowplaying": {
"lastfm": {
"apiKey": "",
"target": "enstrayed"
},
"jellyfin": {
"apiKey": "",
"host": "",
"target": ""
},
"cider": {
"apiKeys": [],
"hosts": []
}
}
}
Docker
In production, this application is designed to be run in Docker, and the container built by pulling the latest commit from the main branch. As such, deploying this application is just a matter of creating a directory and copying the Dockerfile:
Important
Please review the Configuration section of this document for important information. By default, the
config.jsonfile is expected to be mounted into the container at/app/config.json.
FROM node:20
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
ENTRYPOINT [ "node", "index.js" ]
Docker Compose File
---
services:
enstrayedapi:
build:
context: .
image: enstrayedapi
container_name: enstrayedapi
restart: unless-stopped
volumes:
- ./config.json:/app/config.json
License
If for whatever reason you want to, you are free to adapt this code for your own projects or as reference. However, this software is provided as-is with no warranty or agreement to support it.