mirror of
https://github.com/LukeHagar/better-auth.git
synced 2025-12-10 12:27:44 +00:00
test: enable cloudflare smoke test (#4240)
This commit is contained in:
35
e2e/smoke/test/cloudflare.spec.ts
Normal file
35
e2e/smoke/test/cloudflare.spec.ts
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
import { describe, it } from "node:test";
|
||||||
|
import { spawn } from "node:child_process";
|
||||||
|
import { fileURLToPath } from "node:url";
|
||||||
|
import { join } from "node:path";
|
||||||
|
|
||||||
|
const fixturesDir = fileURLToPath(new URL("./fixtures", import.meta.url));
|
||||||
|
|
||||||
|
describe("(cloudflare) simple server", () => {
|
||||||
|
it("check repo", async (t) => {
|
||||||
|
const cp = spawn("npm", ["run", "check"], {
|
||||||
|
cwd: join(fixturesDir, "cloudflare"),
|
||||||
|
stdio: "pipe",
|
||||||
|
});
|
||||||
|
|
||||||
|
t.after(() => {
|
||||||
|
cp.kill("SIGINT");
|
||||||
|
});
|
||||||
|
|
||||||
|
cp.stdout.on("data", (data) => {
|
||||||
|
console.log(data.toString());
|
||||||
|
});
|
||||||
|
|
||||||
|
cp.stderr.on("data", (data) => {
|
||||||
|
console.error(data.toString());
|
||||||
|
});
|
||||||
|
|
||||||
|
await new Promise<void>((resolve) => {
|
||||||
|
cp.stdout.on("data", (data) => {
|
||||||
|
if (data.toString().includes("exiting now.")) {
|
||||||
|
resolve();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -1,105 +1,114 @@
|
|||||||
# Based on https://raw.githubusercontent.com/github/gitignore/main/Node.gitignore
|
# Created by https://www.toptal.com/developers/gitignore/api/node,macos
|
||||||
|
# Edit at https://www.toptal.com/developers/gitignore?templates=node,macos
|
||||||
|
|
||||||
|
### macOS ###
|
||||||
|
# General
|
||||||
|
.DS_Store
|
||||||
|
.AppleDouble
|
||||||
|
.LSOverride
|
||||||
|
|
||||||
|
# Icon must end with two \r
|
||||||
|
Icon
|
||||||
|
|
||||||
|
# Thumbnails
|
||||||
|
._*
|
||||||
|
|
||||||
|
# Files that might appear in the root of a volume
|
||||||
|
.DocumentRevisions-V100
|
||||||
|
.fseventsd
|
||||||
|
.Spotlight-V100
|
||||||
|
.TemporaryItems
|
||||||
|
.Trashes
|
||||||
|
.VolumeIcon.icns
|
||||||
|
.com.apple.timemachine.donotpresent
|
||||||
|
|
||||||
|
# Directories potentially created on remote AFP share
|
||||||
|
.AppleDB
|
||||||
|
.AppleDesktop
|
||||||
|
Network Trash Folder
|
||||||
|
Temporary Items
|
||||||
|
.apdisk
|
||||||
|
|
||||||
|
### Node ###
|
||||||
# Logs
|
# Logs
|
||||||
|
|
||||||
logs
|
logs
|
||||||
_.log
|
*.log
|
||||||
npm-debug.log_
|
npm-debug.log*
|
||||||
yarn-debug.log*
|
yarn-debug.log*
|
||||||
yarn-error.log*
|
yarn-error.log*
|
||||||
lerna-debug.log*
|
lerna-debug.log*
|
||||||
.pnpm-debug.log*
|
.pnpm-debug.log*
|
||||||
|
|
||||||
# Caches
|
|
||||||
|
|
||||||
.cache
|
|
||||||
|
|
||||||
# Diagnostic reports (https://nodejs.org/api/report.html)
|
# Diagnostic reports (https://nodejs.org/api/report.html)
|
||||||
|
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
|
||||||
report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json
|
|
||||||
|
|
||||||
# Runtime data
|
# Runtime data
|
||||||
|
|
||||||
pids
|
pids
|
||||||
_.pid
|
*.pid
|
||||||
_.seed
|
*.seed
|
||||||
*.pid.lock
|
*.pid.lock
|
||||||
|
|
||||||
# Directory for instrumented libs generated by jscoverage/JSCover
|
# Directory for instrumented libs generated by jscoverage/JSCover
|
||||||
|
|
||||||
lib-cov
|
lib-cov
|
||||||
|
|
||||||
# Coverage directory used by tools like istanbul
|
# Coverage directory used by tools like istanbul
|
||||||
|
|
||||||
coverage
|
coverage
|
||||||
*.lcov
|
*.lcov
|
||||||
|
|
||||||
# nyc test coverage
|
# nyc test coverage
|
||||||
|
|
||||||
.nyc_output
|
.nyc_output
|
||||||
|
|
||||||
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
|
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
|
||||||
|
|
||||||
.grunt
|
.grunt
|
||||||
|
|
||||||
# Bower dependency directory (https://bower.io/)
|
# Bower dependency directory (https://bower.io/)
|
||||||
|
|
||||||
bower_components
|
bower_components
|
||||||
|
|
||||||
# node-waf configuration
|
# node-waf configuration
|
||||||
|
|
||||||
.lock-wscript
|
.lock-wscript
|
||||||
|
|
||||||
# Compiled binary addons (https://nodejs.org/api/addons.html)
|
# Compiled binary addons (https://nodejs.org/api/addons.html)
|
||||||
|
|
||||||
build/Release
|
build/Release
|
||||||
|
|
||||||
# Dependency directories
|
# Dependency directories
|
||||||
|
|
||||||
node_modules/
|
node_modules/
|
||||||
jspm_packages/
|
jspm_packages/
|
||||||
|
|
||||||
# Snowpack dependency directory (https://snowpack.dev/)
|
# Moved from ./templates for ignoring all locks in templates
|
||||||
|
templates/**/*-lock.*
|
||||||
|
templates/**/*.lock
|
||||||
|
|
||||||
|
# Snowpack dependency directory (https://snowpack.dev/)
|
||||||
web_modules/
|
web_modules/
|
||||||
|
|
||||||
# TypeScript cache
|
# TypeScript cache
|
||||||
|
|
||||||
*.tsbuildinfo
|
*.tsbuildinfo
|
||||||
|
|
||||||
# Optional npm cache directory
|
# Optional npm cache directory
|
||||||
|
|
||||||
.npm
|
.npm
|
||||||
|
|
||||||
# Optional eslint cache
|
# Optional eslint cache
|
||||||
|
|
||||||
.eslintcache
|
.eslintcache
|
||||||
|
|
||||||
# Optional stylelint cache
|
# Optional stylelint cache
|
||||||
|
|
||||||
.stylelintcache
|
.stylelintcache
|
||||||
|
|
||||||
# Microbundle cache
|
# Microbundle cache
|
||||||
|
|
||||||
.rpt2_cache/
|
.rpt2_cache/
|
||||||
.rts2_cache_cjs/
|
.rts2_cache_cjs/
|
||||||
.rts2_cache_es/
|
.rts2_cache_es/
|
||||||
.rts2_cache_umd/
|
.rts2_cache_umd/
|
||||||
|
|
||||||
# Optional REPL history
|
# Optional REPL history
|
||||||
|
|
||||||
.node_repl_history
|
.node_repl_history
|
||||||
|
|
||||||
# Output of 'npm pack'
|
# Output of 'npm pack'
|
||||||
|
|
||||||
*.tgz
|
*.tgz
|
||||||
|
|
||||||
# Yarn Integrity file
|
# Yarn Integrity file
|
||||||
|
|
||||||
.yarn-integrity
|
.yarn-integrity
|
||||||
|
|
||||||
# dotenv environment variable files
|
# dotenv environment variable files
|
||||||
|
|
||||||
.env
|
.env
|
||||||
.env.development.local
|
.env.development.local
|
||||||
.env.test.local
|
.env.test.local
|
||||||
@@ -107,69 +116,73 @@ web_modules/
|
|||||||
.env.local
|
.env.local
|
||||||
|
|
||||||
# parcel-bundler cache (https://parceljs.org/)
|
# parcel-bundler cache (https://parceljs.org/)
|
||||||
|
.cache
|
||||||
.parcel-cache
|
.parcel-cache
|
||||||
|
|
||||||
# Next.js build output
|
# Next.js build output
|
||||||
|
|
||||||
.next
|
.next
|
||||||
out
|
out
|
||||||
|
|
||||||
# Nuxt.js build / generate output
|
# Nuxt.js build / generate output
|
||||||
|
|
||||||
.nuxt
|
.nuxt
|
||||||
dist
|
dist
|
||||||
|
|
||||||
# Gatsby files
|
# Gatsby files
|
||||||
|
.cache/
|
||||||
# Comment in the public line in if your project uses Gatsby and not Next.js
|
# Comment in the public line in if your project uses Gatsby and not Next.js
|
||||||
|
|
||||||
# https://nextjs.org/blog/next-9-1#public-directory-support
|
# https://nextjs.org/blog/next-9-1#public-directory-support
|
||||||
|
|
||||||
# public
|
# public
|
||||||
|
|
||||||
# vuepress build output
|
# vuepress build output
|
||||||
|
|
||||||
.vuepress/dist
|
.vuepress/dist
|
||||||
|
|
||||||
# vuepress v2.x temp and cache directory
|
# vuepress v2.x temp and cache directory
|
||||||
|
|
||||||
.temp
|
.temp
|
||||||
|
|
||||||
# Docusaurus cache and generated files
|
# Docusaurus cache and generated files
|
||||||
|
|
||||||
.docusaurus
|
.docusaurus
|
||||||
|
|
||||||
# Serverless directories
|
# Serverless directories
|
||||||
|
|
||||||
.serverless/
|
.serverless/
|
||||||
|
|
||||||
# FuseBox cache
|
# FuseBox cache
|
||||||
|
|
||||||
.fusebox/
|
.fusebox/
|
||||||
|
|
||||||
# DynamoDB Local files
|
# DynamoDB Local files
|
||||||
|
|
||||||
.dynamodb/
|
.dynamodb/
|
||||||
|
|
||||||
# TernJS port file
|
# TernJS port file
|
||||||
|
|
||||||
.tern-port
|
.tern-port
|
||||||
|
|
||||||
# Stores VSCode versions used for testing VSCode extensions
|
# Stores VSCode versions used for testing VSCode extensions
|
||||||
|
|
||||||
.vscode-test
|
.vscode-test
|
||||||
|
|
||||||
# yarn v2
|
# yarn v2
|
||||||
|
|
||||||
.yarn/cache
|
.yarn/cache
|
||||||
.yarn/unplugged
|
.yarn/unplugged
|
||||||
.yarn/build-state.yml
|
.yarn/build-state.yml
|
||||||
.yarn/install-state.gz
|
.yarn/install-state.gz
|
||||||
.pnp.*
|
.pnp.*
|
||||||
|
|
||||||
# IntelliJ based IDEs
|
### Node Patch ###
|
||||||
.idea
|
# Serverless Webpack directories
|
||||||
|
.webpack/
|
||||||
|
|
||||||
# Finder (MacOS) folder config
|
# Optional stylelint cache
|
||||||
.DS_Store
|
|
||||||
|
# SvelteKit build / generate output
|
||||||
|
.svelte-kit
|
||||||
|
|
||||||
|
# End of https://www.toptal.com/developers/gitignore/api/node,macos
|
||||||
|
|
||||||
|
# Wrangler output
|
||||||
|
.wrangler/
|
||||||
|
build/
|
||||||
|
|
||||||
|
# Turbo output
|
||||||
|
.turbo/
|
||||||
|
|
||||||
|
.dev.vars*
|
||||||
|
!.dev.vars.example
|
||||||
|
.env*
|
||||||
|
!.env.example
|
||||||
22
e2e/smoke/test/fixtures/cloudflare/package.json
vendored
Normal file
22
e2e/smoke/test/fixtures/cloudflare/package.json
vendored
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
{
|
||||||
|
"name": "cloudflare",
|
||||||
|
"private": true,
|
||||||
|
"dependencies": {
|
||||||
|
"better-auth": "workspace:*",
|
||||||
|
"drizzle-orm": "^0.44.5",
|
||||||
|
"hono": "^4.9.4"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@cloudflare/vitest-pool-workers": "^0.8.67",
|
||||||
|
"@cloudflare/workers-types": "^4.20250826.0",
|
||||||
|
"drizzle-kit": "^0.31.4",
|
||||||
|
"wrangler": "4.33.0"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"check": "tsc && wrangler deploy --dry-run",
|
||||||
|
"dev": "wrangler dev",
|
||||||
|
"migrate:local": "wrangler d1 migrations apply db --local",
|
||||||
|
"cf-typegen": "wrangler types --env-interface CloudflareBindings",
|
||||||
|
"e2e:smoke": "vitest"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,26 @@
|
|||||||
import { Hono } from "hono";
|
import { Hono } from "hono";
|
||||||
import { Auth, createAuth } from "./auth";
|
|
||||||
|
import { betterAuth } from "better-auth";
|
||||||
|
import { createDrizzle } from "./db";
|
||||||
|
import { drizzleAdapter } from "better-auth/adapters/drizzle";
|
||||||
|
|
||||||
|
interface CloudflareBindings {
|
||||||
|
DB: D1Database;
|
||||||
|
}
|
||||||
|
|
||||||
|
const createAuth = (env: CloudflareBindings) =>
|
||||||
|
betterAuth({
|
||||||
|
baseURL: "http://localhost:4000",
|
||||||
|
database: drizzleAdapter(createDrizzle(env.DB), { provider: "sqlite" }),
|
||||||
|
emailAndPassword: {
|
||||||
|
enabled: true,
|
||||||
|
},
|
||||||
|
logger: {
|
||||||
|
level: "debug",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
type Auth = ReturnType<typeof createAuth>;
|
||||||
|
|
||||||
const app = new Hono<{
|
const app = new Hono<{
|
||||||
Bindings: CloudflareBindings;
|
Bindings: CloudflareBindings;
|
||||||
19
e2e/smoke/test/fixtures/cloudflare/tsconfig.json
vendored
Normal file
19
e2e/smoke/test/fixtures/cloudflare/tsconfig.json
vendored
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"target": "esnext",
|
||||||
|
"lib": ["esnext"],
|
||||||
|
"module": "esnext",
|
||||||
|
"outDir": "./dist",
|
||||||
|
"moduleResolution": "bundler",
|
||||||
|
"types": [
|
||||||
|
"@cloudflare/workers-types/2023-07-01",
|
||||||
|
"@cloudflare/workers-types/experimental",
|
||||||
|
"@cloudflare/vitest-pool-workers"
|
||||||
|
],
|
||||||
|
"noEmit": true,
|
||||||
|
"isolatedModules": true,
|
||||||
|
"forceConsistentCasingInFileNames": true,
|
||||||
|
"skipLibCheck": true,
|
||||||
|
"strict": true
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -14,7 +14,7 @@ export default defineWorkersProject(async () => {
|
|||||||
poolOptions: {
|
poolOptions: {
|
||||||
workers: {
|
workers: {
|
||||||
singleWorker: true,
|
singleWorker: true,
|
||||||
wrangler: { configPath: "./wrangler.jsonc" },
|
wrangler: { configPath: "./wrangler.json" },
|
||||||
miniflare: {
|
miniflare: {
|
||||||
d1Databases: ["DB"],
|
d1Databases: ["DB"],
|
||||||
bindings: { TEST_MIGRATIONS: migrations },
|
bindings: { TEST_MIGRATIONS: migrations },
|
||||||
8658
e2e/smoke/test/fixtures/cloudflare/worker-configuration.d.ts
vendored
Normal file
8658
e2e/smoke/test/fixtures/cloudflare/worker-configuration.d.ts
vendored
Normal file
File diff suppressed because it is too large
Load Diff
18
e2e/smoke/test/fixtures/cloudflare/wrangler.json
vendored
Normal file
18
e2e/smoke/test/fixtures/cloudflare/wrangler.json
vendored
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
{
|
||||||
|
"$schema": "node_modules/wrangler/config-schema.json",
|
||||||
|
"compatibility_date": "2025-04-01",
|
||||||
|
"main": "src/index.ts",
|
||||||
|
"name": "cloudflare",
|
||||||
|
"upload_source_maps": true,
|
||||||
|
"d1_databases": [
|
||||||
|
{
|
||||||
|
"binding": "DB",
|
||||||
|
"database_id": "d1-db-id",
|
||||||
|
"database_name": "db",
|
||||||
|
"migrations_dir": "./drizzle"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"observability": {
|
||||||
|
"enabled": true
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
# bun
|
|
||||||
|
|
||||||
To install dependencies:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
bun install
|
|
||||||
```
|
|
||||||
|
|
||||||
To run:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
bun run index.ts
|
|
||||||
```
|
|
||||||
|
|
||||||
This project was created using `bun init` in bun v1.1.26. [Bun](https://bun.sh) is a fast all-in-one JavaScript runtime.
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
import { betterAuth } from "better-auth";
|
|
||||||
import { twoFactor } from "better-auth/plugins";
|
|
||||||
import Database from "bun:sqlite";
|
|
||||||
|
|
||||||
export const auth = betterAuth({
|
|
||||||
baseURL: "http://localhost:4000",
|
|
||||||
database: new Database("./auth.db"),
|
|
||||||
emailAndPassword: {
|
|
||||||
enabled: true,
|
|
||||||
},
|
|
||||||
plugins: [twoFactor()],
|
|
||||||
});
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
await fetch("http://localhost:4000/api/auth/sign-up/email", {
|
|
||||||
method: "POST",
|
|
||||||
body: JSON.stringify({
|
|
||||||
email: "test-2@test.com",
|
|
||||||
password: "password",
|
|
||||||
name: "test-2",
|
|
||||||
}),
|
|
||||||
headers: {
|
|
||||||
"content-type": "application/json",
|
|
||||||
},
|
|
||||||
})
|
|
||||||
.then((res) => res.json())
|
|
||||||
.then((data) => console.log(data));
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
import { auth } from "./auth";
|
|
||||||
|
|
||||||
Bun.serve({
|
|
||||||
fetch: auth.handler,
|
|
||||||
port: 4000,
|
|
||||||
});
|
|
||||||
console.log("Server running on port 4000");
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "@better-auth/bun",
|
|
||||||
"module": "index.ts",
|
|
||||||
"type": "module",
|
|
||||||
"private": true,
|
|
||||||
"scripts": {
|
|
||||||
"dev": "bun index.ts --hot"
|
|
||||||
},
|
|
||||||
"devDependencies": {
|
|
||||||
"@types/bun": "latest"
|
|
||||||
},
|
|
||||||
"peerDependencies": {
|
|
||||||
"typescript": "^5.7.2"
|
|
||||||
},
|
|
||||||
"dependencies": {
|
|
||||||
"@noble/ciphers": "^0.6.0",
|
|
||||||
"@types/better-sqlite3": "^7.6.12",
|
|
||||||
"better-auth": "workspace:*",
|
|
||||||
"better-sqlite3": "^11.6.0",
|
|
||||||
"pg": "^8.13.1"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
{
|
|
||||||
"compilerOptions": {
|
|
||||||
"lib": ["ESNext", "DOM"],
|
|
||||||
"target": "ESNext",
|
|
||||||
"module": "ESNext",
|
|
||||||
"moduleDetection": "force",
|
|
||||||
"jsx": "react-jsx",
|
|
||||||
"allowJs": true,
|
|
||||||
"declaration": true,
|
|
||||||
"moduleResolution": "bundler",
|
|
||||||
"allowImportingTsExtensions": true,
|
|
||||||
"verbatimModuleSyntax": true,
|
|
||||||
"noEmit": true,
|
|
||||||
"strict": true,
|
|
||||||
"skipLibCheck": true,
|
|
||||||
"noFallthroughCasesInSwitch": true,
|
|
||||||
"noUnusedLocals": false,
|
|
||||||
"noUnusedParameters": false,
|
|
||||||
"noPropertyAccessFromIndexSignature": false,
|
|
||||||
"paths": {
|
|
||||||
"@/*": ["./src/*"]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
33
integration-tests/cloudflare/.gitignore
vendored
33
integration-tests/cloudflare/.gitignore
vendored
@@ -1,33 +0,0 @@
|
|||||||
# prod
|
|
||||||
dist/
|
|
||||||
|
|
||||||
# dev
|
|
||||||
.yarn/
|
|
||||||
!.yarn/releases
|
|
||||||
.vscode/*
|
|
||||||
!.vscode/launch.json
|
|
||||||
!.vscode/*.code-snippets
|
|
||||||
.idea/workspace.xml
|
|
||||||
.idea/usage.statistics.xml
|
|
||||||
.idea/shelf
|
|
||||||
|
|
||||||
# deps
|
|
||||||
node_modules/
|
|
||||||
.wrangler
|
|
||||||
|
|
||||||
# env
|
|
||||||
.env
|
|
||||||
.env.production
|
|
||||||
.dev.vars
|
|
||||||
|
|
||||||
# logs
|
|
||||||
logs/
|
|
||||||
*.log
|
|
||||||
npm-debug.log*
|
|
||||||
yarn-debug.log*
|
|
||||||
yarn-error.log*
|
|
||||||
pnpm-debug.log*
|
|
||||||
lerna-debug.log*
|
|
||||||
|
|
||||||
# misc
|
|
||||||
.DS_Store
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
## How to run in dev
|
|
||||||
|
|
||||||
```
|
|
||||||
pnpm install
|
|
||||||
pnpm run migrate:local
|
|
||||||
pnpm run dev
|
|
||||||
```
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "@better-auth/cloudflare",
|
|
||||||
"type": "module",
|
|
||||||
"private": true,
|
|
||||||
"scripts": {
|
|
||||||
"dev": "wrangler dev",
|
|
||||||
"migrate:local": "wrangler d1 migrations apply db --local",
|
|
||||||
"cf-typegen": "wrangler types --env-interface CloudflareBindings",
|
|
||||||
"test": "vitest"
|
|
||||||
},
|
|
||||||
"dependencies": {
|
|
||||||
"better-auth": "workspace:^",
|
|
||||||
"drizzle-orm": "^0.39.3",
|
|
||||||
"hono": "^4.7.2"
|
|
||||||
},
|
|
||||||
"devDependencies": {
|
|
||||||
"@cloudflare/vitest-pool-workers": "^0.8.60",
|
|
||||||
"@cloudflare/workers-types": "^4.20250805.0",
|
|
||||||
"drizzle-kit": "^0.30.4",
|
|
||||||
"wrangler": "^3.109.2"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
import { betterAuth } from "better-auth";
|
|
||||||
import { drizzleAdapter } from "better-auth/adapters/drizzle";
|
|
||||||
import { createDrizzle } from "./db";
|
|
||||||
|
|
||||||
export const createAuth = (env: CloudflareBindings) =>
|
|
||||||
betterAuth({
|
|
||||||
database: drizzleAdapter(createDrizzle(env.DB), { provider: "sqlite" }),
|
|
||||||
secret: "some-secret-value-here",
|
|
||||||
emailAndPassword: {
|
|
||||||
enabled: true,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
export type Auth = ReturnType<typeof createAuth>;
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
{
|
|
||||||
"compilerOptions": {
|
|
||||||
"target": "ESNext",
|
|
||||||
"module": "ESNext",
|
|
||||||
"moduleResolution": "Bundler",
|
|
||||||
"strict": true,
|
|
||||||
"skipLibCheck": true,
|
|
||||||
"lib": ["ESNext"],
|
|
||||||
"types": [
|
|
||||||
"@cloudflare/workers-types/2023-07-01",
|
|
||||||
"@cloudflare/workers-types/experimental",
|
|
||||||
"@cloudflare/vitest-pool-workers"
|
|
||||||
],
|
|
||||||
"jsx": "react-jsx",
|
|
||||||
"jsxImportSource": "hono/jsx"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
// Generated by Wrangler by running `wrangler types --env-interface CloudflareBindings`
|
|
||||||
|
|
||||||
interface CloudflareBindings {
|
|
||||||
DB: D1Database;
|
|
||||||
}
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
{
|
|
||||||
"$schema": "../../node_modules/wrangler/config-schema.json",
|
|
||||||
"name": "cloudflare",
|
|
||||||
"main": "src/index.ts",
|
|
||||||
"compatibility_date": "2025-02-14",
|
|
||||||
"d1_databases": [
|
|
||||||
{
|
|
||||||
"binding": "DB",
|
|
||||||
"database_id": "d1-db-id",
|
|
||||||
"database_name": "db",
|
|
||||||
"migrations_dir": "./drizzle"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
@@ -39,7 +39,8 @@
|
|||||||
"remark-mdx": "3.0.0",
|
"remark-mdx": "3.0.0",
|
||||||
"remark-parse": "11.0.0",
|
"remark-parse": "11.0.0",
|
||||||
"unified": "11.0.4",
|
"unified": "11.0.4",
|
||||||
"whatwg-url": "^14.0.0"
|
"whatwg-url": "^14.0.0",
|
||||||
|
"miniflare>zod": "^3"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"resolutions": {
|
"resolutions": {
|
||||||
|
|||||||
1164
pnpm-lock.yaml
generated
1164
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@@ -1,9 +1,8 @@
|
|||||||
packages:
|
packages:
|
||||||
- packages/**
|
- packages/**
|
||||||
- docs
|
- docs
|
||||||
- integration-tests/**
|
|
||||||
- demo/*
|
- demo/*
|
||||||
- e2e/*
|
- e2e/**
|
||||||
catalogs:
|
catalogs:
|
||||||
react18:
|
react18:
|
||||||
'@types/react': ^19.1.0
|
'@types/react': ^19.1.0
|
||||||
|
|||||||
Reference in New Issue
Block a user