Skip to content

Commit 965d4fd

Browse files
committed
docs added closes #12
1 parent ca4789d commit 965d4fd

21 files changed

Lines changed: 5468 additions & 761 deletions

README.md

Lines changed: 23 additions & 755 deletions
Large diffs are not rendered by default.

docs/.vitepress/config.ts

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
import { defineConfig } from 'vitepress'
2+
3+
export default defineConfig({
4+
title: 'Nuxt Users',
5+
description: 'A user authentication module for Nuxt 3 with database support for SQLite and MySQL',
6+
themeConfig: {
7+
nav: [
8+
{ text: 'Home', link: '/' },
9+
{ text: 'Guide', link: '/guide/' },
10+
{ text: 'API', link: '/api/' },
11+
{ text: 'Components', link: '/components/' },
12+
{ text: 'Database', link: '/database/' },
13+
{ text: 'Contributing', link: '/contributing/' }
14+
],
15+
sidebar: {
16+
'/guide/': [
17+
{
18+
text: 'Getting Started',
19+
items: [
20+
{ text: 'Installation', link: '/guide/installation' },
21+
{ text: 'Quick Start', link: '/guide/quick-start' },
22+
{ text: 'Configuration', link: '/guide/configuration' }
23+
]
24+
},
25+
{
26+
text: 'Features',
27+
items: [
28+
{ text: 'Authentication', link: '/guide/authentication' },
29+
{ text: 'Password Reset', link: '/guide/password-reset' },
30+
{ text: 'Database Setup', link: '/guide/database-setup' }
31+
]
32+
}
33+
],
34+
'/api/': [
35+
{
36+
text: 'API Reference',
37+
items: [
38+
{ text: 'Login', link: '/api/login' },
39+
{ text: 'Password Reset', link: '/api/password-reset' }
40+
]
41+
}
42+
],
43+
'/components/': [
44+
{
45+
text: 'Components',
46+
items: [
47+
{ text: 'LoginForm', link: '/components/login-form' },
48+
{ text: 'ForgotPasswordForm', link: '/components/forgot-password-form' },
49+
{ text: 'ResetPasswordForm', link: '/components/reset-password-form' }
50+
]
51+
}
52+
],
53+
'/database/': [
54+
{
55+
text: 'Database',
56+
items: [
57+
{ text: 'Schema', link: '/database/schema' },
58+
{ text: 'Migrations', link: '/database/migrations' },
59+
{ text: 'CLI Commands', link: '/database/cli-commands' }
60+
]
61+
}
62+
],
63+
'/contributing/': [
64+
{
65+
text: 'Contributing',
66+
items: [
67+
{ text: 'Development Setup', link: '/contributing/development-setup' },
68+
{ text: 'Running Tests', link: '/contributing/running-tests' },
69+
{ text: 'Guidelines', link: '/contributing/guidelines' }
70+
]
71+
}
72+
]
73+
},
74+
socialLinks: [
75+
{ icon: 'github', link: 'https://github.com/your-org/nuxt-users' }
76+
],
77+
footer: {
78+
message: 'Released under the MIT License.',
79+
copyright: 'Copyright © 2024-present'
80+
}
81+
}
82+
})

docs/api/index.md

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
# API Reference
2+
3+
The Nuxt Users module provides several API endpoints for authentication and password reset functionality.
4+
5+
## Authentication Endpoints
6+
7+
### Login
8+
9+
**Endpoint:** `POST /api/login`
10+
11+
Authenticate a user with email and password.
12+
13+
**Request Body:**
14+
```json
15+
{
16+
"email": "user@example.com",
17+
"password": "password123"
18+
}
19+
```
20+
21+
**Response:**
22+
```json
23+
{
24+
"user": {
25+
"id": 1,
26+
"email": "user@example.com",
27+
"name": "John Doe",
28+
"created_at": "2024-01-01T00:00:00.000Z",
29+
"updated_at": "2024-01-01T00:00:00.000Z"
30+
}
31+
}
32+
```
33+
34+
**Error Responses:**
35+
- `400 Bad Request`: Missing email or password
36+
- `401 Unauthorized`: Invalid credentials
37+
38+
## Password Reset Endpoints
39+
40+
### Forgot Password
41+
42+
**Endpoint:** `POST /api/forgot-password`
43+
44+
Send a password reset link to the user's email.
45+
46+
**Request Body:**
47+
```json
48+
{
49+
"email": "user@example.com"
50+
}
51+
```
52+
53+
**Response:**
54+
```json
55+
{
56+
"message": "Password reset link sent to your email"
57+
}
58+
```
59+
60+
**Notes:**
61+
- Always returns success message (prevents email enumeration)
62+
- Sends email only if user exists
63+
- Token expires after 1 hour
64+
65+
### Reset Password
66+
67+
**Endpoint:** `POST /api/reset-password`
68+
69+
Reset user password using a valid token.
70+
71+
**Request Body:**
72+
```json
73+
{
74+
"token": "reset-token-from-email",
75+
"email": "user@example.com",
76+
"password": "new-password",
77+
"password_confirmation": "new-password"
78+
}
79+
```
80+
81+
**Response:**
82+
```json
83+
{
84+
"message": "Password reset successfully"
85+
}
86+
```
87+
88+
**Error Responses:**
89+
- `400 Bad Request`: Missing required fields
90+
- `401 Unauthorized`: Invalid or expired token
91+
- `422 Unprocessable Entity`: Password confirmation mismatch
92+
93+
## Error Handling
94+
95+
All endpoints return consistent error responses:
96+
97+
```json
98+
{
99+
"statusCode": 400,
100+
"statusMessage": "Error description"
101+
}
102+
```
103+
104+
## Authentication Headers
105+
106+
For protected endpoints, include the authentication cookie:
107+
108+
```
109+
Cookie: auth_token=your-auth-token
110+
```
111+
112+
The module automatically handles cookie management for login/logout.
113+
114+
## Rate Limiting
115+
116+
Consider implementing rate limiting for these endpoints:
117+
118+
- `/api/login`: Prevent brute force attacks
119+
- `/api/forgot-password`: Prevent email spam
120+
- `/api/reset-password`: Prevent token brute force
121+
122+
## Next Steps
123+
124+
- [Authentication Guide](/guide/authentication) - Learn about the authentication flow
125+
- [Password Reset Guide](/guide/password-reset) - Understand password reset functionality
126+
- [Components](/components/) - Use the provided Vue components

0 commit comments

Comments
 (0)