create-scaffauth 0.1.0
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/LICENSE +21 -0
- package/README.md +82 -0
- package/dist/index.js +1050 -0
- package/dist/index.js.map +1 -0
- package/dist/templates/express/drizzle-mysql/.env.example.hbs +39 -0
- package/dist/templates/express/drizzle-mysql/README.md.hbs +78 -0
- package/dist/templates/express/drizzle-mysql/drizzle/db.ts +8 -0
- package/dist/templates/express/drizzle-mysql/drizzle/migrate.ts +22 -0
- package/dist/templates/express/drizzle-mysql/drizzle/schema.ts +58 -0
- package/dist/templates/express/drizzle-mysql/drizzle.config.ts +10 -0
- package/dist/templates/express/drizzle-mysql/package.json.hbs +36 -0
- package/dist/templates/express/drizzle-mysql/src/auth.ts.hbs +114 -0
- package/dist/templates/express/drizzle-mysql/src/index.ts +28 -0
- package/dist/templates/express/drizzle-mysql/tsconfig.json +19 -0
- package/dist/templates/express/drizzle-postgres/.env.example.hbs +39 -0
- package/dist/templates/express/drizzle-postgres/README.md.hbs +78 -0
- package/dist/templates/express/drizzle-postgres/drizzle/db.ts +8 -0
- package/dist/templates/express/drizzle-postgres/drizzle/migrate.ts +22 -0
- package/dist/templates/express/drizzle-postgres/drizzle/schema.ts +57 -0
- package/dist/templates/express/drizzle-postgres/drizzle.config.ts +10 -0
- package/dist/templates/express/drizzle-postgres/package.json.hbs +37 -0
- package/dist/templates/express/drizzle-postgres/src/auth.ts.hbs +114 -0
- package/dist/templates/express/drizzle-postgres/src/index.ts +28 -0
- package/dist/templates/express/drizzle-postgres/tsconfig.json +19 -0
- package/dist/templates/express/drizzle-sqlite/.env.example.hbs +39 -0
- package/dist/templates/express/drizzle-sqlite/README.md.hbs +78 -0
- package/dist/templates/express/drizzle-sqlite/drizzle/db.ts +6 -0
- package/dist/templates/express/drizzle-sqlite/drizzle/migrate.ts +12 -0
- package/dist/templates/express/drizzle-sqlite/drizzle/schema.ts +55 -0
- package/dist/templates/express/drizzle-sqlite/drizzle.config.ts +10 -0
- package/dist/templates/express/drizzle-sqlite/package.json.hbs +37 -0
- package/dist/templates/express/drizzle-sqlite/src/auth.ts.hbs +114 -0
- package/dist/templates/express/drizzle-sqlite/src/index.ts +28 -0
- package/dist/templates/express/drizzle-sqlite/tsconfig.json +19 -0
- package/dist/templates/express/kysely-mysql/.env.example.hbs +39 -0
- package/dist/templates/express/kysely-mysql/README.md.hbs +75 -0
- package/dist/templates/express/kysely-mysql/db/db.ts +11 -0
- package/dist/templates/express/kysely-mysql/db/migrate.ts +77 -0
- package/dist/templates/express/kysely-mysql/db/types.ts +54 -0
- package/dist/templates/express/kysely-mysql/package.json.hbs +32 -0
- package/dist/templates/express/kysely-mysql/src/auth.ts.hbs +114 -0
- package/dist/templates/express/kysely-mysql/src/index.ts +28 -0
- package/dist/templates/express/kysely-mysql/tsconfig.json +19 -0
- package/dist/templates/express/kysely-postgres/.env.example.hbs +39 -0
- package/dist/templates/express/kysely-postgres/README.md.hbs +75 -0
- package/dist/templates/express/kysely-postgres/db/db.ts +11 -0
- package/dist/templates/express/kysely-postgres/db/migrate.ts +77 -0
- package/dist/templates/express/kysely-postgres/db/types.ts +54 -0
- package/dist/templates/express/kysely-postgres/package.json.hbs +33 -0
- package/dist/templates/express/kysely-postgres/src/auth.ts.hbs +114 -0
- package/dist/templates/express/kysely-postgres/src/index.ts +28 -0
- package/dist/templates/express/kysely-postgres/tsconfig.json +19 -0
- package/dist/templates/express/kysely-sqlite/.env.example.hbs +39 -0
- package/dist/templates/express/kysely-sqlite/README.md.hbs +75 -0
- package/dist/templates/express/kysely-sqlite/db/db.ts +9 -0
- package/dist/templates/express/kysely-sqlite/db/migrate.ts +75 -0
- package/dist/templates/express/kysely-sqlite/db/types.ts +54 -0
- package/dist/templates/express/kysely-sqlite/package.json.hbs +33 -0
- package/dist/templates/express/kysely-sqlite/src/auth.ts.hbs +114 -0
- package/dist/templates/express/kysely-sqlite/src/index.ts +28 -0
- package/dist/templates/express/kysely-sqlite/tsconfig.json +19 -0
- package/dist/templates/express/prisma-mysql/.env.example.hbs +39 -0
- package/dist/templates/express/prisma-mysql/README.md.hbs +79 -0
- package/dist/templates/express/prisma-mysql/package.json.hbs +35 -0
- package/dist/templates/express/prisma-mysql/prisma/schema.prisma +66 -0
- package/dist/templates/express/prisma-mysql/src/auth.ts.hbs +114 -0
- package/dist/templates/express/prisma-mysql/src/db.ts +3 -0
- package/dist/templates/express/prisma-mysql/src/index.ts +28 -0
- package/dist/templates/express/prisma-mysql/tsconfig.json +19 -0
- package/dist/templates/express/prisma-postgres/.env.example.hbs +39 -0
- package/dist/templates/express/prisma-postgres/README.md.hbs +79 -0
- package/dist/templates/express/prisma-postgres/package.json.hbs +35 -0
- package/dist/templates/express/prisma-postgres/prisma/schema.prisma +66 -0
- package/dist/templates/express/prisma-postgres/src/auth.ts.hbs +114 -0
- package/dist/templates/express/prisma-postgres/src/db.ts +3 -0
- package/dist/templates/express/prisma-postgres/src/index.ts +28 -0
- package/dist/templates/express/prisma-postgres/tsconfig.json +19 -0
- package/dist/templates/express/prisma-sqlite/.env.example.hbs +39 -0
- package/dist/templates/express/prisma-sqlite/README.md.hbs +79 -0
- package/dist/templates/express/prisma-sqlite/package.json.hbs +35 -0
- package/dist/templates/express/prisma-sqlite/prisma/schema.prisma +66 -0
- package/dist/templates/express/prisma-sqlite/src/auth.ts.hbs +114 -0
- package/dist/templates/express/prisma-sqlite/src/db.ts +3 -0
- package/dist/templates/express/prisma-sqlite/src/index.ts +28 -0
- package/dist/templates/express/prisma-sqlite/tsconfig.json +19 -0
- package/dist/templates/fastify/drizzle-mysql/.env.example.hbs +39 -0
- package/dist/templates/fastify/drizzle-mysql/README.md.hbs +78 -0
- package/dist/templates/fastify/drizzle-mysql/drizzle/db.ts +8 -0
- package/dist/templates/fastify/drizzle-mysql/drizzle/migrate.ts +22 -0
- package/dist/templates/fastify/drizzle-mysql/drizzle/schema.ts +58 -0
- package/dist/templates/fastify/drizzle-mysql/drizzle.config.ts +10 -0
- package/dist/templates/fastify/drizzle-mysql/package.json.hbs +34 -0
- package/dist/templates/fastify/drizzle-mysql/src/auth.ts.hbs +114 -0
- package/dist/templates/fastify/drizzle-mysql/src/index.ts +34 -0
- package/dist/templates/fastify/drizzle-mysql/tsconfig.json +19 -0
- package/dist/templates/fastify/drizzle-postgres/.env.example.hbs +39 -0
- package/dist/templates/fastify/drizzle-postgres/README.md.hbs +78 -0
- package/dist/templates/fastify/drizzle-postgres/drizzle/db.ts +8 -0
- package/dist/templates/fastify/drizzle-postgres/drizzle/migrate.ts +22 -0
- package/dist/templates/fastify/drizzle-postgres/drizzle/schema.ts +57 -0
- package/dist/templates/fastify/drizzle-postgres/drizzle.config.ts +10 -0
- package/dist/templates/fastify/drizzle-postgres/package.json.hbs +35 -0
- package/dist/templates/fastify/drizzle-postgres/src/auth.ts.hbs +114 -0
- package/dist/templates/fastify/drizzle-postgres/src/index.ts +34 -0
- package/dist/templates/fastify/drizzle-postgres/tsconfig.json +19 -0
- package/dist/templates/fastify/drizzle-sqlite/.env.example.hbs +39 -0
- package/dist/templates/fastify/drizzle-sqlite/README.md.hbs +78 -0
- package/dist/templates/fastify/drizzle-sqlite/drizzle/db.ts +6 -0
- package/dist/templates/fastify/drizzle-sqlite/drizzle/migrate.ts +12 -0
- package/dist/templates/fastify/drizzle-sqlite/drizzle/schema.ts +55 -0
- package/dist/templates/fastify/drizzle-sqlite/drizzle.config.ts +10 -0
- package/dist/templates/fastify/drizzle-sqlite/package.json.hbs +35 -0
- package/dist/templates/fastify/drizzle-sqlite/src/auth.ts.hbs +114 -0
- package/dist/templates/fastify/drizzle-sqlite/src/index.ts +34 -0
- package/dist/templates/fastify/drizzle-sqlite/tsconfig.json +19 -0
- package/dist/templates/fastify/kysely-mysql/.env.example.hbs +39 -0
- package/dist/templates/fastify/kysely-mysql/README.md.hbs +75 -0
- package/dist/templates/fastify/kysely-mysql/db/db.ts +11 -0
- package/dist/templates/fastify/kysely-mysql/db/migrate.ts +77 -0
- package/dist/templates/fastify/kysely-mysql/db/types.ts +54 -0
- package/dist/templates/fastify/kysely-mysql/package.json.hbs +30 -0
- package/dist/templates/fastify/kysely-mysql/src/auth.ts.hbs +114 -0
- package/dist/templates/fastify/kysely-mysql/src/index.ts +34 -0
- package/dist/templates/fastify/kysely-mysql/tsconfig.json +19 -0
- package/dist/templates/fastify/kysely-postgres/.env.example.hbs +39 -0
- package/dist/templates/fastify/kysely-postgres/README.md.hbs +75 -0
- package/dist/templates/fastify/kysely-postgres/db/db.ts +11 -0
- package/dist/templates/fastify/kysely-postgres/db/migrate.ts +77 -0
- package/dist/templates/fastify/kysely-postgres/db/types.ts +54 -0
- package/dist/templates/fastify/kysely-postgres/package.json.hbs +31 -0
- package/dist/templates/fastify/kysely-postgres/src/auth.ts.hbs +114 -0
- package/dist/templates/fastify/kysely-postgres/src/index.ts +34 -0
- package/dist/templates/fastify/kysely-postgres/tsconfig.json +19 -0
- package/dist/templates/fastify/kysely-sqlite/.env.example.hbs +39 -0
- package/dist/templates/fastify/kysely-sqlite/README.md.hbs +75 -0
- package/dist/templates/fastify/kysely-sqlite/db/db.ts +9 -0
- package/dist/templates/fastify/kysely-sqlite/db/migrate.ts +75 -0
- package/dist/templates/fastify/kysely-sqlite/db/types.ts +54 -0
- package/dist/templates/fastify/kysely-sqlite/package.json.hbs +31 -0
- package/dist/templates/fastify/kysely-sqlite/src/auth.ts.hbs +114 -0
- package/dist/templates/fastify/kysely-sqlite/src/index.ts +34 -0
- package/dist/templates/fastify/kysely-sqlite/tsconfig.json +19 -0
- package/dist/templates/fastify/prisma-mysql/.env.example.hbs +39 -0
- package/dist/templates/fastify/prisma-mysql/README.md.hbs +79 -0
- package/dist/templates/fastify/prisma-mysql/package.json.hbs +33 -0
- package/dist/templates/fastify/prisma-mysql/prisma/schema.prisma +66 -0
- package/dist/templates/fastify/prisma-mysql/src/auth.ts.hbs +114 -0
- package/dist/templates/fastify/prisma-mysql/src/db.ts +3 -0
- package/dist/templates/fastify/prisma-mysql/src/index.ts +34 -0
- package/dist/templates/fastify/prisma-mysql/tsconfig.json +19 -0
- package/dist/templates/fastify/prisma-postgres/.env.example.hbs +39 -0
- package/dist/templates/fastify/prisma-postgres/README.md.hbs +79 -0
- package/dist/templates/fastify/prisma-postgres/package.json.hbs +33 -0
- package/dist/templates/fastify/prisma-postgres/prisma/schema.prisma +66 -0
- package/dist/templates/fastify/prisma-postgres/src/auth.ts.hbs +114 -0
- package/dist/templates/fastify/prisma-postgres/src/db.ts +3 -0
- package/dist/templates/fastify/prisma-postgres/src/index.ts +34 -0
- package/dist/templates/fastify/prisma-postgres/tsconfig.json +19 -0
- package/dist/templates/fastify/prisma-sqlite/.env.example.hbs +39 -0
- package/dist/templates/fastify/prisma-sqlite/README.md.hbs +79 -0
- package/dist/templates/fastify/prisma-sqlite/package.json.hbs +33 -0
- package/dist/templates/fastify/prisma-sqlite/prisma/schema.prisma +66 -0
- package/dist/templates/fastify/prisma-sqlite/src/auth.ts.hbs +114 -0
- package/dist/templates/fastify/prisma-sqlite/src/db.ts +3 -0
- package/dist/templates/fastify/prisma-sqlite/src/index.ts +34 -0
- package/dist/templates/fastify/prisma-sqlite/tsconfig.json +19 -0
- package/dist/templates/hono/drizzle-mysql/.env.example.hbs +39 -0
- package/dist/templates/hono/drizzle-mysql/README.md.hbs +85 -0
- package/dist/templates/hono/drizzle-mysql/drizzle/db.ts +8 -0
- package/dist/templates/hono/drizzle-mysql/drizzle/migrate.ts +22 -0
- package/dist/templates/hono/drizzle-mysql/drizzle/schema.ts +58 -0
- package/dist/templates/hono/drizzle-mysql/drizzle.config.ts +10 -0
- package/dist/templates/hono/drizzle-mysql/package.json.hbs +33 -0
- package/dist/templates/hono/drizzle-mysql/src/auth.ts.hbs +114 -0
- package/dist/templates/hono/drizzle-mysql/src/index.ts +35 -0
- package/dist/templates/hono/drizzle-mysql/tsconfig.json +19 -0
- package/dist/templates/hono/drizzle-postgres/.env.example.hbs +39 -0
- package/dist/templates/hono/drizzle-postgres/README.md.hbs +85 -0
- package/dist/templates/hono/drizzle-postgres/drizzle/db.ts +8 -0
- package/dist/templates/hono/drizzle-postgres/drizzle/migrate.ts +22 -0
- package/dist/templates/hono/drizzle-postgres/drizzle/schema.ts +57 -0
- package/dist/templates/hono/drizzle-postgres/drizzle.config.ts +10 -0
- package/dist/templates/hono/drizzle-postgres/package.json.hbs +34 -0
- package/dist/templates/hono/drizzle-postgres/src/auth.ts.hbs +114 -0
- package/dist/templates/hono/drizzle-postgres/src/index.ts +35 -0
- package/dist/templates/hono/drizzle-postgres/tsconfig.json +19 -0
- package/dist/templates/hono/drizzle-sqlite/.env.example.hbs +39 -0
- package/dist/templates/hono/drizzle-sqlite/README.md.hbs +85 -0
- package/dist/templates/hono/drizzle-sqlite/drizzle/db.ts +6 -0
- package/dist/templates/hono/drizzle-sqlite/drizzle/migrate.ts +12 -0
- package/dist/templates/hono/drizzle-sqlite/drizzle/schema.ts +55 -0
- package/dist/templates/hono/drizzle-sqlite/drizzle.config.ts +10 -0
- package/dist/templates/hono/drizzle-sqlite/package.json.hbs +34 -0
- package/dist/templates/hono/drizzle-sqlite/src/auth.ts.hbs +114 -0
- package/dist/templates/hono/drizzle-sqlite/src/index.ts +35 -0
- package/dist/templates/hono/drizzle-sqlite/tsconfig.json +19 -0
- package/dist/templates/hono/kysely-mysql/.env.example.hbs +39 -0
- package/dist/templates/hono/kysely-mysql/README.md.hbs +75 -0
- package/dist/templates/hono/kysely-mysql/db/db.ts +11 -0
- package/dist/templates/hono/kysely-mysql/db/migrate.ts +77 -0
- package/dist/templates/hono/kysely-mysql/db/types.ts +54 -0
- package/dist/templates/hono/kysely-mysql/package.json.hbs +29 -0
- package/dist/templates/hono/kysely-mysql/src/auth.ts.hbs +114 -0
- package/dist/templates/hono/kysely-mysql/src/index.ts +35 -0
- package/dist/templates/hono/kysely-mysql/tsconfig.json +19 -0
- package/dist/templates/hono/kysely-postgres/.env.example.hbs +39 -0
- package/dist/templates/hono/kysely-postgres/README.md.hbs +75 -0
- package/dist/templates/hono/kysely-postgres/db/db.ts +11 -0
- package/dist/templates/hono/kysely-postgres/db/migrate.ts +77 -0
- package/dist/templates/hono/kysely-postgres/db/types.ts +54 -0
- package/dist/templates/hono/kysely-postgres/package.json.hbs +30 -0
- package/dist/templates/hono/kysely-postgres/src/auth.ts.hbs +114 -0
- package/dist/templates/hono/kysely-postgres/src/index.ts +35 -0
- package/dist/templates/hono/kysely-postgres/tsconfig.json +19 -0
- package/dist/templates/hono/kysely-sqlite/.env.example.hbs +39 -0
- package/dist/templates/hono/kysely-sqlite/README.md.hbs +75 -0
- package/dist/templates/hono/kysely-sqlite/db/db.ts +9 -0
- package/dist/templates/hono/kysely-sqlite/db/migrate.ts +75 -0
- package/dist/templates/hono/kysely-sqlite/db/types.ts +54 -0
- package/dist/templates/hono/kysely-sqlite/package.json.hbs +30 -0
- package/dist/templates/hono/kysely-sqlite/src/auth.ts.hbs +114 -0
- package/dist/templates/hono/kysely-sqlite/src/index.ts +35 -0
- package/dist/templates/hono/kysely-sqlite/tsconfig.json +19 -0
- package/dist/templates/hono/prisma-mysql/.env.example.hbs +39 -0
- package/dist/templates/hono/prisma-mysql/README.md.hbs +79 -0
- package/dist/templates/hono/prisma-mysql/package.json.hbs +32 -0
- package/dist/templates/hono/prisma-mysql/prisma/schema.prisma +66 -0
- package/dist/templates/hono/prisma-mysql/src/auth.ts.hbs +114 -0
- package/dist/templates/hono/prisma-mysql/src/db.ts +3 -0
- package/dist/templates/hono/prisma-mysql/src/index.ts +35 -0
- package/dist/templates/hono/prisma-mysql/tsconfig.json +19 -0
- package/dist/templates/hono/prisma-postgres/.env.example.hbs +39 -0
- package/dist/templates/hono/prisma-postgres/README.md.hbs +79 -0
- package/dist/templates/hono/prisma-postgres/package.json.hbs +32 -0
- package/dist/templates/hono/prisma-postgres/prisma/schema.prisma +66 -0
- package/dist/templates/hono/prisma-postgres/src/auth.ts.hbs +114 -0
- package/dist/templates/hono/prisma-postgres/src/db.ts +3 -0
- package/dist/templates/hono/prisma-postgres/src/index.ts +35 -0
- package/dist/templates/hono/prisma-postgres/tsconfig.json +19 -0
- package/dist/templates/hono/prisma-sqlite/.env.example.hbs +39 -0
- package/dist/templates/hono/prisma-sqlite/README.md.hbs +79 -0
- package/dist/templates/hono/prisma-sqlite/package.json.hbs +32 -0
- package/dist/templates/hono/prisma-sqlite/prisma/schema.prisma +66 -0
- package/dist/templates/hono/prisma-sqlite/src/auth.ts.hbs +114 -0
- package/dist/templates/hono/prisma-sqlite/src/db.ts +3 -0
- package/dist/templates/hono/prisma-sqlite/src/index.ts +35 -0
- package/dist/templates/hono/prisma-sqlite/tsconfig.json +19 -0
- package/package.json +71 -0
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "{{projectName}}",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"private": true,
|
|
5
|
+
"type": "module",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"dev": "tsx watch src/index.ts",
|
|
8
|
+
"build": "tsc",
|
|
9
|
+
"start": "node dist/index.js",
|
|
10
|
+
"db:generate": "prisma generate",
|
|
11
|
+
"db:migrate": "prisma migrate dev",
|
|
12
|
+
"db:push": "prisma db push",
|
|
13
|
+
"db:studio": "prisma studio"
|
|
14
|
+
},
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"@prisma/client": "^6.3.0",
|
|
17
|
+
"better-auth": "^1.2.0",
|
|
18
|
+
"hono": "^4.7.0"
|
|
19
|
+
{{#if (eq emailProvider "resend")}},
|
|
20
|
+
"resend": "^4.0.0"{{/if}}{{#if (eq emailProvider "sendgrid")}},
|
|
21
|
+
"@sendgrid/mail": "^8.1.0"{{/if}}{{#if (eq emailProvider "smtp")}},
|
|
22
|
+
"nodemailer": "^6.9.0"{{/if}}
|
|
23
|
+
},
|
|
24
|
+
"devDependencies": {
|
|
25
|
+
"@types/node": "^22.13.0",
|
|
26
|
+
"prisma": "^6.3.0",
|
|
27
|
+
"tsx": "^4.19.0",
|
|
28
|
+
"typescript": "^5.7.0"
|
|
29
|
+
{{#if (eq emailProvider "smtp")}},
|
|
30
|
+
"@types/nodemailer": "^6.4.0"{{/if}}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
generator client {
|
|
2
|
+
provider = "prisma-client-js"
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
datasource db {
|
|
6
|
+
provider = "sqlite"
|
|
7
|
+
url = env("DATABASE_URL")
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
model User {
|
|
11
|
+
id String @id
|
|
12
|
+
name String
|
|
13
|
+
email String @unique
|
|
14
|
+
emailVerified Boolean @default(false)
|
|
15
|
+
image String?
|
|
16
|
+
createdAt DateTime @default(now())
|
|
17
|
+
updatedAt DateTime @updatedAt
|
|
18
|
+
sessions Session[]
|
|
19
|
+
accounts Account[]
|
|
20
|
+
|
|
21
|
+
@@map("user")
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
model Session {
|
|
25
|
+
id String @id
|
|
26
|
+
expiresAt DateTime
|
|
27
|
+
token String @unique
|
|
28
|
+
createdAt DateTime @default(now())
|
|
29
|
+
updatedAt DateTime @updatedAt
|
|
30
|
+
ipAddress String?
|
|
31
|
+
userAgent String?
|
|
32
|
+
userId String
|
|
33
|
+
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
34
|
+
|
|
35
|
+
@@map("session")
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
model Account {
|
|
39
|
+
id String @id
|
|
40
|
+
accountId String
|
|
41
|
+
providerId String
|
|
42
|
+
userId String
|
|
43
|
+
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
44
|
+
accessToken String?
|
|
45
|
+
refreshToken String?
|
|
46
|
+
idToken String?
|
|
47
|
+
accessTokenExpiresAt DateTime?
|
|
48
|
+
refreshTokenExpiresAt DateTime?
|
|
49
|
+
scope String?
|
|
50
|
+
password String?
|
|
51
|
+
createdAt DateTime @default(now())
|
|
52
|
+
updatedAt DateTime @updatedAt
|
|
53
|
+
|
|
54
|
+
@@map("account")
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
model Verification {
|
|
58
|
+
id String @id
|
|
59
|
+
identifier String
|
|
60
|
+
value String
|
|
61
|
+
expiresAt DateTime
|
|
62
|
+
createdAt DateTime @default(now())
|
|
63
|
+
updatedAt DateTime @updatedAt
|
|
64
|
+
|
|
65
|
+
@@map("verification")
|
|
66
|
+
}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { betterAuth } from "better-auth";
|
|
2
|
+
import { prismaAdapter } from "better-auth/adapters/prisma";
|
|
3
|
+
import { prisma } from "./db";
|
|
4
|
+
{{#if twoFactor}}
|
|
5
|
+
import { twoFactor } from "better-auth/plugins";
|
|
6
|
+
{{/if}}
|
|
7
|
+
{{#if rbac}}
|
|
8
|
+
import { admin } from "better-auth/plugins";
|
|
9
|
+
{{/if}}
|
|
10
|
+
{{#if (eq emailProvider "resend")}}
|
|
11
|
+
import { Resend } from "resend";
|
|
12
|
+
|
|
13
|
+
const resend = new Resend(process.env.RESEND_API_KEY);
|
|
14
|
+
{{/if}}
|
|
15
|
+
{{#if (eq emailProvider "sendgrid")}}
|
|
16
|
+
import sgMail from "@sendgrid/mail";
|
|
17
|
+
|
|
18
|
+
sgMail.setApiKey(process.env.SENDGRID_API_KEY!);
|
|
19
|
+
{{/if}}
|
|
20
|
+
{{#if (eq emailProvider "smtp")}}
|
|
21
|
+
import nodemailer from "nodemailer";
|
|
22
|
+
|
|
23
|
+
const transporter = nodemailer.createTransport({
|
|
24
|
+
host: process.env.SMTP_HOST,
|
|
25
|
+
port: Number(process.env.SMTP_PORT) || 587,
|
|
26
|
+
auth: {
|
|
27
|
+
user: process.env.SMTP_USER,
|
|
28
|
+
pass: process.env.SMTP_PASS,
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
{{/if}}
|
|
32
|
+
|
|
33
|
+
export const auth = betterAuth({
|
|
34
|
+
database: prismaAdapter(prisma, {
|
|
35
|
+
provider: "sqlite",
|
|
36
|
+
}),
|
|
37
|
+
emailAndPassword: {
|
|
38
|
+
enabled: true,
|
|
39
|
+
{{#if emailProvider}}
|
|
40
|
+
requireEmailVerification: true,
|
|
41
|
+
sendResetPassword: async ({ user, url }) => {
|
|
42
|
+
await sendEmail(user.email, "Reset your password", `<a href="${url}">Reset password</a>`);
|
|
43
|
+
},
|
|
44
|
+
{{/if}}
|
|
45
|
+
},
|
|
46
|
+
session: {
|
|
47
|
+
expiresIn: {{sessionExpiresIn}},
|
|
48
|
+
updateAge: {{sessionUpdateAge}},
|
|
49
|
+
cookieCache: {
|
|
50
|
+
enabled: {{sessionCookieCacheEnabled}},
|
|
51
|
+
maxAge: {{sessionCookieCacheMaxAge}},
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
{{#if emailProvider}}
|
|
55
|
+
emailVerification: {
|
|
56
|
+
sendOnSignUp: true,
|
|
57
|
+
sendVerificationEmail: async ({ user, url }) => {
|
|
58
|
+
await sendEmail(user.email, "Verify your email", `<a href="${url}">Verify email</a>`);
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
{{/if}}
|
|
62
|
+
{{#if providers.length}}
|
|
63
|
+
socialProviders: {
|
|
64
|
+
{{#each providers}}
|
|
65
|
+
{{this}}: {
|
|
66
|
+
clientId: process.env.{{uppercase this}}_CLIENT_ID!,
|
|
67
|
+
clientSecret: process.env.{{uppercase this}}_CLIENT_SECRET!,
|
|
68
|
+
},
|
|
69
|
+
{{/each}}
|
|
70
|
+
},
|
|
71
|
+
{{/if}}
|
|
72
|
+
{{#if (or twoFactor rbac)}}
|
|
73
|
+
plugins: [
|
|
74
|
+
{{#if twoFactor}}
|
|
75
|
+
twoFactor(),
|
|
76
|
+
{{/if}}
|
|
77
|
+
{{#if rbac}}
|
|
78
|
+
admin({
|
|
79
|
+
defaultRole: "user",
|
|
80
|
+
}),
|
|
81
|
+
{{/if}}
|
|
82
|
+
],
|
|
83
|
+
{{/if}}
|
|
84
|
+
trustedOrigins: [process.env.CORS_ORIGIN || "http://localhost:3001"],
|
|
85
|
+
});
|
|
86
|
+
{{#if emailProvider}}
|
|
87
|
+
|
|
88
|
+
async function sendEmail(to: string, subject: string, html: string) {
|
|
89
|
+
{{#if (eq emailProvider "resend")}}
|
|
90
|
+
await resend.emails.send({
|
|
91
|
+
from: process.env.EMAIL_FROM || "noreply@example.com",
|
|
92
|
+
to,
|
|
93
|
+
subject,
|
|
94
|
+
html,
|
|
95
|
+
});
|
|
96
|
+
{{/if}}
|
|
97
|
+
{{#if (eq emailProvider "sendgrid")}}
|
|
98
|
+
await sgMail.send({
|
|
99
|
+
from: process.env.EMAIL_FROM || "noreply@example.com",
|
|
100
|
+
to,
|
|
101
|
+
subject,
|
|
102
|
+
html,
|
|
103
|
+
});
|
|
104
|
+
{{/if}}
|
|
105
|
+
{{#if (eq emailProvider "smtp")}}
|
|
106
|
+
await transporter.sendMail({
|
|
107
|
+
from: process.env.EMAIL_FROM || "noreply@example.com",
|
|
108
|
+
to,
|
|
109
|
+
subject,
|
|
110
|
+
html,
|
|
111
|
+
});
|
|
112
|
+
{{/if}}
|
|
113
|
+
}
|
|
114
|
+
{{/if}}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Hono } from "hono";
|
|
2
|
+
import { cors } from "hono/cors";
|
|
3
|
+
import { logger } from "hono/logger";
|
|
4
|
+
import { auth } from "./auth";
|
|
5
|
+
|
|
6
|
+
const app = new Hono();
|
|
7
|
+
|
|
8
|
+
// Middleware
|
|
9
|
+
app.use("*", logger());
|
|
10
|
+
app.use(
|
|
11
|
+
"*",
|
|
12
|
+
cors({
|
|
13
|
+
origin: process.env.CORS_ORIGIN || "http://localhost:3001",
|
|
14
|
+
credentials: true,
|
|
15
|
+
}),
|
|
16
|
+
);
|
|
17
|
+
|
|
18
|
+
// Mount Better Auth handler
|
|
19
|
+
app.on(["POST", "GET"], "/api/auth/**", (c) => {
|
|
20
|
+
return auth.handler(c.req.raw);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
// Health check
|
|
24
|
+
app.get("/", (c) => {
|
|
25
|
+
return c.json({ status: "ok", message: "Auth backend is running" });
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
// Start server
|
|
29
|
+
const port = Number(process.env.PORT) || 3000;
|
|
30
|
+
console.log(`Server running on http://localhost:${port}`);
|
|
31
|
+
|
|
32
|
+
export default {
|
|
33
|
+
port,
|
|
34
|
+
fetch: app.fetch,
|
|
35
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"module": "ESNext",
|
|
5
|
+
"moduleResolution": "bundler",
|
|
6
|
+
"lib": ["ES2022"],
|
|
7
|
+
"outDir": "dist",
|
|
8
|
+
"rootDir": ".",
|
|
9
|
+
"strict": true,
|
|
10
|
+
"esModuleInterop": true,
|
|
11
|
+
"skipLibCheck": true,
|
|
12
|
+
"forceConsistentCasingInFileNames": true,
|
|
13
|
+
"resolveJsonModule": true,
|
|
14
|
+
"declaration": true,
|
|
15
|
+
"sourceMap": true
|
|
16
|
+
},
|
|
17
|
+
"include": ["src/**/*.ts", "drizzle/**/*.ts"],
|
|
18
|
+
"exclude": ["node_modules", "dist"]
|
|
19
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "create-scaffauth",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Scaffold production-ready Better Auth backends",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"create-scaffauth": "./dist/index.js"
|
|
8
|
+
},
|
|
9
|
+
"files": [
|
|
10
|
+
"dist"
|
|
11
|
+
],
|
|
12
|
+
"scripts": {
|
|
13
|
+
"build": "tsup",
|
|
14
|
+
"dev": "tsup --watch",
|
|
15
|
+
"start": "node dist/index.js",
|
|
16
|
+
"lint": "eslint src/",
|
|
17
|
+
"lint:fix": "eslint src/ --fix",
|
|
18
|
+
"format": "prettier --write \"src/**/*.ts\"",
|
|
19
|
+
"format:check": "prettier --check \"src/**/*.ts\"",
|
|
20
|
+
"test": "vitest run",
|
|
21
|
+
"test:watch": "vitest",
|
|
22
|
+
"typecheck": "tsc --noEmit",
|
|
23
|
+
"prepublishOnly": "npm run build"
|
|
24
|
+
},
|
|
25
|
+
"keywords": [
|
|
26
|
+
"auth",
|
|
27
|
+
"authentication",
|
|
28
|
+
"better-auth",
|
|
29
|
+
"backend",
|
|
30
|
+
"cli",
|
|
31
|
+
"scaffolding",
|
|
32
|
+
"hono",
|
|
33
|
+
"fastify",
|
|
34
|
+
"express",
|
|
35
|
+
"oauth",
|
|
36
|
+
"2fa"
|
|
37
|
+
],
|
|
38
|
+
"repository": {
|
|
39
|
+
"type": "git",
|
|
40
|
+
"url": "https://github.com/scaffauth/create-scaffauth"
|
|
41
|
+
},
|
|
42
|
+
"bugs": {
|
|
43
|
+
"url": "https://github.com/scaffauth/create-scaffauth/issues"
|
|
44
|
+
},
|
|
45
|
+
"homepage": "https://scaffauth.xyz",
|
|
46
|
+
"license": "MIT",
|
|
47
|
+
"engines": {
|
|
48
|
+
"node": ">=18.0.0"
|
|
49
|
+
},
|
|
50
|
+
"dependencies": {
|
|
51
|
+
"@clack/prompts": "^0.9.1",
|
|
52
|
+
"@octokit/rest": "^21.1.1",
|
|
53
|
+
"chalk": "^5.4.1",
|
|
54
|
+
"commander": "^13.1.0",
|
|
55
|
+
"execa": "^9.5.2",
|
|
56
|
+
"fs-extra": "^11.3.0",
|
|
57
|
+
"handlebars": "^4.7.8",
|
|
58
|
+
"ora": "^8.2.0"
|
|
59
|
+
},
|
|
60
|
+
"devDependencies": {
|
|
61
|
+
"@types/fs-extra": "^11.0.4",
|
|
62
|
+
"@types/node": "^22.13.1",
|
|
63
|
+
"eslint": "^9.20.0",
|
|
64
|
+
"eslint-config-prettier": "^10.0.1",
|
|
65
|
+
"prettier": "^3.5.1",
|
|
66
|
+
"tsup": "^8.3.6",
|
|
67
|
+
"typescript": "^5.7.3",
|
|
68
|
+
"typescript-eslint": "^8.24.0",
|
|
69
|
+
"vitest": "^3.0.5"
|
|
70
|
+
}
|
|
71
|
+
}
|