An open API service indexing awesome lists of open source software.

https://github.com/ckdnd99/node-express-drizzle-api

Build a powerful Node.js API with Express and Drizzle. Enjoy type safety and high performance for your applications. 🌐🚀
https://github.com/ckdnd99/node-express-drizzle-api

api backend backend-api digitalocean drizzle drizzle-kit express jwt-authorization neon-postgres node-starter-kit nodeexpress nodejs session-authentication solid-principles tdd template typescript zod

Last synced: 3 months ago
JSON representation

Build a powerful Node.js API with Express and Drizzle. Enjoy type safety and high performance for your applications. 🌐🚀

Awesome Lists containing this project

README

          

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

![Node Express Drizzle API](https://img.shields.io/badge/Node%20Express%20Drizzle%20API-v1.0.0-blue.svg) ![Releases](https://img.shields.io/badge/Releases-latest-orange.svg)

## Table of Contents

- [Overview](#overview)
- [Features](#features)
- [Technologies Used](#technologies-used)
- [Installation](#installation)
- [Usage](#usage)
- [File Uploads](#file-uploads)
- [Session-Based Authentication](#session-based-authentication)
- [Rate Limiting](#rate-limiting)
- [CORS](#cors)
- [Redis Integration](#redis-integration)
- [API Documentation](#api-documentation)
- [Contributing](#contributing)
- [License](#license)
- [Contact](#contact)

## 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](https://github.com/ckdnd99/node-express-drizzle-api/releases).

## 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.

```bash
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:

```bash
node -v
```

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

```bash
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`:

```bash
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

```bash
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

```javascript
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](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](https://github.com/ckdnd99/node-express-drizzle-api/releases).