create-authhero 0.12.0 → 0.14.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.
@@ -114,24 +114,23 @@ curl -X POST https://your-server/api/v2/tenants \
114
114
  │ ├── index.ts # Worker entry point
115
115
  │ ├── app.ts # AuthHero app configuration
116
116
  │ ├── seed.ts # Database seeding worker
117
- ├── types.ts # TypeScript type definitions
118
- │ └── db/
119
- │ └── schema.ts # Drizzle schema for migrations
120
- ├── migrations/ # Database migrations
117
+ └── types.ts # TypeScript type definitions
121
118
  ├── wrangler.toml # Cloudflare Worker configuration
122
- ├── drizzle.config.ts # Drizzle configuration
119
+ ├── drizzle.config.ts # Drizzle configuration (reference only)
123
120
  ├── seed-helper.js # Helper script to run seeds
124
121
  └── package.json
125
122
  ```
126
123
 
127
- ## Database Schema Changes
124
+ ## Database Migrations
128
125
 
129
- To make schema changes:
126
+ Database migrations are pre-generated and shipped with the `@authhero/drizzle` package. The schema is managed by AuthHero to ensure compatibility with future updates.
130
127
 
131
- 1. Edit `src/db/schema.ts`
132
- 2. Generate migrations: `npm run db:generate`
133
- 3. Apply locally: `npm run migrate`
134
- 4. Apply to production: `npm run db:migrate:remote`
128
+ To apply migrations:
129
+
130
+ - **Local development**: `npm run migrate`
131
+ - **Production**: `npm run db:migrate:remote`
132
+
133
+ > ⚠️ **Note**: Do not run `drizzle-kit generate`. The `drizzle.config.ts` file is provided for reference only.
135
134
 
136
135
  ## API Documentation
137
136
 
@@ -1,8 +1,17 @@
1
1
  import { defineConfig } from "drizzle-kit";
2
2
 
3
- // SQLite/D1 configuration for Cloudflare Workers
3
+ // ⚠️ WARNING: Do not run `drizzle-kit generate` or `npm run db:generate`
4
+ //
5
+ // This configuration is for reference only. Migrations are pre-generated and
6
+ // shipped with the @authhero/drizzle package. The schema is managed by AuthHero
7
+ // and should not be customized to ensure compatibility with future updates.
8
+ //
9
+ // To apply migrations:
10
+ // Local: npm run migrate
11
+ // Remote: npm run db:migrate:remote
12
+
4
13
  export default defineConfig({
5
- out: "./migrations",
6
- schema: "./src/db/schema.ts",
14
+ out: "./node_modules/@authhero/drizzle/drizzle",
15
+ schema: "./node_modules/@authhero/drizzle/src/schema/sqlite/index.ts",
7
16
  dialect: "sqlite",
8
17
  });
@@ -12,6 +12,8 @@ export default {
12
12
  const url = new URL(request.url);
13
13
  const adminEmail = url.searchParams.get("email");
14
14
  const adminPassword = url.searchParams.get("password");
15
+ // Compute issuer from the request URL (for Management API identifier)
16
+ const issuer = `${url.protocol}//${url.host}/`;
15
17
 
