Skip to content

maheshbelnekar/Global_Phone_Directory

Repository files navigation

Global Phone Directory

RESTful webservice to maintain a global phone directory. Webserives updates and returns JSON allowing access through any remote system.

Installation and Setup

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.

Prerequisites

Check if you have node or npm installed:

node -v
npm -v

Check if you have mysql installed:

mysqladmin --version

Setup

git clone [email protected]:maheshbelnekar/Global_Phone_Directory.git
cd Global_Phone_Directory

Run npm(node) server

sudo npm install
sudo npm i -g nodemon
nodemon app.js

Now, the server should be up and running on localhost:3003.

Configuration

Node server port

By default, the node server runs on port 3003. You can change this my editing the app.listen() in app.js.

app.listen(3003,() => {
    console.log("Server is up and running on port 3003...")
})

Database server and password

You can either choose to connect to a remote database or run on a local one. Configuring the username and password(if present), is a must. Update getConnection() function in app.js.

// function to establish connection with the database
function getConnection() {
  return mysql.createConnection({
    host: 'localhost',
    user: 'root',
    password: 'password',
    database: 'my_directory'
  });
}

Database setup

Import the sql dump from "Global_Phone_Directory/db_scripts/global_directory.sql"

mysql -u root -p my_directory < global_directory.sql

REST Commands

The application currently provides following endpoints:

  • GET / localhost:3003/

Root request. Simply prints: "Hello from ROOT".

  • GET /users localhost:3003/users

Gets a list of all users.

  • GET /user/:id localhost:3003/user/3

Get details of the contact will key="id". Here, id refers to the id column in database.

  • POST /user_create localhost:3003/user_create

Add a new person to contact.

Screenshots

Get request

Show all contacts

Add new contact

Authors

Acknowledgments and Credits

About

RESTful webservice to maintain a global phone directory.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published