Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hassan-ak/wmd-next-simple-books-api
⭐⭐⭐ WMD Next-Neon Assignment :- Simple Book API
https://github.com/hassan-ak/wmd-next-simple-books-api
neon nextjs rest-api vercel
Last synced: about 2 months ago
JSON representation
⭐⭐⭐ WMD Next-Neon Assignment :- Simple Book API
- Host: GitHub
- URL: https://github.com/hassan-ak/wmd-next-simple-books-api
- Owner: hassan-ak
- Created: 2023-04-18T16:18:14.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2023-04-21T17:13:34.000Z (almost 2 years ago)
- Last Synced: 2024-11-07T13:12:29.686Z (3 months ago)
- Topics: neon, nextjs, rest-api, vercel
- Language: TypeScript
- Homepage: https://wmd-next-simple-books-api.vercel.app/
- Size: 101 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Simple Books API using Next.js 13 and Neon
This REST API allows you to reserve a book. This API is fully founctional with SQL calls to Neon Database and deployed on Vercel.
It mirrors the funtionality available at [Simple Book Api](https://simple-books-api.glitch.me/).
---
## EntryPoint
[https://wmd-next-simple-books-api.vercel.app/api](https://wmd-next-simple-books-api.vercel.app/api)
---
## Endpoints
### Status
GET `/status`
Returns the status of the API.
### List of books
GET `/books`
Returns a list of books.
Optional query parameters:
- type: fiction or non-fiction
- limit: a number between 1 and 20.### Get a single book
GET `/books/:bookId`
Retrieve detailed information about a book.
### Submit an order
POST `/orders`
Allows you to submit a new order. Requires authentication.
The request body needs to be in JSON format and include the following properties:
- bookId - Integer - Required
- customerName - String - RequiredExample
```
POST /orders/
Authorization: Bearer
{
"bookId": "1",
"customerName": "John"
}
```The response body will contain the order Id.
### Get all orders
GET `/orders`
Allows you to view all orders. Requires authentication.
### Get an order
GET `/orders/:orderId`
Allows you to view an existing order. Requires authentication.
### Update an order
PATCH `/orders/:orderId`
Update an existing order. Requires authentication.
The request body needs to be in JSON format and allows you to update the following properties:
- customerName - String
Example
```
PATCH /orders/PF6Mfl
Authorization: Bearer
{
"customerName": "John"
}
```### Delete an order
DELETE `/orders/:orderId`
The request body needs to be empty.
Delete an existing order. Requires authentication.
Example
```
DELETE /orders/PF6Mfl
Authorization: Bearer
```---
## API Authentication
To submit or view an order, you need to register your API client.
POST `/api-clients/`
The request body needs to be in JSON format and include the following properties:
- clientName - String
- clientEmail - String```
Example
{
"clientName": "user",
"clientEmail": "[email protected]"
}
```The response body will contain the access token. The access token is valid for 7 days.
### Possible errors
Status code 409 - `"`API client already registered.`"` Try changing the values for clientEmail and clientName to something else.