Skip to content

NicoToff/nestjs-spells-api

Repository files navigation

NestJS Spell API

Nest Logo

This simple API serves homebrewed spells for my campaigns of Dungeons & Dragons 5th Edition. It is built with NestJS, a framework for building efficient, scalable Node.js server-side applications.

This application is yours to use, modify and distribute as you see fit.

Installation

First, clone this project (HTTPS):

git clone https://github.com/NicoToff/nestjs-spells-api.git

Or (SSH):

git clone git@github.com:NicoToff/nestjs-spells-api.git

Run the app

Development mode

This project use pnpm as package manager. If you need to install it on your system, follow their installation guide.

Install the dependencies:

pnpm install
pnpm dev

You are going to need some API keys to use POST routes and populate your database. The API keys must be in UUID format and are expected to be stored in ENV variables under "API_KEYS" (comma-separated).

A dev-script convieniently creates a .env file for you with random API keys:

pnpm keys:gen --create-env

Then, in local dev environment, these keys are automatically pulled from the .env file directly.

Docker

The project contains a working Dockerfile. Provided you have Docker installed, as well as docker-compose, you can build and run the image with the following command:

docker-compose up -d --build

docker-compose is needed to set up ENV variables for the container.

Fly.io

My personal instance of this API is hosted on Fly.io. If you wish to also deploy this app through them, you'll find a fly.toml file in the repo that you can tailor to your needs.

Authenticate to Fly.io with:

flyctl auth login

You can deploy your own instance with the following command:

pnpm depl

This command will automically set secrets to your Fly.io instance.

If you only wish to create and push new API keys, run:

pnpm keys:gen && pnpm keys:sync

Whichever hosting provider you choose, you'll need to provide API keys as ENV variables.

Fly.io FAQ

You might run into this error:

Error: failed to update VM <id>: You have reached the maximum number of machines for this app.

Fly.io has a free tier that allows you to run 3 VMs at a time, but they also automatically provide redundancy when deploying your app. This means you end up with 2 machines for a single deployment, plus the auto-created "Free builder" => Max limit is indeed reached.

You can either upgrade your plan, or simply limit the number of VMs to 1 for all your apps by running:

fly scale count 1

About

A NestJS API that serves homebrewed D&D spells data and more.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages