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.
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
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
Install dependencies with the command npm install
- bcrypt: hashes data
- cors: enables Cross-origin resource sharing
- dotenv: loads variables from env file
- express: minimalist web framework
- helmet: secures http headers
- jsonwebtoken: implementation of json web tokens
- knex: SQL query builder
- morgan: HTTP request logger middleware
- pg: PostgreSQL client
- swagger-jsdoc: generates OpenAPI spec from JSDoc -annotated code
- swagger-ui-express: Serves swagger-ui generated API docs from OpenAPI Spec
- uuid: creations RFC4122 UUIDs
- cypress: end-to-end testing tool
- eslint: AST-based pattern checker for JavaScript
- eslint-config-standard: eslint config that follows JavaScript Standard Style
- eslint-plugin-cypress: eslint plugin for cypress
- eslint-plugin-import: eslint plugin for import/export, dependency of eslint-config-standard
- eslint-plugin-node: eslint plugin for node.js, dependency of eslint-config-standard
- eslint-plugin-promise:eslint plugin for promises dependency of eslint-config-standard
- nodemon: Development toll that restarts application when changes are detected
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
Run migrations with the command npm run db:migrate
Migration files are located in data/migrations
folder.
Run seeds with the command npm run db:seed
Seed files are located in data/seeds
folder.