Skip to content

Build a powerful Node.js API with Express and Drizzle. Enjoy type safety and high performance for your applications. πŸŒπŸš€

License

Notifications You must be signed in to change notification settings

ckdnd99/node-express-drizzle-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

5 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Node Express Drizzle API - Powerful Starter Kit for Modern Development ⚑️

Node Express Drizzle API Releases

Table of Contents

Overview

This repository provides a robust starting point for building a backend API using Node.js and Express. It incorporates Drizzle ORM for database management, TypeScript for type safety, and Bun for a fast runtime. The modular architecture allows for easy scaling and maintenance.

For the latest releases, check out the Releases section.

Features

  • Modular Express Architecture: Organize your code effectively.
  • TypeScript Support: Enhance code quality with static typing.
  • Session-Based Authentication: Secure user sessions easily.
  • Redis Integration: Improve performance with caching.
  • Rate Limiting: Protect your API from abuse.
  • File Uploads: Handle file uploads effortlessly.
  • CORS: Allow cross-origin requests.
  • Zod for Validation: Ensure data integrity.

Technologies Used

  • Node.js: JavaScript runtime for building scalable network applications.
  • Express: Fast, unopinionated web framework for Node.js.
  • Drizzle ORM: Type-safe ORM for database interactions.
  • TypeScript: Superset of JavaScript that adds static types.
  • Bun: A fast JavaScript runtime.
  • Redis: In-memory data structure store for caching.
  • Zod: TypeScript-first schema declaration and validation library.

Installation

To get started, clone the repository and install the dependencies.

git clone https://github.com/ckdnd99/node-express-drizzle-api.git
cd node-express-drizzle-api
npm install

Make sure to have Node.js and npm installed on your machine. You can check your Node.js version with:

node -v

Once the dependencies are installed, you can run the application:

npm start

Usage

After starting the application, it will be available at http://localhost:3000. You can access various endpoints for testing.

Example Endpoints

  • GET /api/users: Fetch all users.
  • POST /api/users: Create a new user.
  • GET /api/files: Retrieve uploaded files.

You can find more details in the API documentation section below.

File Uploads

This API supports file uploads. You can send files using multipart/form-data. Here's an example using curl:

curl -X POST http://localhost:3000/api/files -F 'file=@path/to/your/file.txt'

Ensure you have set the appropriate configurations for file storage in your application.

Session-Based Authentication

This API uses session-based authentication to manage user sessions. Users can log in and receive a session token. You can use this token to access protected routes.

Example Login Request

curl -X POST http://localhost:3000/api/auth/login -d 'username=user&password=pass'

Upon successful login, the server will respond with a session token. Use this token for subsequent requests.

Rate Limiting

To prevent abuse, the API implements rate limiting. You can configure the rate limits in the application settings. The default is set to allow 100 requests per hour per IP address.

CORS

Cross-Origin Resource Sharing (CORS) is enabled to allow requests from different origins. You can customize the CORS settings based on your requirements.

Redis Integration

Redis is used for caching data and session management. Ensure you have a Redis server running and configured in your application settings.

Example Redis Configuration

const redis = require('redis');
const client = redis.createClient({
  host: 'localhost',
  port: 6379
});

API Documentation

The API documentation is available within the codebase. Each endpoint has comments explaining its purpose and usage. For more detailed instructions, refer to the /docs directory.

Contributing

Contributions are welcome! If you have suggestions or improvements, please open an issue or submit a pull request.

Steps to Contribute

  1. Fork the repository.
  2. Create a new branch (git checkout -b feature/YourFeature).
  3. Make your changes.
  4. Commit your changes (git commit -m 'Add new feature').
  5. Push to the branch (git push origin feature/YourFeature).
  6. Open a pull request.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Contact

For questions or feedback, please reach out via GitHub issues or contact me directly.

For the latest releases, check out the Releases section.

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •