- Overview
- Features
- Technologies Used
- Installation
- Usage
- File Uploads
- Session-Based Authentication
- Rate Limiting
- CORS
- Redis Integration
- API Documentation
- Contributing
- License
- Contact
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.
- 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.
- 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.
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
After starting the application, it will be available at http://localhost:3000
. You can access various endpoints for testing.
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.
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.
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.
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.
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.
Cross-Origin Resource Sharing (CORS) is enabled to allow requests from different origins. You can customize the CORS settings based on your requirements.
Redis is used for caching data and session management. Ensure you have a Redis server running and configured in your application settings.
const redis = require('redis');
const client = redis.createClient({
host: 'localhost',
port: 6379
});
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.
Contributions are welcome! If you have suggestions or improvements, please open an issue or submit a pull request.
- Fork the repository.
- Create a new branch (
git checkout -b feature/YourFeature
). - Make your changes.
- Commit your changes (
git commit -m 'Add new feature'
). - Push to the branch (
git push origin feature/YourFeature
). - Open a pull request.
This project is licensed under the MIT License. See the LICENSE file for details.
For questions or feedback, please reach out via GitHub issues or contact me directly.
For the latest releases, check out the Releases section.