This repository houses code for Address Book's backend.
This is a simple RESTful API for an address book. Part of an online assessment for STRV. It allows a user to:
- Register a new account.
- Log in to the created.
- Add a contact to Firebase
.
├── .github # Compiled files
├── database # Database migration scripts and seeders
├── docs # Documentation files
├── src # Source files
├── test # Automated tests
├── .env.example
├── LICENSE
├── package.json
└── README.md
Each response will be returned with one of the following HTTP status codes:
200
OK
The request was successful400
Bad Request
There was a problem with the request (security, malformed)401
Unauthorized
The supplied API credentials are invalid403
Forbidden
The credentials provided do not have permissions to access the requested resource404
Not Found
An attempt was made to access a resource that does not exist in the API500
Server Error
An error on the server occurred
The API response, to the best of my ability, is structure after JSEnd specifications.
- For a
success
response, the server will return a response of this format:
{
"status": "success",
"message": "success message from the API server"
"data": { ... }
}
- For an
error
response, the server will return a response of this format. Thetrace
key in theerror
object is returned ifNODE_ENV === development
.
{
"status": "error",
"error": {
"message": "error message from the API server",
"trace": {
"statusCode": <status-code>
}
}
}
- Project Specifications
- Project Entities Model
- API on Staging Environment
- API Documentation
- Postman Collection
This project uses Express.js v4.17. It has the following dependencies:
- Firebase Admin for storing contacts.
- Github Actions for Continuous Integration and Deployment.
- Heroku for hosting the API.
This project is hosted on Github. You can clone this project directly using this command:
git clone https://github.com/meetKazuki/address-book.git
- Create a PostgreSQL database by running the
cmd
below:
createdb -h localhost -p 5432 -U postgres <database_name>
- After cloning the repository, create a
.env
file from.env.example
and set your local.env.
variable(s).
cp .env.example .env
- Install the dependencies
npm install
- Run migration
npm run db:migrate
- You can run the server using
npm run dev
- Other
npm
scripts are also available for handling database migration and database seeding:npm run db:migrate
runs script that is responsible for creating tables and their columns in the database,db:migrate:undo
: undoes the effect ofnpm run db:migrate
,db:reset
: undoes all the migrations, then runs migration on the database,db:seed
: responsible for seeding records in the database,
To run tests, run
npm test
Notice a bug? Please open an issue. Need more clarification on any part of the code base? Contact Desmond.
To contribute to this project, start by raising an issue. There are issue templates for bug and feature request. Once this issue has been agreed upon, you can create a feature or hotfix branch off develop or master (for hotfix) and raise PR. There is also a PR template.
This project is licensed under the MIT License
- Desmond Edem - Initial work