This repository contains the express-based API that powers the Mixnjuice frontend.
- Express
- Sequelize
- passport-http-bearer
- postgrator to handle SQL migrations
Before use, from psql as the postgres user:
create database flavors;
create user flavors with encrypted password 'changeme';
grant all privileges on database flavors to flavors;
\c flavors
create extension if not exists "pgcrypto";The pgcrypto extension is used to generate UUIDs.
Now, in a shell:
npm install
npm run build
cp .env.default .envConfiguration resides in .env. Edit this file and supply your database information. Finally:
npm run migrate
npm startYou can use npm run migrate 0 to revert all database migrations, or npm run migrate X to migrate to version X.
Some requests require a bearer token by default. If you start the server with the API_TOKEN_VALIDATE environment variable set to false the token check will be bypassed. For convience you can run npm run start-mock to start the API up with anonymous auth enabled.
Simply run docker-compose up from the source root. Use the --no-start option to create the containers without starting them in interactive mode.
You can manually migrate the database using
docker-compose run --rm api npm run migrateTo send email using Amazon SES, install the AWS CLI. Then run
aws configureAlternatively, configure the AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment variables in .env.
You can clean out tokens that have expired more than three hours ago using
node lib/cleanTokens.jsVisual Studio Code is the recommended IDE for this project.
The following VS Code extensions will improve your development experience:
dbaeumer.vscode-eslintesbenp.prettier-vscode
The recommended settings for the extensions and VS Code are saved in .vscode/settings.json and will automatically be used.