This project contains a small API to provide user registration and contact management. Please see Project-Instructions.pdf for the original directions.
To run the API locally, make sure to have the following pieces set up before starting.
This API uses PostgreSQL as it's persistent storage.
- Install PostgreSQL
- (optional) Install an admin tool such as pgAdmin
- If using pgAdmin - configure for localhost
-
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
-
Clone the repo
git clone https://github.com/ericve25/user-management-take-home.git
-
Copy .env.example to .env and customize values to your needs
cp .env.example .env
-
Install Dependencies
npm install
-
Initialize the database
This will create a database named 'contacts_app' for you.
node scripts/createDB.js
-
Start the API
npm start
Run linter to validate code style (using a modified version of the AirBnB style guide)
npm run lint
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)
Options to run using dotenv to load env vars and with debugging
npm run dev
npm run dev-debug
Cleans up all .gitignored files (must be called with 'npm run')
npm run clean
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.)
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.)
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.)
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.