16
18
  if (!adminEmail || !adminPassword) {
17
19
  return new Response(
@@ -34,6 +36,7 @@ export default {
34
36
  const result = await seed(adapters, {
35
37
  adminEmail,
36
38
  adminPassword,
39
+ issuer,
37
40
  });
38
41
 
39
42
  return new Response(
@@ -9,14 +9,14 @@ compatibility_date = "2024-11-20"
9
9
  # binding = "AUTH_DB"
10
10
  # database_name = "authhero-db"
11
11
  # database_id = "<YOUR_DATABASE_ID>"
12
- # migrations_dir = "migrations"
12
+ # migrations_dir = "node_modules/@authhero/drizzle/drizzle"
13
13
 
14
14
  # For local development, you can use a local D1 database:
15
15
  [[d1_databases]]
16
16
  binding = "AUTH_DB"
17
17
  database_name = "authhero-db"
18
18
  database_id = "local"
19
- migrations_dir = "migrations"
19
+ migrations_dir = "node_modules/@authhero/drizzle/drizzle"
20
20
 
21
21
  # ════════════════════════════════════════════════════════════════════════════
22
22
  # OPTIONAL: Analytics Engine for centralized logging
@@ -75,8 +75,6 @@ A single-tenant AuthHero authentication server using Cloudflare Workers and D1.
75
75
  - `npm run db:migrate:remote` - Run migrations on remote database
76
76
  - `npm run seed:local` - Seed local database with admin user
77
77
  - `npm run seed:remote` - Seed remote database with admin user
78
- - `npm run db:generate` - Generate new migration from schema changes
79
- - `npm run db:push` - Push schema changes directly to database (development only)
80
78
 
81
79
  ## Deployment
82
80
 
@@ -100,16 +98,12 @@ A single-tenant AuthHero authentication server using Cloudflare Workers and D1.
100
98
  ## Project Structure
101
99
 
102
100
  ```
103
- ├── migrations/
104
- │ └── 0000_init.sql # Initial database schema migration
105
101
  ├── src/
106
- │ ├── db/
107
- │ │ └── schema.ts # Drizzle schema (for migration generation)
108
102
  │ ├── index.ts # Worker entry point
109
103
  │ ├── app.ts # AuthHero app configuration
110
104
  │ ├── seed.ts # Database seeding worker
111
105
  │ └── types.ts # TypeScript type definitions
112
- ├── drizzle.config.ts # Drizzle Kit configuration
106
+ ├── drizzle.config.ts # Drizzle configuration (reference only)
113
107
  ├── seed-helper.js # Helper script for automated seeding
114
108
  ├── wrangler.toml # Cloudflare Worker configuration
115
109
  └── package.json
@@ -117,45 +111,14 @@ A single-tenant AuthHero authentication server using Cloudflare Workers and D1.
117
111
 
118
112
  ## Database Migrations
119
113
 
120
- This project uses [Drizzle Kit](https://orm.drizzle.team/kit-docs/overview) for generating database migrations from schema changes.
114
+ Database migrations are pre-generated and shipped with the `@authhero/drizzle` package. The schema is managed by AuthHero to ensure compatibility with future updates.
121
115
 
122
- ### Schema-Driven Migrations
116
+ To apply migrations:
123
117
 
124
- The database schema is defined in `src/db/schema.ts` using Drizzle ORM. When you need to make schema changes:
118
+ - **Local development**: `npm run migrate` or `npm run db:migrate:local`
119
+ - **Production**: `npm run db:migrate:remote`
125
120
 
126
- 1. **Modify the schema** (if customizing beyond the default AuthHero schema)
127
-
128
- 2. **Generate a new migration:**
129
-
130
- ```bash
131
- npm run db:generate
132
- ```
133
-
134
- This creates a new SQL migration file in the `migrations/` directory.
135
-
136
- 3. **Apply the migration locally:**
137
-
138
- ```bash
139
- npm run db:migrate:local
140
- ```
141
-
142
- 4. **Apply to production:**
143
- ```bash
144
- npm run db:migrate:remote
145
- ```
146
-
147
- ### Migration Architecture
148
-
149
- - **Drizzle ORM**: Defines the database schema in TypeScript
150
- - **drizzle-kit**: Generates SQL migrations by comparing schema to database state
151
- - **Kysely**: Used at runtime for executing queries (via @authhero/kysely-adapter)
152
-
153
- This approach gives you:
154
-
155
- - Type-safe schema definitions
156
- - Incremental migrations (only changes are migrated)
157
- - Full control over migration SQL
158
- - Compatibility with Cloudflare D1
121
+ > ⚠️ **Note**: Do not run `drizzle-kit generate`. The `drizzle.config.ts` file is provided for reference only.
159
122
 
160
123
  ## API Documentation
161
124
 
@@ -1,8 +1,17 @@
1
1
  import { defineConfig } from "drizzle-kit";
2
2
 
3
- // SQLite/D1 configuration for Cloudflare Workers
3
+ // ⚠️ WARNING: Do not run `drizzle-kit generate` or `npm run db:generate`
4
+ //
5
+ // This configuration is for reference only. Migrations are pre-generated and
6
+ // shipped with the @authhero/drizzle package. The schema is managed by AuthHero
7
+ // and should not be customized to ensure compatibility with future updates.
8
+ //
9
+ // To apply migrations:
10
+ // Local: npm run migrate
11
+ // Remote: npm run db:migrate:remote
12
+
4
13
  export default defineConfig({
5
- out: "./migrations",
6
- schema: "./src/db/schema.ts",
14
+ out: "./node_modules/@authhero/drizzle/drizzle",
15
+ schema: "./node_modules/@authhero/drizzle/src/schema/sqlite/index.ts",
7
16
  dialect: "sqlite",
8
17
  });
@@ -12,6 +12,8 @@ export default {
12
12
  const url = new URL(request.url);
13
13
  const adminEmail = url.searchParams.get("email");
14
14
  const adminPassword = url.searchParams.get("password");
15
+ // Compute issuer from the request URL (for Management API identifier)
16
+ const issuer = `${url.protocol}//${url.host}/`;
15
17
 
16
18
  if (!adminEmail || !adminPassword) {
17
19
  return new Response(
@@ -34,6 +36,7 @@ export default {
34
36
  const result = await seed(adapters, {
35
37
  adminEmail,
36
38
  adminPassword,
39
+ issuer,
37
40
  });
38
41
 
39
42
  return new Response(
@@ -9,14 +9,14 @@ compatibility_date = "2024-11-20"
9
9
  # binding = "AUTH_DB"
10
10
  # database_name = "authhero-db"
11
11
  # database_id = "<YOUR_DATABASE_ID>"
12
- # migrations_dir = "migrations"
12
+ # migrations_dir = "node_modules/@authhero/drizzle/drizzle"
13
13
 
14
14
  # For local development, you can use a local D1 database:
15
15
  [[d1_databases]]
16
16
  binding = "AUTH_DB"
17
17
  database_name = "authhero-db"
18
18
  database_id = "local"
19
- migrations_dir = "migrations"
19
+ migrations_dir = "node_modules/@authhero/drizzle/drizzle"
20
20
 
21
21
  # ════════════════════════════════════════════════════════════════════════════
22
22
  # OPTIONAL: Analytics Engine for centralized logging
@@ -3,8 +3,8 @@ import { Command as x } from "commander";
3
3
  import c from "inquirer";
4
4
  import i from "fs";
5
5
  import f from "path";
6
- import { spawn as b } from "child_process";
7
- const D = new x(), n = {
6
+ import { spawn as D } from "child_process";
7
+ const b = new x(), n = {
8
8
  local: {
9
9
  name: "Local (SQLite)",
10
10
  description: "Local development setup with SQLite database - great for getting started",
@@ -54,12 +54,12 @@ const D = new x(), n = {
54
54
  "db:migrate:local": "wrangler d1 migrations apply AUTH_DB --local",
55
55
  "db:migrate:remote": "wrangler d1 migrations apply AUTH_DB --remote",
56
56
  migrate: "wrangler d1 migrations apply AUTH_DB --local",
57
- "db:generate": "drizzle-kit generate",
58
57
  "seed:local": "node seed-helper.js",
59
58
  "seed:remote": "node seed-helper.js '' '' remote",
60
59
  seed: "node seed-helper.js"
61
60
  },
62
61
  dependencies: {
62
+ "@authhero/drizzle": "latest",
63
63
  "@authhero/kysely-adapter": "latest",
64
64
  "@hono/swagger-ui": "^0.5.0",
65
65
  "@hono/zod-openapi": "^0.19.0",
@@ -94,12 +94,12 @@ const D = new x(), n = {
94
94
  "db:migrate:local": "wrangler d1 migrations apply AUTH_DB --local",
95
95
  "db:migrate:remote": "wrangler d1 migrations apply AUTH_DB --remote",
96
96
  migrate: "wrangler d1 migrations apply AUTH_DB --local",
97
- "db:generate": "drizzle-kit generate",
98
97
  "seed:local": "node seed-helper.js",
99
98
  "seed:remote": "node seed-helper.js '' '' remote",
100
99
  seed: "node seed-helper.js"
101
100
  },
102
101
  dependencies: {
102
+ "@authhero/drizzle": "latest",
103
103
  "@authhero/kysely-adapter": "latest",
104
104
  "@authhero/multi-tenancy": "latest",
105
105
  "@hono/swagger-ui": "^0.5.0",
@@ -161,7 +161,7 @@ main().catch(console.error);
161
161
  }
162
162
  function v(r, a) {
163
163
  return new Promise((s, o) => {
164
- const t = b(r, [], {
164
+ const t = D(r, [], {
165
165
  cwd: a,
166
166
  shell: !0,
167
167
  stdio: "inherit"
@@ -173,7 +173,7 @@ function v(r, a) {
173
173
  }
174
174
  function S(r, a, s) {
175
175
  return new Promise((o, t) => {
176
- const e = b(r, [], {
176
+ const e = D(r, [], {
177
177
  cwd: a,
178
178
  shell: !0,
179
179
  stdio: "inherit",
@@ -184,7 +184,7 @@ function S(r, a, s) {
184
184
  }), e.on("error", t);
185
185
  });
186
186
  }
187
- D.version("1.0.0").description("Create a new AuthHero project").argument("[project-name]", "name of the project").option(
187
+ b.version("1.0.0").description("Create a new AuthHero project").argument("[project-name]", "name of the project").option(
188
188
  "-t, --template <type>",
189
189
  "template type: local, cloudflare-simple, or cloudflare-multitenant"
190
190
  ).option("-e, --email <email>", "admin email address").option("-p, --password <password>", "admin password (min 8 characters)").option(
@@ -409,4 +409,4 @@ Server will be available at: https://localhost:3000`)), console.log(`
409
409
  For more information, visit: https://authhero.net/docs
410
410
  `));
411
411
  });
412
- D.parse(process.argv);
412
+ b.parse(process.argv);
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "type": "git",
6
6
  "url": "https://github.com/markusahlstrand/authhero"
7
7
  },
8
- "version": "0.12.0",
8
+ "version": "0.14.0",
9
9
  "type": "module",
10
10
  "main": "dist/create-authhero.js",
11
11
  "bin": {