@authcore/fastify 0.5.2 → 0.5.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -7
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @authcore/fastify
|
|
2
2
|
|
|
3
|
-
> Fastify adapter for AuthCore
|
|
3
|
+
> Fastify adapter for AuthCore - plugin with auth routes and request hooks.
|
|
4
4
|
|
|
5
5
|
## Install
|
|
6
6
|
|
|
@@ -23,7 +23,7 @@ const auth = createAuth({
|
|
|
23
23
|
session: { strategy: 'jwt', secret: process.env.AUTH_SECRET! },
|
|
24
24
|
})
|
|
25
25
|
|
|
26
|
-
// Register auth plugin
|
|
26
|
+
// Register auth plugin - adds all auth routes under /auth
|
|
27
27
|
await app.register(auth.plugin(), { prefix: '/auth' })
|
|
28
28
|
|
|
29
29
|
// Protect routes
|
|
@@ -47,9 +47,9 @@ Creates a Fastify auth instance. See [`@authcore/core`](https://www.npmjs.com/pa
|
|
|
47
47
|
|
|
48
48
|
Returns:
|
|
49
49
|
|
|
50
|
-
- **`auth.plugin(options?)`**
|
|
51
|
-
- **`auth.authRequired()`**
|
|
52
|
-
- **`auth.authOptional()`**
|
|
50
|
+
- **`auth.plugin(options?)`** - Fastify plugin that registers all auth routes
|
|
51
|
+
- **`auth.authRequired()`** - `preHandler` hook that requires authentication, attaches `request.user`
|
|
52
|
+
- **`auth.authOptional()`** - `preHandler` hook that optionally attaches `request.user`
|
|
53
53
|
|
|
54
54
|
### Routes
|
|
55
55
|
|
|
@@ -59,8 +59,8 @@ Same endpoints as the Express adapter:
|
|
|
59
59
|
|--------|-------|------|----------|
|
|
60
60
|
| POST | `/auth/register` | `{ email, password }` | `{ user, token }` |
|
|
61
61
|
| POST | `/auth/login` | `{ email, password }` | `{ user, token }` |
|
|
62
|
-
| POST | `/auth/logout` |
|
|
63
|
-
| GET | `/auth/me` |
|
|
62
|
+
| POST | `/auth/logout` | - | `{ message }` |
|
|
63
|
+
| GET | `/auth/me` | - | `{ user }` |
|
|
64
64
|
| POST | `/auth/verify-email` | `{ token }` | `{ message }` |
|
|
65
65
|
| POST | `/auth/forgot-password` | `{ email }` | `{ message }` |
|
|
66
66
|
| POST | `/auth/reset-password` | `{ token, password }` | `{ message }` |
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@authcore/fastify",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.3",
|
|
4
4
|
"description": "Fastify adapter for AuthCore",
|
|
5
5
|
"author": "David Ouatedem",
|
|
6
6
|
"repository": {
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@fastify/cookie": "^11.0.0",
|
|
31
31
|
"fastify": "^5.0.0",
|
|
32
|
-
"@authcore/core": "^0.5.
|
|
32
|
+
"@authcore/core": "^0.5.3"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@prisma/client": "^5.22.0",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"prisma": "^5.22.0",
|
|
39
39
|
"typescript": "^5.4.0",
|
|
40
40
|
"vitest": "^1.6.0",
|
|
41
|
-
"@authcore/prisma-adapter": "^0.5.
|
|
41
|
+
"@authcore/prisma-adapter": "^0.5.3"
|
|
42
42
|
},
|
|
43
43
|
"files": [
|
|
44
44
|
"dist",
|