Skip to content

urosaria/node_express_api

Repository files navigation

node_express_api

Prerequisites

This code worked & tested on node version v15.6.0.
Tested by Mac OS & Ubuntu-16.04.7.

Getting Started

If you don't have node, please install it.

In Ubuntu:


$ sudo apt-get update
$ sudo apt-get install -y build-essential 
$ sudo apt-get install -y nodejs 

Then check version:


$ node -v 

In order to clone the source from github, please install git. In Ubuntu:


$ sudo apt install git

Then clone the code:


$ git clone https://github.com/urosaria/node_express_api.git

Then follow:


$ cd node_express_api 
$ npm install
$ node bin/www

You can check API in your browser: http://{{host}}:3000/

APIs (Call random list of users)

This API provides a random list of members from backend server.

http://{{host}}:3000/

GET Users

Default list:


http://{{host}}:3000/

GET UsersByDept

Users by dept:


http://{{host}}:3000/dept/:dept

Example: http://127.0.0.1:3000/dept/IT
':dept' could be IT, Marketing, HR, Sales.

Result


{
    "users": [
        {
            "name": "Zachary Ouellet",
            "dept": "Sales",
            "position": "Manager",
            "email": "zachary.ouellet@example.com",
            "picture": "https://randomuser.me/api/portraits/men/63.jpg",
            "location": {
                "street": {
                    "number": 5836,
                    "name": "Oak St"
                },
                "city": "Armstrong",
                "state": "Newfoundland and Labrador",
                "country": "Canada",
                "postcode": "B9C 3S9",
                "coordinates": {
                    "latitude": "-60.9028",
                    "longitude": "-88.6122"
                },
                "timezone": {
                    "offset": "+5:45",
                    "description": "Kathmandu"
                }
            },
            "desc": "Zachary Ouelletis a Manager of Sales department. The primary responsibility is to sell an organisation’s services and products."
        },
      ...
    ]
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published