Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/peimelo/toh-api
Tour of Heroes API made with NodeJS.
https://github.com/peimelo/toh-api
api course javascript nodejs tour-of-heroes
Last synced: about 20 hours ago
JSON representation
Tour of Heroes API made with NodeJS.
- Host: GitHub
- URL: https://github.com/peimelo/toh-api
- Owner: peimelo
- Created: 2020-07-07T09:08:47.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2023-03-07T04:45:03.000Z (over 1 year ago)
- Last Synced: 2024-04-14T07:50:22.314Z (7 months ago)
- Topics: api, course, javascript, nodejs, tour-of-heroes
- Language: JavaScript
- Homepage: https://toh-api.vercel.app/api
- Size: 250 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# API Server
To install and start the API server, run the following commands in this directory:
- `npm install`
- `node server`Open `http://localhost:3000`
## Using The Server
### Include An Authorization Header
`POST /api/sessions`: returns a `token` in the body and also in the header. You can use this `token` in the following endpoints.
All requests, except `POST /api/sessions`, use an **Authorization** header, of size >= 10 characters, so that you can only manipulate your data, for example:
```js
fetch(url, {
headers: { Authorization: 'whatever-you-want' },
});
```### API Endpoint
The following endpoints are available:
| Endpoints | Usage | Params |
| --------------------------- | ------------------------------------- | ------------------------------------------------ |
| `POST /api/sessions` | Authenticates the user. | **email** - [String]
**password** - String] |
| `GET /api/heroes` | Get all of the heroes. | |
| `GET /api/heroes?name=term` | Get all heroes with name like a term. | **term** - [String] |
| `GET /api/heroes/:id` | Get the details of a single hero. | |
| `POST /api/heroes` | Add a new hero. | **name** - [String] |
| `PUT /api/heroes/:id` | Edit the details of an existing hero. | **name** - [String] |
| `DELETE /api/heroes/:id` | Remove the hero. | |