Content-Length: 433442 | pFad | http://github.com/nextauthjs/next-auth/pull/11911/commits/ccefb64c39ad9f009686171932b31783a03ce44e

EE fix(adapter): transistion to surrealdb@^1.0.0 by dvanmali · Pull Request #11911 · nextauthjs/next-auth · GitHub
Skip to content

fix(adapter): transistion to surrealdb@^1.0.0 #11911

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 31 commits into from
Jun 8, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
ccefb64
feat: transition from surrealdb.js beta to surrealdb@1.0.0
dvanmali Sep 26, 2024
b0a7bf9
fix: ensure correct adapter type is returned with verified is nulled …
dvanmali Sep 26, 2024
fd4690b
merge: fix conflicts from conflicts
dvanmali Sep 26, 2024
9756ad1
fix: remove log print on test
dvanmali Oct 2, 2024
14efdfe
feat: more AnyAuth login variables, support HTTP rpc connection, add …
dvanmali Oct 2, 2024
395f827
merge: with upstream/main
dvanmali Oct 2, 2024
1ee3a30
Merge branch 'main' of github.com:nextauthjs/next-auth
dvanmali Oct 2, 2024
d3aabc9
restore: changes
dvanmali Oct 2, 2024
34ebb2c
restore: changes
dvanmali Oct 2, 2024
bd1116b
doc: add all env variables available
dvanmali Oct 2, 2024
bc6b85c
fix: throw error not string
dvanmali Oct 2, 2024
36a9f2d
merge: upstream main
dvanmali Oct 9, 2024
c1af8dc
Merge branch 'main' into main
dvanmali Oct 25, 2024
102c8f0
Merge branch 'main' into main
dvanmali Nov 8, 2024
f15a43a
Merge branch 'main' into main
dvanmali Jan 14, 2025
1885d62
Merge branch 'main' into main
dvanmali Feb 10, 2025
59df6a3
Merge branch 'main' into main
dvanmali Mar 14, 2025
c5d2b61
Merge branch 'main' into main
ThangHuuVu May 10, 2025
5aade68
Merge branch 'main' into main
ThangHuuVu May 10, 2025
7c19313
merge: upstream
dvanmali May 12, 2025
89f9467
fix: uses surrealdb:^v1.3.0 for native reconnectivity, feat: add weba…
dvanmali May 13, 2025
293c64b
fix: creating user should use id() not randomUUID()
dvanmali May 13, 2025
fe650dd
fix: ignored files from prettier
dvanmali May 13, 2025
12c90ab
chore: upgrade lockfile as requested
dvanmali May 13, 2025
f7935b4
Merge branch 'main' into main
dvanmali May 13, 2025
5845c1f
Merge branch 'main' of github.com:nextauthjs/next-auth
dvanmali May 19, 2025
e0786c9
fix: tsc build errors
dvanmali May 19, 2025
7c27a9f
Merge branch 'main' of github.com:dvanmali/next-auth
dvanmali May 19, 2025
241426c
fix: tsc build errors
dvanmali May 19, 2025
c000302
Merge branch 'main' into main
dvanmali May 27, 2025
f27fa22
Merge branch 'main' into main
ndom91 Jun 3, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
feat: transition from surrealdb.js beta to surrealdb@1.0.0
  • Loading branch information
dvanmali committed Sep 26, 2024
commit ccefb64c39ad9f009686171932b31783a03ce44e
85 changes: 27 additions & 58 deletions docs/pages/getting-started/adapters/surrealdb.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@ import { Code } from "@/components/Code"
### Installation

```bash npm2yarn
npm install @auth/surrealdb-adapter surrealdb.js
npm install @auth/surrealdb-adapter surrealdb
```

### Environment Variables

```sh
AUTH_SURREALDB_CONNECTION
AUTH_SURREALDB_USERNAME
AUTH_SURREALDB_PASSWORD
AUTH_SURREALDB_NS
AUTH_SURREALDB_DB
AUTH_SURREAL_URL,
AUTH_SURREAL_NS,
AUTH_SURREAL_DB,
AUTH_SURREAL_USER,
AUTH_SURREAL_PW,
```

