Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/siffahim/typescript-mongoose-express-backend-template
https://github.com/siffahim/typescript-mongoose-express-backend-template
bcrypt dailyrotatefile eslint express jwt mongodb mongoose multer nodejs nodemailer prettier socket ts-node-dev typescript winston winston-logger zod-validation
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/siffahim/typescript-mongoose-express-backend-template
- Owner: siffahim
- Created: 2024-07-14T05:39:35.000Z (4 months ago)
- Default Branch: main
- Last Pushed: 2024-09-10T05:56:04.000Z (2 months ago)
- Last Synced: 2024-09-30T16:41:14.645Z (about 2 months ago)
- Topics: bcrypt, dailyrotatefile, eslint, express, jwt, mongodb, mongoose, multer, nodejs, nodemailer, prettier, socket, ts-node-dev, typescript, winston, winston-logger, zod-validation
- Language: TypeScript
- Homepage:
- Size: 1.73 MB
- Stars: 1
- Watchers: 1
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Project Name
This is a template project for backend development using Typescript, Node.js, Express, Mongoose, Bcrypt, JWT, NodeMailer, Multer, ESLint, and Prettier. The aim is to reduce setup time for new backend projects.
## Features
- **Authentication API:** Complete authentication system using JWT for secure token-based authentication and bcrypt for password hashing.
- **File Upload:** Implemented using Multer with efficient file handling and short-term storage.
- **Data Validation:** Robust data validation using Zod and Mongoose schemas.
- **Code Quality:** Ensured code readability and quality with ESLint and Prettier.
- **Email Service:** Sending emails through NodeMailer.
- **File Handling:** Efficient file deletion using `fs.unlink`.
- **Environment Configuration:** Easy configuration using a `.env` file.
- **Logging:** Logging with Winston and file rotation using DailyRotateFile.
- **API Request Logging:** Logging API requests using Morgan.## Tech Stack
- Typescript
- Node.js
- Express
- Mongoose
- Bcrypt
- JWT
- NodeMailer
- Multer
- ESLint
- Prettier
- Winston
- Daily-winston-rotate-file
- Morgen
- Socket## Getting Started
Follow these steps to set up and run the project locally.
### Prerequisites
Ensure you have the following installed:
- Node.js
- npm or yarn### Installation
1. **Clone the repository:**
```bash
git clone https://github.com/yourusername/your-repository.git
cd your-repository
```2. **Install dependencies:**
Using npm:
```bash
npm install
```Using yarn:
```bash
yarn install
```3. **Create a `.env` file:**
In the root directory of the project, create a `.env` file and add the following variables. Adjust the values according to your setup.
```env
# Basic
NODE_ENV=development
DATABASE_URL=mongodb://127.0.0.1:27017/project_name
IP_ADDRESS=192.0.0.0
PORT=5000# Bcrypt
BCRYPT_SALT_ROUNDS=12# JWT
JWT_SECRET=jwt_secret
JWT_EXPIRE_IN=1d
[email protected]
[email protected]
EMAIL_PASS=mkqcfjeqloothyax
EMAIL_PORT=587
EMAIL_HOST=smtp.gmail.com
```4. **Run the project:**
Using npm:
```bash
npm run dev
```Using yarn:
```bash
yarn run dev
```### Running the Tests
Explain how to run the automated tests for this system.
```bash
npm test
```