Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kirti136/kriscent_assignment
https://github.com/kirti136/kriscent_assignment
Last synced: 20 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/kirti136/kriscent_assignment
- Owner: kirti136
- Created: 2024-05-21T09:37:50.000Z (8 months ago)
- Default Branch: main
- Last Pushed: 2024-05-21T15:56:18.000Z (8 months ago)
- Last Synced: 2024-05-22T12:36:22.689Z (8 months ago)
- Language: JavaScript
- Size: 7.34 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Kriscent Assignment Backend
This is the backend API for the Kriscent Assignment. It provides routes for user authentication, authorization, and book management. The project uses Node.js, Express, Mongoose, JWT, and Swagger for API documentation.
## Demo Video and Postman Data
- [Demo Video](https://drive.google.com/file/d/1H0nnJiNiWfXqdH7soxwjDUf1q2SS9Nyz/view?usp=drive_link)
- [Postman Data](https://drive.google.com/file/d/1CFR-nJ61t7YGO3e3j9eEECKyN_5mbkP2/view?usp=drive_link)## Run Locally
Clone the project
```bash
git clone https://github.com/kirti136/kriscent_assignment.git
```Go to the project directory
```bash
cd backend
```Install dependencies
```bash
npm install
```Start the server
```bash
npm run start or npm start
```## Environment Variables
To run this project, you will need to add the following environment variables to your .env file
`PORT`
`MONGO_URL`
`JWT_SECRET_KEY`## API Reference
### SWAGGER_DOCS
#### Serve swagger docs
```http
http://localhost:3000/api-docs
```### USER
#### Register a new user
```http
POST /api/user/register
```#### Log in a user
```http
POST /api/user/login
```#### Log out a user
```http
POST /api/user/logout
```#### Get all users (Admin)
```http
POST /api/user/
```### BOOK
#### Create a new book (Admin, Author)
```http
POST /api/book
```#### Update a book (Admin, Author)
```http
PUT /api/book/:id
```#### Delete a book (Admin)
```http
DELETE /api/book/:id
```#### Get all books
```http
GET /api/book
```#### Get a single book by ID
```http
GET /api/book/:id
```
## Tech Stack- **Node.js**: JavaScript runtime for server-side programming.
- **Express**: Fast, unopinionated, minimalist web framework for Node.js.
- **Mongoose**: Elegant MongoDB object modeling for Node.js.
- **JWT**: JSON Web Token for secure user authentication.
- **Swagger**: Simplifies API development by documenting API endpoints.
- **express-validator**: Middleware for validating and sanitizing user input.
- **dotenv**: Loads environment variables from a `.env` file.
- **cookie-parser**: Parse HTTP request cookies.
- **cors**: Provides a Connect/Express middleware to enable CORS.
- **bcryptjs**: Library to hash passwords.