A RESTful express.js API for Orb
Requires node.js and npm.
- Install packages
npm install
- Install and setup mongodb, run
mongod
- Run Nodemon development server
npm start
- Go to localhost:8080/
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.
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
Updates user's data. See POST /api/users for available parameters. These fields can be updated individually (or all together).
Deletes a single user from the database.