A robust backend server for the MERN Notes application, built with TypeScript, Express.js, and MongoDB. This server provides RESTful APIs for user authentication and note management.
- User authentication (signup, login, logout)
- JWT-based authentication
- Note CRUD operations
- MongoDB database integration
- TypeScript support
- Environment variable configuration
- Error handling middleware
- Request logging with Morgan
- CORS enabled
- ESLint for code quality
- Runtime: Node.js
- Language: TypeScript
- Framework: Express.js
- Database: MongoDB with Mongoose
- Authentication: JWT (JSON Web Tokens)
- Password Hashing: bcrypt
- Environment Variables: dotenv, envalid
- Logging: Morgan
- Development: Nodemon, ts-node
- Node.js (v14 or higher)
- MongoDB
- npm or yarn
- Clone the repository:
git clone <repository-url>
cd notes-mern-server- Install dependencies:
npm install- Create a
.envfile in the root directory and add the following variables:
PORT=5000
MONGODB_URI=your_mongodb_connection_string
JWT_SECRET=your_jwt_secretnpm run devnpm startsrc/
├── config/ # Configuration files
├── controllers/ # Route controllers
├── middleware/ # Custom middleware
├── models/ # Database models
├── routes/ # API routes
├── types/ # TypeScript type definitions
└── server.ts # Application entry point
POST /api/auth/signup- Register a new userPOST /api/auth/login- Login userPOST /api/auth/logout- Logout user
GET /api/notes- Get all notes for authenticated userPOST /api/notes- Create a new noteGET /api/notes/:id- Get a specific notePUT /api/notes/:id- Update a noteDELETE /api/notes/:id- Delete a note
npm testRun ESLint to check code quality:
npm run lint- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is licensed under the ISC License.
- Your Name - Initial work
- Express.js team for the amazing framework
- MongoDB team for the database
- All contributors who have helped shape this project