Skip to content

A sample API implementation supporting CRUD operations for phonebook contacts persisted into SQLite datastore.

Notifications You must be signed in to change notification settings

nikitasfrs/phonebook-api

Repository files navigation

Phonebook API

A sample API implementation supporting CRUD operations for phonebook contacts persisted into SQLite datastore.

Written using TypeScript, Node.js, Express.

Getting started

  1. Install dependencies using npm i
  2. Populate database with mock data using npm run populate-db
  3. Start server with npm start
  4. Experiment calling the available endpoints !

Available NPM scripts

Install dependencies

npm i

Test

npm test

Populate database with testing data

npm run populate-db

Start

npm start

Start development mode

npm run dev

Available operations

GET /contacts

curl --location --request GET 'http://0.0.0.0:3000/contacts?sortBy=contact_id&order=DESC' \
--data-raw ''

POST /contacts

curl --location --request POST 'http://0.0.0.0:3000/contacts' \
--header 'Content-Type: application/json' \
--data-raw '{
    "full_name": "koko",
    "phone_work": "123",
    "phone_mobile": "123",
    "phone_other": "123",
    "phone_home": "123",
    "email": "foo@bar",
    "address": "some address"
}'

PUT /contacts/:id

curl --location --request PUT 'http://0.0.0.0:3000/contacts/2' \
--header 'Content-Type: application/json' \
--data-raw '{
    "full_name": "FOO BAARRRRR",
    "phone_work": "784-235-0127 x488",
    "phone_mobile": "1-214-402-3151 x4870",
    "phone_home": "(413) 450-0103",
    "phone_other": "611-775-8196 x5190",
    "email": "[email protected]",
    "address": "359 Jaeden Gateway"
}'

DELETE /contacts/:id

curl --location --request DELETE 'http://0.0.0.0:3000/contacts/151' \
--data-raw ''

TODO

  • Increase coverage
  • Integration tests
  • API token access

About

A sample API implementation supporting CRUD operations for phonebook contacts persisted into SQLite datastore.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published