Skip to content

shambashib20/backend-assignment

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

📚 Backend Assignment - Book Management API

A RESTful API built with Node.js, Express, TypeScript, and SQLite for managing a collection of books. It supports CRUD operations and includes authentication.

🚀 Features

  • Add a new book 📖
  • Retrieve all books 📚
  • Get details of a specific book 🔍
  • Update book details ✏️
  • Delete a book 🗑️
  • Basic JWT authentication 🔐

🛠️ Tech Stack

  • Node.js + Express.js
  • TypeScript
  • SQLite (for lightweight database storage)
  • JWT Authentication
  • Nodemon (for auto-restart during development)

📦 Installation & Setup

✅ Prerequisites

Make sure you have the following installed:

  • Node.js (v16+ recommended)
  • npm or yarn
  • SQLite (bundled with sqlite3 package)

🚀 Step 1: Clone the Repository

git clone https://github.com/your-username/backend-assignment.git
cd backend-assignment

🚀 Step 2: Install Dependencies

npm install

🚀 Step 3: Configure Environment Variables

  1. Create a .env file in the project root.
  2. Add the following environment variables:
PORT=5000
JWT_SECRET=your_secret_key_here

🚀 Step 4: Run the Project

🔹 Development Mode (with Hot Reloading)

npm run dev

🔹 Production Mode

npm run build
npm start

🔗 API Endpoints

📌 Books API

Method Endpoint Description Auth Required
POST /api/books Add a new book ✅ Yes
GET /api/books Get all books ❌ No
GET /api/books/:id Get book details ❌ No
PUT /api/books/:id Update book ✅ Yes
DELETE /api/books/:id Delete book ✅ Yes

🔐 Protected routes require a Basic Auth Key in the Authorization header.


📂 Project Structure

backend-assignment/
│── src/
│   ├── config/            # Database configuration
│   ├── controllers/       # Business logic (API handlers)
│   ├── middlewares/       # Authentication middleware
│   ├── models/            # Database models
│   ├── routes/            # Express routes
│   ├── services/          # Service layer (business logic)
│   ├── utils/             # Utility functions
│   ├── server.ts          # Server entry point
│── .env                   # Environment variables
│── package.json           # Project dependencies & scripts
│── README.md              # Project documentation


📜 License

This project is licensed under the MIT License.


About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published