### Configuration
Expand Down Expand Up @@ -99,66 +99,35 @@ The SurrealDB adapter does not handle connections automatically, so you will hav

### Authorization

#### Option 1 – Using RPC:
#### Using WS:

```ts filename="./lib/surrealdb.ts"
import { Surreal } from "surrealdb.js"
With this configuration, we can use the websocket endpoint. Thus, the `AUTH_SURREAL_URL` should begin with `ws` or `wss`.

const connectionString = process.env.AUTH_SURREALDB_CONNECTION
const user = process.env.AUTH_SURREALDB_USERNAME
const pass = process.env.AUTH_SURREALDB_PASSWORD
const ns = process.env.AUTH_SURREALDB_NS
const db = process.env.AUTH_SURREALDB_DB
```ts filename="./lib/surrealdb.ts"
import { Surreal } from "surrealdb"

const clientPromise = new Promise<Surreal>(async (resolve, reject) => {
const db = new Surreal()
try {
await db.connect(`${connectionString}/rpc`, {
ns,
db,
auth: { user, pass },
})
const db = new Surreal()
const {
AUTH_SURREAL_URL: url,
AUTH_SURREAL_NS: namespace,
AUTH_SURREAL_DB: database,
AUTH_SURREAL_USER: username,
AUTH_SURREAL_PW: password,
} = process.env
if (url && namespace && database && username && password) {
await db.connect(url)
await db.signin({
namespace,
database,
username,
password,
})
}
resolve(db)
} catch (e) {
reject(e)
}
})

// Export a module-scoped MongoClient promise. By doing this in a
// separate module, the client can be shared across functions.
export default clientPromise
```

#### Option 2 – Using HTTP:

Useful in serverless environments like Vercel.

```ts filename="./lib/surrealdb.ts"
import { ExperimentalSurrealHTTP } from "surrealdb.js"

const connectionString = process.env.AUTH_SURREALDB_CONNECTION
const user = process.env.AUTH_SURREALDB_USERNAME
const pass = process.env.AUTH_SURREALDB_PASSWORD
const ns = process.env.AUTH_SURREALDB_NS
const db = process.env.AUTH_SURREALDB_DB

const clientPromise = new Promise<ExperimentalSurrealHTTP<typeof fetch>>(
async (resolve, reject) => {
try {
const db = new ExperimentalSurrealHTTP(connectionString, {
fetch,
ns,
db,
auth: { user, pass },
})
resolve(db)
} catch (e) {
reject(e)
}
}
)

// Export a module-scoped MongoClient promise. By doing this in a
// separate module, the client can be shared across functions.
export default clientPromise
```
9 changes: 5 additions & 4 deletions packages/adapter-surrealdb/package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
{
"name": "@auth/surrealdb-adapter",
"version": "1.5.2",
"version": "2.0.0",
"description": "SurrealDB adapter for next-auth.",
"homepage": "https://authjs.dev",
"repository": "https://github.com/nextauthjs/next-auth",
"bugs": {
"url": "https://github.com/nextauthjs/next-auth/issues"
},
"author": "Martin Schaer <martin@schaerweb.com>",
"author": "Dylan Vanmali",
"contributors": [
"Martin Schaer <martin@schaerweb.com>",
"Thang Huu Vu <hi@thvu.dev>"
],
"type": "module",
Expand All @@ -29,7 +30,7 @@
"next-auth",
"next.js",
"oauth",
"mongodb",
"surrealdb",
"adapter"
],
"private": false,
Expand All @@ -44,6 +45,6 @@
"@auth/core": "workspace:*"
},
"peerDependencies": {
"surrealdb.js": "^0.11.0"
"surrealdb": "^1.0.0"
}
}
Loading








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/nextauthjs/next-auth/pull/11911/commits/ccefb64c39ad9f009686171932b31783a03ce44e

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy