A mirror of the github repo for the backend of my website https://api.wireless.fish
  • TypeScript 97.9%
  • Dockerfile 2.1%
Find a file
2026-04-11 12:23:02 +02:00
src updated domain n stuff 2026-04-11 12:05:57 +02:00
.dockerignore fix docker ignore 2026-04-11 12:23:02 +02:00
.env.example updated domain n stuff 2026-04-11 12:05:57 +02:00
.gitignore added database backups 2026-02-02 14:49:51 +01:00
docker-compose.dev.yml updated domain n stuff 2026-04-11 12:05:57 +02:00
docker-compose.yml updated domain n stuff 2026-04-11 12:05:57 +02:00
Dockerfile Fixed cf tunnel 2026-02-02 18:27:53 +01:00
package-lock.json updated domain n stuff 2026-04-11 12:05:57 +02:00
package.json updated domain n stuff 2026-04-11 12:05:57 +02:00
README.md updated domain n stuff 2026-04-11 12:05:57 +02:00
schema.sql added db schema 2026-02-02 16:10:48 +01:00
tsconfig.json Added docker and sqlite support 2026-02-01 17:15:07 +01:00

Website backend (Express API)

Endpoints

GET /

Health check

Response: 200 OK

GET /guestbook

Retrieves all guestbook messages.

Response:

let response = {
  count: number,
  entries: {
    id: number,
    name: string,
    content: string,
    reply_to: number | null,
    site: string | null,
    created_at: string,
  },
};

POST /guestbook

Adds a new message to the guestbook

Request Body:

let request_body = {
  name: string,
  content: string,
  reply_to: number, // optional
  site: string, // optional, MUST be a URL
};

Response: 200 OK

Error Responses:

  • 400 Bad Request - Missing required fields or invalid data

GET /lastfm

Health check for Last.fm API availability

Response: 200 OK

Error Responses:

  • 502 Bad Gateway - Last.fm API appears to be down

GET /lastfm/recent

Retrieves recent tracks for a Last.fm user

Query Parameters:

  • user (required) - Last.fm username
  • limit (optional) - Number of tracks to return (default: 50, minimum: 1)

Example:

GET /lastfm/recent?user=username&limit=10

Response: 200 OK

For response contents, see last.fm/api getRecentTracks method or the type RecentTracks from src/types.ts

Error Responses:

  • 400 Bad Request - Missing required parameter
  • 500 Internal Server Error - API request failed

GET /lastfm/info

Retrieves user information about a Last.fm user

Query Parameters:

  • user (required) - Last.fm username

Example:

GET /lastfm/info?user=username

Response: 200 OK

For response contents, see last.fm/api getInfo method or the type UserInfo from src/types.ts

Error Responses:

  • 400 Bad Request - Missing required parameter
  • 500 Internal Server Error - API request failed

POST /ntfy

Sends a notification

Request Body:

let request_body = { text: string };

Response: 200 OK

Error Responses:

  • 400 Bad Request - Missing required field
  • 500 Internal Server Error - Failed to process notification

Rate Limiting

Rate limiting is enabled in production (when DEV_ENV is not set):

  • 100 requests per 5 minutes per IP
  • Standard RateLimit headers are used

Environment Variables

Required:

  • NTFY_BACKEND - NTFY URL for backend notifications
  • NTFY_MOBILE - NTFY URL for mobile notifications
  • LASTFM_KEY - Last.fm API key

Optional:

  • DEV_ENV - Set to disable rate limiting (development mode)

Scheduled Tasks

  • Weekly Backup: Every Sunday at 2:00 AM, the database is automatically backed up (backup is also created when the program is started)

Development

Runs on port 3000 and accepts connections from all interfaces (0.0.0.0).