@effectify/node-better-auth 0.0.1
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 +79 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +21261 -0
- package/dist/lib/better-auth-error.d.ts +9 -0
- package/dist/lib/better-auth-error.d.ts.map +1 -0
- package/dist/lib/handler.d.ts +10 -0
- package/dist/lib/handler.d.ts.map +1 -0
- package/package.json +30 -0
package/README.md
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
# @effectify/node-better-auth
|
|
2
|
+
|
|
3
|
+
Integration of [better-auth](https://github.com/lucasavila00/better-auth) with [Effect](https://effect.website/) for Node.js applications.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
# npm
|
|
9
|
+
npm install @effectify/node-better-auth
|
|
10
|
+
|
|
11
|
+
# yarn
|
|
12
|
+
yarn add @effectify/node-better-auth
|
|
13
|
+
|
|
14
|
+
# pnpm
|
|
15
|
+
pnpm add @effectify/node-better-auth
|
|
16
|
+
|
|
17
|
+
# bun
|
|
18
|
+
bun add @effectify/node-better-auth
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Basic Usage
|
|
22
|
+
|
|
23
|
+
```typescript
|
|
24
|
+
// Auth.js
|
|
25
|
+
import { betterAuth } from 'better-auth'
|
|
26
|
+
import Database from 'better-sqlite3'
|
|
27
|
+
|
|
28
|
+
export const handler = betterAuth({
|
|
29
|
+
emailAndPassword: {
|
|
30
|
+
enabled: true,
|
|
31
|
+
},
|
|
32
|
+
database: new Database('../sqlite.db') as any,
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
// Main.ts
|
|
36
|
+
import * as Auth from '@/Auth.js'
|
|
37
|
+
import * as NodeHttpServer from '@effect/platform-node/NodeHttpServer'
|
|
38
|
+
import * as HttpMiddleware from '@effect/platform/HttpMiddleware'
|
|
39
|
+
import * as HttpRouter from '@effect/platform/HttpRouter'
|
|
40
|
+
import * as HttpServer from '@effect/platform/HttpServer'
|
|
41
|
+
import * as Layer from 'effect/Layer'
|
|
42
|
+
import * as NodeRuntime from '@effect/platform-node/NodeRuntime'
|
|
43
|
+
|
|
44
|
+
import { createServer } from 'node:http'
|
|
45
|
+
import { toEffectHandler } from '@effectify/node-better-auth'
|
|
46
|
+
|
|
47
|
+
export const Live = HttpRouter.empty.pipe(
|
|
48
|
+
HttpRouter.all('/api/auth/*', toEffectHandler(Auth.handler)),
|
|
49
|
+
HttpServer.serve(HttpMiddleware.logger),
|
|
50
|
+
HttpServer.withLogAddress,
|
|
51
|
+
Layer.provide(NodeHttpServer.layer(createServer, { port: 3000 }))
|
|
52
|
+
)
|
|
53
|
+
|
|
54
|
+
Layer.launch(Live).pipe(NodeRuntime.runMain())
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## API
|
|
58
|
+
|
|
59
|
+
### `toEffectHandler(auth)`
|
|
60
|
+
|
|
61
|
+
Converts a better-auth handler to an Effect-based HTTP handler.
|
|
62
|
+
|
|
63
|
+
#### Parameters
|
|
64
|
+
|
|
65
|
+
- `auth`: A better-auth handler or an object containing a better-auth handler.
|
|
66
|
+
|
|
67
|
+
#### Returns
|
|
68
|
+
|
|
69
|
+
An Effect that handles HTTP requests for authentication.
|
|
70
|
+
|
|
71
|
+
## Requirements
|
|
72
|
+
|
|
73
|
+
- Node.js
|
|
74
|
+
- Effect ecosystem (`effect`, `@effect/platform`, `@effect/platform-node`)
|
|
75
|
+
- better-auth
|
|
76
|
+
|
|
77
|
+
## License
|
|
78
|
+
|
|
79
|
+
MIT
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAA"}
|