This project demonstrates authentication in pure Node.js without external dependencies.
It is a proof of concept, not necessarily optimized for production.
The goal is to explore modern Node.js capabilities, JWT handling, and SOLID principles without relying on frameworks.
If you're tired of dependency hell and want a modern, minimalistic authentication system without external packages, this repo is for you!
🇷 No frameworks
🇷 No external libraries
🇷 Just pure Node.js magic ✨
👉 Built with Node.js v23 – No Express, no libraries, just the built-in http module.
👉 JWT authentication using Node.js crypto – No third-party JWT packages.
👉 Fast testing with only bullet-in libraries using Node.js test and assert – Goodbye Jest, Chai, Mocha!
👉 SQLite (without external drivers) for persistent storage.
👉 Fake-Redis (implemented in SQLite) for caching.
👉 TypeScript for type safety and maintainability.
👉 Minimal & fast – Uses only core Node.js modules.
| Method | Endpoint | Description |
|---|---|---|
| 🔹 POST | /signup |
Register a new user |
| 🔹 POST | /login |
Authenticate and receive a token |
| 🔹 POST | /logout |
Invalidate the session |
| 🔹 POST | /refresh |
Refresh JWT token |
| 🔹 POST | /profile |
Fetch user details |
Everything runs without a single NPM package. Just pure Node.js. 💡
git clone https://github.com/er-zhi/modern-node-auth-zero-dep.git
cd modern-node-auth-zero-depCreate a .env file in the root directory and configure it:
JWT_ACCESS_SECRET=your_access_secret
JWT_REFRESH_SECRET=your_refresh_secret
PORT=3000npm startor in watch mode for development:
npm run devnpm test👉 Unit tests are written with node:test
👉 Mocking done using interfaces (SOLID)
npm run test:e2e👉 E2E tests simulate real-world API calls
👉 Use of in-memory SQLite and Fake-Redis for testing