pkronstrom / orb-api

A RESTful express.js API

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

orb-api

A RESTful express.js API for Orb

Installation

Requires node.js and npm.

  1. Install packages npm install
  2. Install and setup mongodb, run mongod
  3. Run Nodemon development server npm start
  4. Go to localhost:8080/

API Endpoints

All authorized endpoints require an authorization token (JWT) for access. The token can be claimed from /auth endpoint by logging in.

Send the acquired token as a Authorization: Bearer <token> HTTP Header for the following endpoints.


### / ###### GET (public) **returns** a html help page
### /auth ###### POST (public) Works as an endpont for user authorization.

parameters name, password as x-www-form-urlencoded or json parameters are required.

returns an authorizaton token (JWT) in response.


### /api/users ###### GET (authorization required) **returns** all the users on the database.
POST (public)

Works as an endpoint for user creation.

The following parameters are available:

Parameter Type Required Description
name String yes User nickname
password String yes A secure password
age Number yes User age in years
gender String: male/female yes User's gender
note String no A note that is shown to other users
latitude Number no User's current positional coordinates, lat
longitude Number no User's current positional coordinates, lon
following List [] no A list of user id's the User is following

### /api/users/[id] ###### GET (authorization required) **returns** a single user by
PUT (authorization required)

Updates user's data. See POST /api/users for available parameters. These fields can be updated individually (or all together).

DELETE (authorization required)

Deletes a single user from the database.

About

A RESTful express.js API


Languages

Language:JavaScript 100.0%