This repository contains the source code for a REST API built using Node.js that simulates a contact book. It includes functionality to consume, encrypt, and store contact data, as well as fetch, decrypt, update, and delete data.
-
Clone the repository to your local machine:
git clone https://github.com/bollo-omar/contact-book.git
-
Install the required dependencies:
npm install
-
Set up the SQLite database (see Database).
-
Start the server:
npm start
-
Setup Prisma Migration
npx prisma migrate dev --name init
-
The API will be accessible at
http://localhost:3000
orhttp://localhost:8000
. -
Create
.env
file at the root of the project, copy contents of.env.example
and paste the on the new file
GET /api/v1/contacts
: Fetch all contacts.GET /api/v1/contacts/:id
: Fetch a specific contact by ID.POST /api/v1/contacts
: Add a new contact.PUT /api/v1/contacts/:id
: Update an existing contact.DELETE /api/v1/contacts/:id
: Delete a contact by ID.
For detailed information on how to use each endpoint, refer to the API documentation. Postman
All contact data is encrypted using AES-256 encryption before being stored in the database. When fetching data, it is decrypted before being returned.
The contact information is stored in an SQLite database. You can find the database file at ./prisma/contact.db
. The database is set up automatically when you start the server.
Thank you for using the Contact Book REST API! If you have any questions or encounter any issues, please don't hesitate to open an issue.