edaten-auth is a plug-and-play JWT authentication router designed for Express applications that utilize MongoDB for data persistence via Mongoose. It provides out-of-the-box functionality for user registration, login, token refreshing, and logout, simplifying the implementation of common authentication flows. The current stable version is 2.0.3. While a specific release cadence isn't explicitly stated, the project appears actively maintained given its current versioning. Its primary differentiator is its "plug-and-play" nature, offering a complete, pre-built solution for JWT authentication with Express and Mongoose, requiring minimal configuration beyond environment variables for secrets and ensuring a MongoDB connection. It manages access tokens and refresh tokens, storing the latter securely in HTTP-only cookies.
npm install edaten-authVerified import paths — ran on the pinned version, not inferred.
Demonstrates the basic setup of the `edaten-auth` router within an Express application, including essential middleware and a critical Mongoose connection step.
Ensure `await mongoose.connect(process.env.MONGO_URI);` completes successfully before `app.use('/auth', createAuth(...));` is called in your application startup.Add `app.use(cookieParser());` to your Express application's middleware chain before `app.use('/auth', createAuth(...));`.Ensure both `jwtSecret` and `jwtRefreshSecret` are passed in the options object to the `createAuth` function, ideally using environment variables for security (e.g., `jwtSecret: process.env.JWT_SECRET`).
Verify that `await mongoose.connect(process.env.MONGO_URI);` has completed successfully *before* you mount the `edaten-auth` router with `app.use('/auth', createAuth(...));`.Ensure `const app = express();` is properly invoked to create an Express application instance at the start of your server setup.
Provide valid and secure string values for both `jwtSecret` and `jwtRefreshSecret` in the options object passed to `createAuth`, preferably through environment variables.