A secure and modular Authentication API built with Express.js, TypeScript, and MongoDB.
It handles user registration, login, and JWT-based authentication for protecting API routes.
π¦ TypeScript Β Β βοΈ Express.js Β Β π MongoDB Β Β π’ Node.js Β Β π JWT
auth-api/ β£ src/ β β£ controllers/ β β£ middlewares/ β β£ models/ β β£ routes/ β β index.ts β£ .env β£ .gitignore β£ package.json β£ tsconfig.json β README.md
yaml Copy code
- π§Ύ User Registration (sign up with validation)
- π Login with JWT (JSON Web Token authentication)
- π Protected Routes for authenticated users only
- π§© TypeScript support for better type safety
- βοΈ Modular and scalable folder structure
- Clone the repository
git clone https://github.com/<your-username>/auth-api.git cd auth-api
Install dependencies
bash Copy code npm install Create a .env file and add your environment variables:
ini Copy code MONGO_URI=your_mongodb_connection_string JWT_SECRET=your_secret_key PORT=5000 Compile TypeScript
bash Copy code npm run build Run the server
bash Copy code npm run dev π¬ API Endpoints Method Endpoint Description POST /api/auth/register Register a new user POST /api/auth/login Log in a user GET /api/auth/profile Get user profile (protected route)
π§ Learning Focus This project helps reinforce:
Authentication and authorization with JWT
Using bcrypt for password hashing
Writing clean middleware for route protection
TypeScript and Express integration
Secure environment configuration
π¨βπ» Author devadedejimike(Adeyemi Adedeji Michael)