/reading-tracker-server

Express API and PostgreSQL backend for reading tracker app

Primary LanguageJavaScript

Reading Tracker Backend

Backend made up of a Node.js Server, Express.js API & PostgreSQL database set up using Knex.js. Used to store data to be used for users to create books lists and tracker their reading progress.

Endpoints

This project is leveraging the swagger-jsdoc and swagger-ui-express libraries to document the endpoints. Documentation is available on the /api-docs route, Deployed Documentation

Local Database Set Up

To set up locally you must have PostgreSQL installed locally. Download

Once you have PostgreSQL installed locally you will need to create a database, the psql command is CREATE DATABASE dbname

After the database is created in your psql service create a .env file in the root with the environment variable DATABASE_URL set to your database url. database url example DATABASE_URL=postgres://postgres@localhost/dbname

Node Dependencies

Install dependencies with the command npm install

Production Dependencies:

Development Dependencies:

Environment variables

This repo uses environment variables to help maintain security, allow for easier configuration, and hopefully fewer mistakes in production.

// .ENV EXAMPLE
NODE_ENV=development
PORT=1337
DATABASE_URL=postgres://psqlUsername:psqlUserpass@localhost:5432/dbname
SEEDED_PASS_ONE=apassword
SEEDED_PASS_TWO=anotherpassword
SEEDED_PASS_THREE=surpriseAnotherpassword
SALT=525600

Data Migrations

Run migrations with the command npm run db:migrate Migration files are located in data/migrations folder.

Data Seeds

Run seeds with the command npm run db:seed Seed files are located in data/seeds folder.