Skip to content

ericve25/user-management-take-home

Repository files navigation

user-management-take-home

This project contains a small API to provide user registration and contact management. Please see Project-Instructions.pdf for the original directions.

Prerequisites

To run the API locally, make sure to have the following pieces set up before starting.

PostgreSQL

This API uses PostgreSQL as it's persistent storage.

  1. Install PostgreSQL
  2. (optional) Install an admin tool such as pgAdmin

Local Dev Setup for Mac OS X

  1. NodeJS can be installed however you wish: homebrew, n, or directly from the NodeJS website. This documentation uses nvm to switch between NodeJS versions.

    • Install nvm with curl
    curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.8/install.sh | bash
    
    • Reload your .bash_profile or .bashrc and verify your installation of nvm
    source ~/.bash_profile & nvm --version
    

    Output of nvm version number indicates nvm has successfully been installed.

    • Install latest version of node with nvm
    nvm install node
    
  2. Clone the repo

    git clone https://github.com/ericve25/user-management-take-home.git
    
  3. Copy .env.example to .env and customize values to your needs

    cp .env.example .env
    
  4. Install Dependencies

    npm install
    
  5. Initialize the database

    This will create a database named 'contacts_app' for you.

    node scripts/createDB.js
    
  6. Start the API

    npm start
    

Linting

Run linter to validate code style (using a modified version of the AirBnB style guide)

npm run lint

Testing

Run unit tests with code coverage or run with debugging.

npm run test
npm run test-debug

(Note: due to time constraints I ended up not including any tests at this point. Unit, integration, and acceptance tests could be added)

Development

Options to run using dotenv to load env vars and with debugging

npm run dev
npm run dev-debug

Cleaning

Cleans up all .gitignored files (must be called with 'npm run')

npm run clean

Documentation

Documentation for this API is contained here in the README. Please visit the API root route for list of endpoints.

(Note: in a production setting, I would add hosted docs generated from markdown with a static site generator such as Hugo.)

Deployment

API is not currently deployed, but can be for reference upon request.

(Note: in a production setting, I would add CI monitoring to all branches to support status checks before merging branches to master and automatic deployment of specified branches to testing servers plus triggered deployment of master for production.)

Authentication

This API uses JWT to secure its endpoints and provide authentication and authorization for a given user. The /register endpoint provides the JWT on registration, and the /login endpoint provides JWT when correct credentials are provided.

(Note: due to the time constraint of a tech assessment, only very basic authorization has been implemented and JWT are not set to expire. This is obviously bad practice and would be fixed in a non time constrained environment.)

Principles

This solution generally tries to follow the principles found in the 12-Factor App method. Some elements have not been addressed due to the time-constrained nature of a tech-assessment.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published