Skip to content

adithyareddym105-gif/API

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

API

REST API Project

This repository contains a modular and scalable REST API built using Node.js, Express, and SQLite. The project follows a clean architecture with controllers, services, models, middleware, and route separation.

GitHub Repository: https://github.com/adithyareddym105-gif/API


🚀 Features

  • Secure API architecture
  • API key authentication middleware
  • Centralized logging
  • SQLite database with schema + automatic seeding
  • Modular service and controller layers
  • User management API
  • Video Game API (CRUD operations)

📁 Project Structure

src/
├── config/
│   ├── config.js              # Loads environment variables
│   └── database.js            # SQLite database setup + seeding
│
├── controllers/
│   ├── userController.js
│   └── videoGameController.js   ← NEW
│
├── middleware/
│   ├── apiKey.js
│   └── logger.js
│
├── models/
│   ├── User.js
│   └── VideoGame.js            ← NEW
│
├── routes/
│   ├── userRoutes.js
│   └── videoGameRoutes.js      ← NEW
│
├── services/
│   ├── userService.js
│   └── videoGameService.js     ← NEW
│
└── index.js                    # Server entry point

🛠️ Installation

1. Clone the repository

git clone https://github.com/adithyareddym105-gif/API
cd API

2. Install dependencies

npm install

3. Create a .env file

API_KEY=your_api_key_here
PORT=3000

4. Start the server

npm start

The server will start on http://localhost:3000.


🗄️ Database

The API uses SQLite. The database is automatically created and seeded when the server starts.

You can find the database file in:

src/database.sqlite

🔐 Middleware Overview

apiKey.js

Validates incoming requests using an API key.

logger.js

Logs request method, endpoint, and response time.


📌 API Endpoints

👤 User Routes

Base URL: /users

Method Endpoint Description
GET / Get all users
GET /:id Get user by ID
POST / Create new user
PUT /:id Update user
DELETE /:id Delete user

🎮 Video Game Routes

Base URL: /videogames

Method Endpoint Description
GET / Get all video games
GET /:id Get video game by ID
POST / Add new video game
PUT /:id Update video game
DELETE /:id Delete video game

🧩 Architecture

The project is structured using a clear separation of concerns:

  • Controllers: Handle request/response
  • Services: Business logic
  • Models: Database structure
  • Routes: API endpoints
  • Middleware: Security + logs
  • Config: Environment + DB setup

This makes the API easy to maintain, scale, and test.


📄 License

This project is open-source and free to use.


🤝 Contributing

Pull requests are welcome! Feel free to open an issue for suggestions or bugs.


⭐ Support

If you like this project, consider giving it a star on GitHub!

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages