This is the backend API codebase for HabiTools, a set of tools and automations for Habitica. The goal is to create a clean interface without requiring users to install or manage scripts yourself.
The live site can be visited at habitools.online.
- Recommended method, use the provided docker setup to run an instance of PostgreSQL.
- Make sure you aready have the ability to run docker-compose locally.
- The docker-compose file is set up to use the values in your
.envfor initializing postgres. - It's recommended to already have Yarn installed. You can install it globally with
npm install --global yarn. - Use the npm scripts
yarn db:up,yarn db:logs, andyarn db:downto manage the postgres instance.
- Alternatively, you can run PostgreSQL directly on your local machine.
- You can take a look at the Initializing Postgres instructions to help with initial setup.
- Pre-requisite: You need your local PostgreSQL instance running.
- These instructions assume you already have
node.jsinstalled on your system. - You will need Yarn. You can install it globally with
npm install --global yarn. - Install modules:
yarn install. - Duplicate
.env.examplefile to.env.- Fill in all necessary values. Blank-out any that you don't have values for. For example:
EMAILER_API_KEY=. - Make sure
NODE_ENVisdevelopment.
- Fill in all necessary values. Blank-out any that you don't have values for. For example:
- Create and seed the database with
yarn db-reset-dev. - Start the dev server:
yarn start.
- Pre-requisite: You need your local PostgreSQL instance running.
- Install modules:
yarn install --production. - Duplicate
.env.examplefile to.env.- Fill in all necessary values. Blank-out any that you don't have values for. For example:
EMAILER_API_KEY=. - Make sure
NODE_ENVisproduction.
- Fill in all necessary values. Blank-out any that you don't have values for. For example:
- Build with
yarn build:prod. - Create and seed the database:
- Migrate:
yarn migrate:prod - Seed (Warning: This operation will erase all existing data):
npx knex seed:run --knexfile build/knex/knexfile.js
- Migrate:
- Start the production server with
yarn start:prod
This is the recommended method for live production and staging environments.
- You will need a PostgreSQL instance. The recommended method is to use docker for this in production. There are many ways to accomplish pairing the database and backend, so I won't be touching on that here.
- Make sure your env variables are attached. It's recommended to NOT use an
.envfile in production as this is a security risk and maintainability liablity. Instead, use a build system or PaaS that will inject env variables into the application at build-time. - Your first time running production this way, you should set the env variable
SEED_PRODUCTION_DANGEROUStotrue. This will blow away the existing data and seed it. It's important to remove this variable afterwards.- It is recommended to actually remove this variable entirely, don't just set it to
false. This reduces the risk of accidentally running it again in production and losing all you data!
- It is recommended to actually remove this variable entirely, don't just set it to
- The application will set it's port to 3000. It's recommended to forward this to port 3001, but any port will do.
- You'll notice there aren't any specific commands or configurations provided. That's because this application should be part of a larger system and it would get far too complex to document even the most common use-cases.
This project is licensed under the GNU Affero General Public License v3 (AGPLv3).
You are free to use, modify, and distribute this software under the terms of the AGPLv3.
If you wish to use this software in a proprietary product, offer it as a service without releasing source code, or otherwise not comply with AGPLv3 requirements, you must obtain a commercial license.
For commercial licensing inquiries, contact: JDudzik950@gmail.com
By contributing to this project, you agree to the Contributor License Agreement (CLA).
See the CLA.md file for details.