a RESTful API for a bookstore application using Node.js, Express, and TypeScript. The API should manage books, authors, and categories. Each book has a title, author, category, publication year, and ISBN.
|--- logs
|--- prisma
|--- src
| |--- controllers
| |---
| |--- middlewares
| | |--- validations
| |--- routes
| | |--- api
| | | |--- v1
| |--- services
| |--- utils
| |--- swagger.ts
| |--- test
|--- .env
|--- .env.example
|--- jest.config.js
|--- .gitignore
|--- package.json
|--- tsconfig.json
|--- README.md
- Node.js
- TypeScript
- Express
- ts-node-dev
- Prisma
- Jest
- Supertest
- Swagger
- Bcrypt
- Jsonwebtoken
- Dotenv
- Cors
- Morgan
The database schema can be found at: Database Schema
- Edit the .example.env file with app credentials and rename it to .env
- Run
npm run start:dev
to start the development server - Run
npm test
to run the tests - Visit
https://be-assessment.onrender.com/api/v1/greetings
to see the result
-
Swagger Api Documentation can be found at: API Documentation
-
PostMan Documentation can be found at: PostMan Documentation
All endpoints are prefixed with https://be-assessment.onrender.com/api/v1/
.
- Description: Retrieve all categories.
- Security: Requires bearer authentication.
- Responses:
200
: A list of categories.
- Description: Get a category by ID.
- Security: Requires bearer authentication.
- Parameters:
categoryId
- ID of the category to retrieve. - Responses:
200
: Category found.404
: Category not found.
- Description: Create a new category.
- Security: Requires bearer authentication.
- Body: Category object.
- Responses:
201
: Category created successfully.400
: Bad request, invalid data supplied.
- Description: Update a category by ID.
- Security: Requires bearer authentication.
- Parameters:
categoryId
- ID of the category to update. - Body: Updated Category object.
- Responses:
200
: Category updated successfully.404
: Category not found.
- Description: Delete a category by ID.
- Security: Requires bearer authentication.
- Parameters:
categoryId
- ID of the category to delete. - Responses:
204
: Category deleted successfully.404
: Category not found.
- Description: Retrieve all books.
- Security: Requires bearer authentication.
- Responses:
200
: A list of books.
- Description: Get a book by ID.
- Security: Requires bearer authentication.
- Parameters:
bookId
- ID of the book to retrieve. - Responses:
200
: Book found.404
: Book not found.
- Description: Create a new book.
- Security: Requires bearer authentication.
- Body: Book object.
- Responses:
201
: Book created successfully.400
: Bad request, invalid data supplied.
- Description: Update a book by ID.
- Security: Requires bearer authentication.
- Parameters:
bookId
- ID of the book to update. - Body: Updated Book object.
- Responses:
200
: Book updated successfully.404
: Book not found.
- Description: Delete a book by ID.
- Security: Requires bearer authentication.
- Parameters:
bookId
- ID of the book to delete. - Responses:
204
: Book deleted successfully.404
: Book not found.
- Description: Retrieve all authors.
- Security: Requires bearer authentication.
- Responses:
200
: A list of authors.
- Description: Get an author by ID.
- Security: Requires bearer authentication.
- Parameters:
authorId
- ID of the author to retrieve. - Responses:
200
: Author found.404
: Author not found.
- Description: Create/Register a new author.
- Body: Author object.
- Responses:
201
: Author created successfully.400
: Bad request, invalid data supplied.
- Description: Update an author by ID.
- Security: Requires bearer authentication.
- Parameters:
authorId
- ID of the author to update. - Body: Updated Author object.
- Responses:
200
: Author updated successfully.404
: Author not found.
- Description: Delete an author by ID.
- Security: Requires bearer authentication.
- Parameters:
authorId
- ID of the author to delete. - Responses:
204
: Author deleted successfully.404
: Author not found.
- Description: Login an author.
- Body: Credentials object.
- Responses:
200
: Login successful.400
: Invalid credentials.
- Description: Logout an author.
- Responses:
200
: Logout successful.