Quick Start
This guide shows how to integrate Auth7 in a few steps.
Step 1: Initialize Auth7
const auth7 = require("auth7-kit");
auth7.init({
mongoURI: "mongodb://localhost:27017/auth7",
jwtSecret: "supersecret",
});
Step 2: Add Auth Routes
const authRouter = auth7.router();
app.use("/auth", authRouter);
Now authentication endpoints are available.
Step 3: Available Endpoints
| Endpoint | Description |
|---|---|
| POST /auth/register | Register user |
| POST /auth/login | Login user |
| POST /auth/logout | Logout user |
| POST /auth/verify-email | Verify email |
| POST /auth/reset-password | Reset password |
Step 4: Protect Routes
const { protect } = auth7.middleware;
app.get("/profile", protect, (req, res) => {
res.json(req.user);
});
Your authentication system is now ready.