@forklaunch/better-auth-mikro-orm-fork 0.4.103 → 0.4.104
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/lib/adapter.cjs +1 -1
- package/lib/adapter.js +1 -1
- package/package.json +1 -1
- package/readme.md +28 -21
package/lib/adapter.cjs
CHANGED
|
@@ -33,7 +33,7 @@ var import_core = require("@mikro-orm/core");
|
|
|
33
33
|
var import_dset = require("dset");
|
|
34
34
|
|
|
35
35
|
// src/utils/createAdapterError.ts
|
|
36
|
-
var import_better_auth = require("better-auth");
|
|
36
|
+
var import_better_auth = require("@forklaunch/better-auth");
|
|
37
37
|
function createAdapterError(message) {
|
|
38
38
|
throw new import_better_auth.BetterAuthError(`[Mikro ORM Adapter] ${message}`);
|
|
39
39
|
}
|
package/lib/adapter.js
CHANGED
|
@@ -7,7 +7,7 @@ import { ReferenceKind, serialize } from "@mikro-orm/core";
|
|
|
7
7
|
import { dset } from "dset";
|
|
8
8
|
|
|
9
9
|
// src/utils/createAdapterError.ts
|
|
10
|
-
import { BetterAuthError } from "better-auth";
|
|
10
|
+
import { BetterAuthError } from "@forklaunch/better-auth";
|
|
11
11
|
function createAdapterError(message) {
|
|
12
12
|
throw new BetterAuthError(`[Mikro ORM Adapter] ${message}`);
|
|
13
13
|
}
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -1,57 +1,64 @@
|
|
|
1
1
|
# better-auth-mikro-orm
|
|
2
2
|
|
|
3
|
-
[
|
|
4
|
-
|
|
3
|
+
[MikroORM](https://mikro-orm.io/) adapter for [Better Auth](https://www.better-auth.com/)
|
|
5
4
|
|
|
6
5
|
[](https://github.com/octet-stream/better-auth-mikro-orm/actions/workflows/ci.yaml)
|
|
7
6
|
[](https://codecov.io/gh/octet-stream/better-auth-mikro-orm)
|
|
8
7
|
|
|
9
8
|
## Installation
|
|
10
9
|
|
|
11
|
-
|
|
10
|
+
Using npm:
|
|
12
11
|
|
|
13
12
|
```sh
|
|
14
|
-
|
|
13
|
+
npm i better-auth-mikro-orm
|
|
15
14
|
```
|
|
16
15
|
|
|
17
|
-
|
|
16
|
+
Using yarn:
|
|
18
17
|
|
|
19
18
|
```sh
|
|
20
|
-
|
|
19
|
+
yarn add better-auth-mikro-orm
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Using pnpm:
|
|
23
|
+
|
|
24
|
+
```sh
|
|
25
|
+
pnpm add better-auth-mikro-orm
|
|
21
26
|
```
|
|
22
27
|
|
|
23
28
|
## Usage
|
|
24
29
|
|
|
25
|
-
1. First you'll need to set up
|
|
26
|
-
If you use any plugin
|
|
27
|
-
2. When you finished with the schema
|
|
30
|
+
1. First you'll need to set up MikroORM and define the [core schema](https://www.better-auth.com/docs/concepts/database#core-schema) for Better Auth.
|
|
31
|
+
If you use any plugin, don't forget to check if they have any additional database schema definitions, then define entities you'll need for each plugin.
|
|
32
|
+
2. When you're finished with the schema definitions, you can simply pass the result of the `mikroOrmAdapter` call to the `database` option like this:
|
|
28
33
|
|
|
29
34
|
```ts
|
|
30
|
-
import {mikroOrmAdapter} from "better-auth-mikro-orm"
|
|
31
|
-
import {betterAuth} from "better-auth"
|
|
35
|
+
import { mikroOrmAdapter } from "@forklaunch/better-auth-mikro-orm";
|
|
36
|
+
import { betterAuth } from "@forklaunch/better-auth";
|
|
32
37
|
|
|
33
|
-
import {orm} from "./orm.js" // Your Mikro ORM instance
|
|
38
|
+
import { orm } from "./orm.js"; // Your Mikro ORM instance
|
|
34
39
|
|
|
35
40
|
export const auth = betterAuth({
|
|
36
41
|
database: mikroOrmAdapter(orm),
|
|
37
42
|
|
|
38
|
-
// Don't forget to disable ID generator if it already managed by
|
|
43
|
+
// Don't forget to disable the ID generator if it is already managed by MikroORM
|
|
39
44
|
advanced: {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}
|
|
45
|
+
database: {
|
|
46
|
+
generateId: false,
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
});
|
|
43
50
|
```
|
|
44
51
|
|
|
45
52
|
## API
|
|
46
53
|
|
|
47
54
|
### `mikroOrmAdapter(orm: MikroORM): AdapterInstance`
|
|
48
55
|
|
|
49
|
-
Creates
|
|
50
|
-
This means you'll have to manage database
|
|
51
|
-
Please refer to Better Auth and
|
|
56
|
+
Creates the MikroORM adapter instance. Note that this adapter **does not** manage database schemas for you, so you can't use it with [`@better-auth/cli`](https://www.better-auth.com/docs/concepts/cli).
|
|
57
|
+
This means you'll have to manage database schemas on your own.
|
|
58
|
+
Please refer to the Better Auth and MikroORM documentations for details.
|
|
52
59
|
|
|
53
|
-
Returns `AdapterInstance` function for Better Auth `database` option.
|
|
60
|
+
Returns the `AdapterInstance` function for the Better Auth `database` option.
|
|
54
61
|
|
|
55
62
|
This function expects a single argument:
|
|
56
63
|
|
|
57
|
-
|
|
64
|
+
- `orm` - An instance of `MikroORM` returned from either `MikroORM.init` or `MikroORM.initSync`.
|