shipd 0.1.3 → 0.2.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/base-package/app/globals.css +126 -0
- package/base-package/app/layout.tsx +53 -0
- package/base-package/app/page.tsx +15 -0
- package/base-package/base.config.json +57 -0
- package/base-package/components/ui/avatar.tsx +53 -0
- package/base-package/components/ui/badge.tsx +46 -0
- package/base-package/components/ui/button.tsx +59 -0
- package/base-package/components/ui/card.tsx +92 -0
- package/base-package/components/ui/chart.tsx +353 -0
- package/base-package/components/ui/checkbox.tsx +32 -0
- package/base-package/components/ui/dialog.tsx +135 -0
- package/base-package/components/ui/dropdown-menu.tsx +257 -0
- package/base-package/components/ui/form.tsx +167 -0
- package/base-package/components/ui/input.tsx +21 -0
- package/base-package/components/ui/label.tsx +24 -0
- package/base-package/components/ui/progress.tsx +31 -0
- package/base-package/components/ui/resizable.tsx +56 -0
- package/base-package/components/ui/select.tsx +185 -0
- package/base-package/components/ui/separator.tsx +28 -0
- package/base-package/components/ui/sheet.tsx +139 -0
- package/base-package/components/ui/skeleton.tsx +13 -0
- package/base-package/components/ui/sonner.tsx +25 -0
- package/base-package/components/ui/switch.tsx +31 -0
- package/base-package/components/ui/tabs.tsx +66 -0
- package/base-package/components/ui/textarea.tsx +18 -0
- package/base-package/components/ui/toggle-group.tsx +73 -0
- package/base-package/components/ui/toggle.tsx +47 -0
- package/base-package/components/ui/tooltip.tsx +61 -0
- package/base-package/components.json +21 -0
- package/base-package/eslint.config.mjs +16 -0
- package/base-package/lib/utils.ts +6 -0
- package/base-package/middleware.ts +12 -0
- package/base-package/next.config.ts +27 -0
- package/base-package/package.json +49 -0
- package/base-package/postcss.config.mjs +5 -0
- package/base-package/public/favicon.svg +4 -0
- package/base-package/tailwind.config.ts +89 -0
- package/base-package/tsconfig.json +27 -0
- package/dist/index.js +1858 -956
- package/docs-template/README.md +74 -0
- package/features/ai-chat/README.md +316 -0
- package/features/ai-chat/app/api/chat/route.ts +16 -0
- package/features/ai-chat/app/dashboard/_components/chatbot.tsx +39 -0
- package/features/ai-chat/app/dashboard/chat/page.tsx +73 -0
- package/features/ai-chat/feature.config.json +22 -0
- package/features/analytics/README.md +364 -0
- package/features/analytics/feature.config.json +20 -0
- package/features/analytics/lib/posthog.ts +36 -0
- package/features/auth/README.md +409 -0
- package/features/auth/app/api/auth/[...all]/route.ts +4 -0
- package/features/auth/app/dashboard/layout.tsx +15 -0
- package/features/auth/app/dashboard/page.tsx +140 -0
- package/features/auth/app/sign-in/page.tsx +228 -0
- package/features/auth/app/sign-up/page.tsx +243 -0
- package/features/auth/auth-schema.ts +47 -0
- package/features/auth/components/auth/setup-instructions.tsx +123 -0
- package/features/auth/feature.config.json +33 -0
- package/features/auth/lib/auth-client.ts +8 -0
- package/features/auth/lib/auth.ts +295 -0
- package/features/auth/lib/email-stub.ts +55 -0
- package/features/auth/lib/email.ts +47 -0
- package/features/auth/middleware.patch.ts +43 -0
- package/features/database/README.md +312 -0
- package/features/database/db/drizzle.ts +48 -0
- package/features/database/db/schema.ts +21 -0
- package/features/database/drizzle.config.ts +13 -0
- package/features/database/feature.config.json +30 -0
- package/features/email/README.md +341 -0
- package/features/email/emails/components/layout.tsx +181 -0
- package/features/email/emails/password-reset.tsx +67 -0
- package/features/email/emails/payment-failed.tsx +167 -0
- package/features/email/emails/subscription-confirmation.tsx +129 -0
- package/features/email/emails/welcome.tsx +100 -0
- package/features/email/feature.config.json +22 -0
- package/features/email/lib/email.ts +118 -0
- package/features/file-upload/README.md +329 -0
- package/features/file-upload/app/api/upload-image/route.ts +64 -0
- package/features/file-upload/app/dashboard/upload/page.tsx +324 -0
- package/features/file-upload/feature.config.json +23 -0
- package/features/file-upload/lib/upload-image.ts +28 -0
- package/features/marketing-landing/README.md +333 -0
- package/features/marketing-landing/app/page.tsx +25 -0
- package/features/marketing-landing/components/homepage/cli-workflow-section.tsx +231 -0
- package/features/marketing-landing/components/homepage/features-section.tsx +152 -0
- package/features/marketing-landing/components/homepage/footer.tsx +53 -0
- package/features/marketing-landing/components/homepage/hero-section.tsx +112 -0
- package/features/marketing-landing/components/homepage/integrations.tsx +124 -0
- package/features/marketing-landing/components/homepage/navigation.tsx +116 -0
- package/features/marketing-landing/components/homepage/news-section.tsx +82 -0
- package/features/marketing-landing/components/homepage/pricing-section.tsx +98 -0
- package/features/marketing-landing/components/homepage/testimonials-section.tsx +34 -0
- package/features/marketing-landing/components/logos/BetterAuth.tsx +21 -0
- package/features/marketing-landing/components/logos/NeonPostgres.tsx +41 -0
- package/features/marketing-landing/components/logos/Nextjs.tsx +72 -0
- package/features/marketing-landing/components/logos/Polar.tsx +7 -0
- package/features/marketing-landing/components/logos/TailwindCSS.tsx +27 -0
- package/features/marketing-landing/components/logos/index.ts +6 -0
- package/features/marketing-landing/components/logos/shadcnui.tsx +8 -0
- package/features/marketing-landing/feature.config.json +23 -0
- package/features/payments/README.md +375 -0
- package/features/payments/app/api/subscription/route.ts +25 -0
- package/features/payments/app/dashboard/payment/_components/manage-subscription.tsx +22 -0
- package/features/payments/app/dashboard/payment/page.tsx +126 -0
- package/features/payments/app/success/page.tsx +123 -0
- package/features/payments/feature.config.json +31 -0
- package/features/payments/lib/polar-products.ts +49 -0
- package/features/payments/lib/subscription.ts +148 -0
- package/features/payments/payments-schema.ts +30 -0
- package/features/seo/README.md +302 -0
- package/features/seo/app/blog/[slug]/page.tsx +314 -0
- package/features/seo/app/blog/page.tsx +107 -0
- package/features/seo/app/robots.txt +13 -0
- package/features/seo/app/sitemap.ts +70 -0
- package/features/seo/feature.config.json +19 -0
- package/features/seo/lib/seo-utils.ts +163 -0
- package/package.json +3 -1
|
@@ -0,0 +1,312 @@
|
|
|
1
|
+
# Database Module - Integration Guide
|
|
2
|
+
|
|
3
|
+
**Module Version:** 1.0.0
|
|
4
|
+
**Last Updated:** 2025-12-22
|
|
5
|
+
**Standalone:** ✅ Yes (base database setup)
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Overview
|
|
10
|
+
|
|
11
|
+
This module sets up PostgreSQL database connectivity using Drizzle ORM. It provides the foundation for database operations and can be extended by other modules (auth, payments) that add their own tables.
|
|
12
|
+
|
|
13
|
+
**Key Features:**
|
|
14
|
+
- PostgreSQL connection with Drizzle ORM
|
|
15
|
+
- Drizzle Kit configuration for migrations
|
|
16
|
+
- Base schema structure (extended by other modules)
|
|
17
|
+
- Database scripts (push, generate, migrate, studio)
|
|
18
|
+
- Support for Neon, Supabase, or any Postgres database
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## Files Added
|
|
23
|
+
|
|
24
|
+
### Configuration
|
|
25
|
+
- `drizzle.config.ts` - Drizzle Kit configuration
|
|
26
|
+
- `db/drizzle.ts` - Database connection setup
|
|
27
|
+
- `db/schema.ts` - Base schema file (modules will add tables here)
|
|
28
|
+
|
|
29
|
+
### Migrations
|
|
30
|
+
- `db/migrations/` - Directory for database migrations
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
## Dependencies
|
|
35
|
+
|
|
36
|
+
### Package Dependencies
|
|
37
|
+
The following packages will be added to `package.json`:
|
|
38
|
+
- `postgres@^3.4.4` - PostgreSQL client
|
|
39
|
+
- `drizzle-orm@^0.41.0` - Drizzle ORM
|
|
40
|
+
|
|
41
|
+
### Dev Dependencies
|
|
42
|
+
- `drizzle-kit@^0.31.0` - Drizzle migration and studio tools
|
|
43
|
+
|
|
44
|
+
### Package Scripts
|
|
45
|
+
The following scripts will be added to `package.json`:
|
|
46
|
+
- `db:push` - Push schema changes to database (development)
|
|
47
|
+
- `db:generate` - Generate migration files
|
|
48
|
+
- `db:migrate` - Run migrations
|
|
49
|
+
- `db:studio` - Open Drizzle Studio (database GUI)
|
|
50
|
+
|
|
51
|
+
---
|
|
52
|
+
|
|
53
|
+
## Environment Variables
|
|
54
|
+
|
|
55
|
+
Add this to your `.env.local`:
|
|
56
|
+
|
|
57
|
+
```env
|
|
58
|
+
# Database
|
|
59
|
+
DATABASE_URL="postgresql://user:password@host:port/database"
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
**Required Variables:**
|
|
63
|
+
- `DATABASE_URL` - PostgreSQL connection string
|
|
64
|
+
|
|
65
|
+
**Where to get it:**
|
|
66
|
+
- **Neon**: [neon.tech](https://neon.tech) - Free tier available
|
|
67
|
+
- **Supabase**: [supabase.com](https://supabase.com) - Free tier available
|
|
68
|
+
- **Local Postgres**: `postgresql://postgres:password@localhost:5432/mydb`
|
|
69
|
+
- **Any Postgres**: Standard PostgreSQL connection string format
|
|
70
|
+
|
|
71
|
+
---
|
|
72
|
+
|
|
73
|
+
## Manual Integration Steps
|
|
74
|
+
|
|
75
|
+
If you're appending this module to an existing project, follow these steps:
|
|
76
|
+
|
|
77
|
+
### Step 1: Install Dependencies
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
npm install
|
|
81
|
+
# or
|
|
82
|
+
pnpm install
|
|
83
|
+
# or
|
|
84
|
+
yarn install
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
The append command automatically adds missing dependencies to `package.json`, but you need to install them.
|
|
88
|
+
|
|
89
|
+
### Step 2: Add Environment Variable
|
|
90
|
+
|
|
91
|
+
1. Copy `.env.example` to `.env.local` (if not exists)
|
|
92
|
+
2. Add `DATABASE_URL` with your PostgreSQL connection string
|
|
93
|
+
3. Get a database URL from:
|
|
94
|
+
- [Neon](https://neon.tech) (recommended for development)
|
|
95
|
+
- [Supabase](https://supabase.com)
|
|
96
|
+
- Your own PostgreSQL server
|
|
97
|
+
|
|
98
|
+
### Step 3: Verify Installation
|
|
99
|
+
|
|
100
|
+
1. Check that `drizzle.config.ts` exists in project root
|
|
101
|
+
2. Check that `db/drizzle.ts` and `db/schema.ts` exist
|
|
102
|
+
3. Verify package.json has database scripts
|
|
103
|
+
|
|
104
|
+
### Step 4: Initialize Database (Optional)
|
|
105
|
+
|
|
106
|
+
If you want to create an initial migration:
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
npm run db:generate
|
|
110
|
+
npm run db:push
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
**Note:** The base schema is empty. Tables will be added when you install other modules (auth, payments, etc.).
|
|
114
|
+
|
|
115
|
+
---
|
|
116
|
+
|
|
117
|
+
## Usage Examples
|
|
118
|
+
|
|
119
|
+
### Using the Database Connection
|
|
120
|
+
|
|
121
|
+
```typescript
|
|
122
|
+
import { db } from "@/db/drizzle";
|
|
123
|
+
|
|
124
|
+
// Example query (after auth module adds user table)
|
|
125
|
+
const users = await db.select().from(user);
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
### Generating Migrations
|
|
129
|
+
|
|
130
|
+
After adding tables (via auth or payments modules):
|
|
131
|
+
|
|
132
|
+
```bash
|
|
133
|
+
# Generate migration files
|
|
134
|
+
npm run db:generate
|
|
135
|
+
|
|
136
|
+
# Review the generated migration in db/migrations/
|
|
137
|
+
|
|
138
|
+
# Push to database (development)
|
|
139
|
+
npm run db:push
|
|
140
|
+
|
|
141
|
+
# Or run migrations (production)
|
|
142
|
+
npm run db:migrate
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
### Opening Drizzle Studio
|
|
146
|
+
|
|
147
|
+
```bash
|
|
148
|
+
npm run db:studio
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
This opens a web-based database GUI at `http://localhost:4983`
|
|
152
|
+
|
|
153
|
+
---
|
|
154
|
+
|
|
155
|
+
## Customization
|
|
156
|
+
|
|
157
|
+
### Database Connection
|
|
158
|
+
|
|
159
|
+
Edit `db/drizzle.ts` to customize the connection:
|
|
160
|
+
|
|
161
|
+
```typescript
|
|
162
|
+
// For Supabase compatibility (prepared statements disabled)
|
|
163
|
+
const client = postgres(connectionString, { prepare: false });
|
|
164
|
+
|
|
165
|
+
// For other Postgres providers
|
|
166
|
+
const client = postgres(connectionString);
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
### Schema Location
|
|
170
|
+
|
|
171
|
+
The schema file is at `db/schema.ts`. Other modules will add their tables here. You can also add custom tables:
|
|
172
|
+
|
|
173
|
+
```typescript
|
|
174
|
+
// db/schema.ts
|
|
175
|
+
export const myCustomTable = pgTable("my_custom_table", {
|
|
176
|
+
id: text("id").primaryKey(),
|
|
177
|
+
name: text("name").notNull(),
|
|
178
|
+
// ...
|
|
179
|
+
});
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
---
|
|
183
|
+
|
|
184
|
+
## Integration Points
|
|
185
|
+
|
|
186
|
+
### Files That May Need Manual Updates
|
|
187
|
+
|
|
188
|
+
**db/schema.ts**:
|
|
189
|
+
- Other modules (auth, payments) will add their tables to this file
|
|
190
|
+
- You can add custom tables here as well
|
|
191
|
+
|
|
192
|
+
**drizzle.config.ts**:
|
|
193
|
+
- Usually doesn't need changes
|
|
194
|
+
- Modify if you need custom migration settings
|
|
195
|
+
|
|
196
|
+
---
|
|
197
|
+
|
|
198
|
+
## Troubleshooting
|
|
199
|
+
|
|
200
|
+
### Common Issues
|
|
201
|
+
|
|
202
|
+
**Issue:** "Missing DATABASE_URL" error
|
|
203
|
+
**Solution:**
|
|
204
|
+
- Ensure `DATABASE_URL` is set in `.env.local`
|
|
205
|
+
- Restart your dev server after adding env vars
|
|
206
|
+
- Check the connection string format
|
|
207
|
+
|
|
208
|
+
**Issue:** "Connection refused" or "ECONNREFUSED"
|
|
209
|
+
**Solution:**
|
|
210
|
+
- Verify your database is running
|
|
211
|
+
- Check the connection string is correct
|
|
212
|
+
- For cloud databases, ensure your IP is whitelisted (if required)
|
|
213
|
+
|
|
214
|
+
**Issue:** "relation does not exist" error
|
|
215
|
+
**Solution:**
|
|
216
|
+
- Run migrations: `npm run db:push` or `npm run db:migrate`
|
|
217
|
+
- Ensure other modules (auth, payments) have been installed and their tables added
|
|
218
|
+
|
|
219
|
+
**Issue:** Supabase connection issues
|
|
220
|
+
**Solution:**
|
|
221
|
+
- The connection is configured with `prepare: false` for Supabase compatibility
|
|
222
|
+
- If issues persist, check Supabase connection pooling settings
|
|
223
|
+
|
|
224
|
+
---
|
|
225
|
+
|
|
226
|
+
## Next Steps
|
|
227
|
+
|
|
228
|
+
After installing this module:
|
|
229
|
+
|
|
230
|
+
1. Set up your database (Neon, Supabase, or local)
|
|
231
|
+
2. Add `DATABASE_URL` to `.env.local`
|
|
232
|
+
3. Install Auth module (will add user/session tables)
|
|
233
|
+
4. Install Payments module (will add subscription table)
|
|
234
|
+
5. Run `npm run db:push` to create tables
|
|
235
|
+
|
|
236
|
+
---
|
|
237
|
+
|
|
238
|
+
## Related Modules
|
|
239
|
+
|
|
240
|
+
This module is required by:
|
|
241
|
+
- **Auth Module** - Adds user, session, account, verification tables
|
|
242
|
+
- **Payments Module** - Adds subscription table
|
|
243
|
+
|
|
244
|
+
This module works well with:
|
|
245
|
+
- **Auth Module** - For user authentication
|
|
246
|
+
- **Payments Module** - For subscription management
|
|
247
|
+
|
|
248
|
+
---
|
|
249
|
+
|
|
250
|
+
## Module Status
|
|
251
|
+
|
|
252
|
+
✅ **Standalone Package** - Can be installed independently
|
|
253
|
+
✅ **Base Setup** - Provides foundation for other modules
|
|
254
|
+
✅ **Ready to Use** - Works immediately after append
|
|
255
|
+
✅ **Well Documented** - Comprehensive integration guide
|
|
256
|
+
|
|
257
|
+
---
|
|
258
|
+
|
|
259
|
+
## AI Integration Prompt
|
|
260
|
+
|
|
261
|
+
**For AI Assistants:** Use this prompt to understand and integrate the Database module into an existing Next.js application.
|
|
262
|
+
|
|
263
|
+
```
|
|
264
|
+
The Database module has been appended to this Next.js project. Your task is to ensure it's properly integrated and functional.
|
|
265
|
+
|
|
266
|
+
**Installed Packages:**
|
|
267
|
+
- postgres@^3.4.4 - PostgreSQL client library
|
|
268
|
+
- drizzle-orm@^0.41.0 - TypeScript ORM for PostgreSQL
|
|
269
|
+
- drizzle-kit@^0.31.0 (dev) - Migration and database management tools
|
|
270
|
+
|
|
271
|
+
**Files Added:**
|
|
272
|
+
- drizzle.config.ts - Drizzle Kit configuration for migrations
|
|
273
|
+
- db/drizzle.ts - Database connection setup with lazy initialization
|
|
274
|
+
- db/schema.ts - Base schema file (currently empty, ready for modules to add tables)
|
|
275
|
+
- db/migrations/ - Directory for database migration files
|
|
276
|
+
|
|
277
|
+
**Package Scripts Added:**
|
|
278
|
+
- npm run db:push - Push schema changes directly to database (development)
|
|
279
|
+
- npm run db:generate - Generate migration files from schema changes
|
|
280
|
+
- npm run db:migrate - Run pending migrations
|
|
281
|
+
- npm run db:studio - Open Drizzle Studio GUI at http://localhost:4983
|
|
282
|
+
|
|
283
|
+
**Environment Variables Required:**
|
|
284
|
+
- DATABASE_URL - PostgreSQL connection string (format: postgresql://user:password@host:port/database)
|
|
285
|
+
|
|
286
|
+
**Integration Steps:**
|
|
287
|
+
1. Verify DATABASE_URL is set in .env.local. If missing, prompt user to add it.
|
|
288
|
+
2. Check that db/drizzle.ts uses lazy connection pattern (allows app to run without DATABASE_URL configured).
|
|
289
|
+
3. Verify db/schema.ts exists and is empty (other modules will add tables here).
|
|
290
|
+
4. Ensure drizzle.config.ts points to correct schema path: "./db/schema.ts"
|
|
291
|
+
5. Test database connection by running: npm run db:studio (if DATABASE_URL is set)
|
|
292
|
+
|
|
293
|
+
**Key Integration Points:**
|
|
294
|
+
- The database connection in db/drizzle.ts uses a Proxy pattern for lazy initialization
|
|
295
|
+
- Other modules (auth, payments) will automatically merge their tables into db/schema.ts
|
|
296
|
+
- The schema file should be imported as: import * as schema from "@/db/schema"
|
|
297
|
+
- Database queries use Drizzle ORM syntax: db.select().from(table).where(eq(table.id, value))
|
|
298
|
+
|
|
299
|
+
**Dependencies:**
|
|
300
|
+
- This module has no dependencies on other Shipd modules
|
|
301
|
+
- Other modules (auth, payments) require this module to be installed first
|
|
302
|
+
|
|
303
|
+
**Common Issues to Check:**
|
|
304
|
+
- If DATABASE_URL is missing, the app should still run (lazy connection), but database operations will fail
|
|
305
|
+
- For Supabase compatibility, connection uses { prepare: false } option
|
|
306
|
+
- Migration files are generated in db/migrations/ directory
|
|
307
|
+
|
|
308
|
+
**Next Steps After Integration:**
|
|
309
|
+
- If auth module is installed, it will add user/session/account/verification tables to schema
|
|
310
|
+
- If payments module is installed, it will add subscription table to schema
|
|
311
|
+
- After other modules add tables, run: npm run db:push to create tables in database
|
|
312
|
+
```
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import postgres from "postgres";
|
|
2
|
+
import { drizzle } from "drizzle-orm/postgres-js";
|
|
3
|
+
|
|
4
|
+
// Lazy database connection - only connect when actually used
|
|
5
|
+
// This allows the app to start even without DATABASE_URL configured
|
|
6
|
+
let dbInstance: ReturnType<typeof drizzle> | null = null;
|
|
7
|
+
let connectionError: Error | null = null;
|
|
8
|
+
|
|
9
|
+
function getDb() {
|
|
10
|
+
if (dbInstance) {
|
|
11
|
+
return dbInstance;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
if (connectionError) {
|
|
15
|
+
throw connectionError;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const connectionString = process.env.DATABASE_URL;
|
|
19
|
+
if (!connectionString) {
|
|
20
|
+
connectionError = new Error(
|
|
21
|
+
"Missing DATABASE_URL. Add it to your .env.local (or hosting provider env vars). " +
|
|
22
|
+
"You can use a Neon Postgres URL, Supabase, or any Postgres connection string."
|
|
23
|
+
);
|
|
24
|
+
throw connectionError;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
try {
|
|
28
|
+
// Disable prepared statements for Supabase compatibility
|
|
29
|
+
const client = postgres(connectionString, { prepare: false });
|
|
30
|
+
dbInstance = drizzle(client);
|
|
31
|
+
return dbInstance;
|
|
32
|
+
} catch (error) {
|
|
33
|
+
connectionError = error instanceof Error ? error : new Error(String(error));
|
|
34
|
+
throw connectionError;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// Export a proxy that lazily initializes the database
|
|
39
|
+
export const db = new Proxy({} as ReturnType<typeof drizzle>, {
|
|
40
|
+
get(_target, prop) {
|
|
41
|
+
const db = getDb();
|
|
42
|
+
const value = db[prop as keyof ReturnType<typeof drizzle>];
|
|
43
|
+
if (typeof value === 'function') {
|
|
44
|
+
return value.bind(db);
|
|
45
|
+
}
|
|
46
|
+
return value;
|
|
47
|
+
}
|
|
48
|
+
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import {
|
|
2
|
+
boolean,
|
|
3
|
+
integer,
|
|
4
|
+
pgTable,
|
|
5
|
+
text,
|
|
6
|
+
timestamp,
|
|
7
|
+
} from "drizzle-orm/pg-core";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Base Database Schema
|
|
11
|
+
*
|
|
12
|
+
* This is the base schema. Other modules (auth, payments) will add their tables.
|
|
13
|
+
* When appending modules, their schema files will be merged into this file.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
// Auth tables will be added by the auth module
|
|
17
|
+
// Subscription table will be added by the payments module
|
|
18
|
+
|
|
19
|
+
// Base schema is empty - modules add their own tables
|
|
20
|
+
// This file serves as the entry point for schema merging
|
|
21
|
+
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { config } from 'dotenv';
|
|
2
|
+
import { defineConfig } from "drizzle-kit";
|
|
3
|
+
|
|
4
|
+
config({ path: '.env' });
|
|
5
|
+
|
|
6
|
+
export default defineConfig({
|
|
7
|
+
schema: "./db/schema.ts",
|
|
8
|
+
out: "./db/migrations",
|
|
9
|
+
dialect: "postgresql",
|
|
10
|
+
dbCredentials: {
|
|
11
|
+
url: process.env.DATABASE_URL!,
|
|
12
|
+
},
|
|
13
|
+
});
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "database",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "PostgreSQL database setup with Drizzle ORM",
|
|
5
|
+
"dependencies": {
|
|
6
|
+
"postgres": "^3.4.4",
|
|
7
|
+
"drizzle-orm": "^0.41.0"
|
|
8
|
+
},
|
|
9
|
+
"devDependencies": {
|
|
10
|
+
"drizzle-kit": "^0.31.0"
|
|
11
|
+
},
|
|
12
|
+
"envVars": [
|
|
13
|
+
"DATABASE_URL"
|
|
14
|
+
],
|
|
15
|
+
"files": [
|
|
16
|
+
"drizzle.config.ts",
|
|
17
|
+
"db/drizzle.ts",
|
|
18
|
+
"db/schema.ts",
|
|
19
|
+
"db/migrations"
|
|
20
|
+
],
|
|
21
|
+
"packageJsonScripts": {
|
|
22
|
+
"db:push": "drizzle-kit push",
|
|
23
|
+
"db:generate": "drizzle-kit generate",
|
|
24
|
+
"db:migrate": "drizzle-kit migrate",
|
|
25
|
+
"db:studio": "drizzle-kit studio"
|
|
26
|
+
},
|
|
27
|
+
"requires": [],
|
|
28
|
+
"conflicts": []
|
|
29
|
+
}
|
|
30
|
+
|