ReviewOS

also looking at this

stacks/stx

chore: wip stx improvements

#1649
Merged fingersandmind wants to merge feat/stx-improvements into main
241 files +19022 -1323
ECOSYSTEM_TODO.mdmodified+110-110
Changes to ECOSYSTEM_TODO.md
@@ -9,7 +9,7 @@
99- [x] Implement `.env` file loader using `Bun.env`
1010- [x] Implement `validateEnv()` with startup error reporting
1111- [x] Migrate `env.ts` helpers (`isProduction`, `isDevelopment`) into this package
12- [ ] Add re-export shim in core `stx` package for backwards compat
12- [x] Add re-export shim in core `stx` package for backwards compat
1313- [x] Add `@stacksjs/config` to root `tsconfig.json` paths
1414- [x] Add to workspace in root `package.json`
1515- [x] Write tests for all env types, defaults, required fields, validation
@@ -24,8 +24,8 @@
2424- [x] Extract SPA client script from `stx/src/client/index.ts`
2525- [x] Implement nested layout resolution (`_layout.stx` chain)
2626- [x] Implement route type generation (`.stx/route-types.d.ts`)
27- [ ] Update `dev-server.ts` and `bun-plugin/src/serve.ts` to import from `@stacksjs/router`
28- [ ] Add re-export shims in core `stx` for backwards compat
27- [x] Update `dev-server.ts` and `bun-plugin/src/serve.ts` to import from `@stacksjs/router`
28- [x] Add re-export shims in core `stx` for backwards compat
2929- [x] Write tests for: file scanning, pattern matching, dynamic params, middleware chain, layout nesting, named routes
3030- [x] Add to `tsconfig.json` paths and workspace
3131
@@ -37,8 +37,8 @@
3737- [x] Implement `useAsyncData()` and `useFetch()` composables
3838- [x] Implement loader result caching with stale-while-revalidate
3939- [x] Implement safe serialization (handle Dates, BigInt, etc.)
40- [ ] Integrate loader execution into dev-server request pipeline
41- [ ] Integrate actions with `@form` directive
40- [x] Integrate loader execution into dev-server request pipeline
41- [x] Integrate actions with `@form` directive
4242- [x] Write tests for loaders, actions, composables, caching, serialization
4343- [x] Add to `tsconfig.json` paths and workspace
4444
@@ -49,8 +49,8 @@
4949- [x] Implement `bunServerAdapter` with compression, static file serving, TLS
5050- [x] Implement `staticAdapter` wrapping existing SSG
5151- [x] Extract platform detection from `edge-runtime.ts`
52- [ ] Integrate with production build pipeline
53- [ ] Add `stx deploy` CLI command
52- [x] Integrate with production build pipeline
53- [x] Add `stx deploy` CLI command
5454- [x] Write tests for each adapter
5555- [x] Add to `tsconfig.json` paths and workspace
5656
@@ -60,61 +60,61 @@
6060
6161### 5. `@stacksjs/db` — Database & ORM
6262
63- [ ] Create `packages/db/` with standard package structure
64- [ ] Extract `QueryBuilder`, `Model`, adapters from `database.ts`
65- [ ] Implement `defineTable()` schema builder
66- [ ] Implement `TableBuilder` with all column types
67- [ ] Implement migration runner
68- [ ] Implement auto-migrate for development
69- [ ] Implement database seeder
70- [ ] Add re-export shim in core `stx` package
71- [ ] Write comprehensive tests
72- [ ] Add to `tsconfig.json` paths and workspace
63- [x] Create `packages/db/` with standard package structure
64- [x] Extract `QueryBuilder`, `Model`, adapters from `database.ts`
65- [x] Implement `defineTable()` schema builder
66- [x] Implement `TableBuilder` with all column types
67- [x] Implement migration runner
68- [x] Implement auto-migrate for development
69- [x] Implement database seeder
70- [x] Add re-export shim in core `stx` package
71- [x] Write comprehensive tests
72- [x] Add to `tsconfig.json` paths and workspace
7373
7474### 6. `@stacksjs/auth` — Authentication & Authorization
7575
76- [ ] Create `packages/auth/` with standard package structure
77- [ ] Implement session management (create, validate, destroy)
78- [ ] Implement password hashing (bcrypt via Bun)
79- [ ] Implement OAuth flow (GitHub, Google providers)
80- [ ] Implement auth/guest middleware
81- [ ] Implement permissions system
82- [ ] Create scaffold templates (login, register, forgot-password, reset-password)
83- [ ] Extract CSRF logic from `forms.ts`
84- [ ] Wire up `@auth`/`@guest`/`@can` directive backends
85- [ ] Write tests for all auth flows
86- [ ] Add to `tsconfig.json` paths and workspace
76- [x] Create `packages/auth/` with standard package structure
77- [x] Implement session management (create, validate, destroy)
78- [x] Implement password hashing (bcrypt via Bun)
79- [x] Implement OAuth flow (GitHub, Google providers)
80- [x] Implement auth/guest middleware
81- [x] Implement permissions system
82- [x] Create scaffold templates (login, register, forgot-password, reset-password)
83- [x] Extract CSRF logic from `forms.ts`
84- [x] Wire up `@auth`/`@guest`/`@can` directive backends
85- [x] Write tests for all auth flows
86- [x] Add to `tsconfig.json` paths and workspace
8787
8888### 7. `@stacksjs/api` — File-Based API Routes + Type-Safe RPC
8989
90- [ ] Create `packages/api/` with standard package structure
91- [ ] Implement `defineHandler()` with method, input validation, middleware
92- [ ] Implement file-based API route scanning
93- [ ] Implement typed RPC client generation
94- [ ] Integrate API route handling into dev-server
95- [ ] Write tests
96- [ ] Add to workspace
90- [x] Create `packages/api/` with standard package structure
91- [x] Implement `defineHandler()` with method, input validation, middleware
92- [x] Implement file-based API route scanning
93- [x] Implement typed RPC client generation
94- [x] Integrate API route handling into dev-server
95- [x] Write tests
96- [x] Add to workspace
9797
9898### 8. `@stacksjs/forms` — Form State + Validation + Server Actions
9999
100- [ ] Create `packages/forms/` with standard package structure
101- [ ] Extract `Validator` class from `forms-validation.ts`
102- [ ] Implement `useForm()` composable
103- [ ] Implement Zod schema integration
104- [ ] Integrate with `@form` directive and server actions
105- [ ] Write tests
106- [ ] Add to workspace
100- [x] Create `packages/forms/` with standard package structure
101- [x] Extract `Validator` class from `forms-validation.ts`
102- [x] Implement `useForm()` composable
103- [x] Implement Zod schema integration
104- [x] Integrate with `@form` directive and server actions
105- [x] Write tests
106- [x] Add to workspace
107107
108108### 9. `@stacksjs/cache` — Multi-Driver Caching
109109
110- [ ] Create `packages/cache/` with standard package structure
111- [ ] Implement memory driver (LRU)
112- [ ] Implement file driver (from existing `caching.ts`)
113- [ ] Implement SQLite driver (using `bun:sqlite`)
114- [ ] Implement `remember()` and tag-based invalidation
115- [ ] Integrate with ISR
116- [ ] Write tests
117- [ ] Add to workspace
110- [x] Create `packages/cache/` with standard package structure
111- [x] Implement memory driver (LRU)
112- [x] Implement file driver (from existing `caching.ts`)
113- [x] Implement SQLite driver (using `bun:sqlite`)
114- [x] Implement `remember()` and tag-based invalidation
115- [x] Integrate with ISR
116- [x] Write tests
117- [x] Add to workspace
118118
119119---
120120
@@ -122,45 +122,45 @@
122122
123123### 10. `@stacksjs/email` — Email with STX Templates
124124
125- [ ] Create `packages/email/` with standard package structure
126- [ ] Implement `sendMail()` with STX template rendering
127- [ ] Implement provider adapters (Resend, SES, SMTP)
128- [ ] Write tests
129- [ ] Add to workspace
125- [x] Create `packages/email/` with standard package structure
126- [x] Implement `sendMail()` with STX template rendering
127- [x] Implement provider adapters (Resend, SES, SMTP)
128- [x] Write tests
129- [x] Add to workspace
130130
131131### 11. `@stacksjs/storage` — File Storage Abstraction
132132
133- [ ] Create `packages/storage/` with standard package structure
134- [ ] Implement local disk driver
135- [ ] Implement S3/R2 driver with signed URLs
136- [ ] Write tests
137- [ ] Add to workspace
133- [x] Create `packages/storage/` with standard package structure
134- [x] Implement local disk driver
135- [x] Implement S3/R2 driver with signed URLs
136- [x] Write tests
137- [x] Add to workspace
138138
139139### 12. `@stacksjs/testing` — Test Utilities
140140
141- [ ] Create `packages/testing/` with standard package structure
142- [ ] Implement `renderTemplate()` for template testing
143- [ ] Implement `testLoader()` and `testAction()` helpers
144- [ ] Write tests
145- [ ] Add to workspace
141- [x] Create `packages/testing/` with standard package structure
142- [x] Implement `renderTemplate()` for template testing
143- [x] Implement `testLoader()` and `testAction()` helpers
144- [x] Write tests
145- [x] Add to workspace
146146
147147### 13. `@stacksjs/errors` — Error Boundaries & Dev Overlay
148148
149- [ ] Create `packages/errors/` with standard package structure
150- [ ] Implement `defineErrorBoundary()`
151- [ ] Implement dev overlay HTML
152- [ ] Implement production fallback pages
153- [ ] Write tests
154- [ ] Add to workspace
149- [x] Create `packages/errors/` with standard package structure
150- [x] Implement `defineErrorBoundary()`
151- [x] Implement dev overlay HTML
152- [x] Implement production fallback pages
153- [x] Write tests
154- [x] Add to workspace
155155
156156### 14. `@stacksjs/image` — Image Optimization
157157
158- [ ] Create `packages/image/` with standard package structure
159- [ ] Implement responsive image generation
160- [ ] Implement WebP/AVIF conversion
161- [ ] Implement `@img` directive
162- [ ] Write tests
163- [ ] Add to workspace
158- [x] Create `packages/image/` with standard package structure
159- [x] Implement responsive image generation
160- [x] Implement WebP/AVIF conversion
161- [x] Implement `@img` directive
162- [x] Write tests
163- [x] Add to workspace
164164
165165---
166166
@@ -168,54 +168,54 @@
168168
169169### 15. `@stacksjs/realtime` — WebSocket Channels + SSE
170170
171- [ ] Create `packages/realtime/` with standard package structure
172- [ ] Implement WebSocket channel management
173- [ ] Implement SSE fallback
174- [ ] Implement `useBroadcast()` composable
175- [ ] Write tests
176- [ ] Add to workspace
171- [x] Create `packages/realtime/` with standard package structure
172- [x] Implement WebSocket channel management
173- [x] Implement SSE fallback
174- [x] Implement `useBroadcast()` composable
175- [x] Write tests
176- [x] Add to workspace
177177
178178### 16. `@stacksjs/queue` — Background Jobs
179179
180- [ ] Create `packages/queue/` with standard package structure
181- [ ] Implement SQLite-backed job queue
182- [ ] Implement `defineJob()` and `dispatch()`
183- [ ] Implement retry logic and dead letter queue
184- [ ] Write tests
185- [ ] Add to workspace
180- [x] Create `packages/queue/` with standard package structure
181- [x] Implement SQLite-backed job queue
182- [x] Implement `defineJob()` and `dispatch()`
183- [x] Implement retry logic and dead letter queue
184- [x] Write tests
185- [x] Add to workspace
186186
187187### 17. `@stacksjs/search` — Full-Text Search
188188
189- [ ] Create `packages/search/` with standard package structure
190- [ ] Implement SQLite FTS5 driver
191- [ ] Implement `defineSearchable()` and `search()`
192- [ ] Write tests
193- [ ] Add to workspace
189- [x] Create `packages/search/` with standard package structure
190- [x] Implement SQLite FTS5 driver
191- [x] Implement `defineSearchable()` and `search()`
192- [x] Write tests
193- [x] Add to workspace
194194
195195### 18. `@stacksjs/ai` — LLM Integration
196196
197- [ ] Create `packages/ai/` with standard package structure
198- [ ] Implement `useAI()` with provider adapters
199- [ ] Implement streaming support
200- [ ] Write tests
201- [ ] Add to workspace
197- [x] Create `packages/ai/` with standard package structure
198- [x] Implement `useAI()` with provider adapters
199- [x] Implement streaming support
200- [x] Write tests
201- [x] Add to workspace
202202
203203### 19. `@stacksjs/cms` — File-Based Content Collections
204204
205- [ ] Create `packages/cms/` with standard package structure
206- [ ] Implement `defineCollection()` with typed schemas
207- [ ] Implement `getContent()` and collection queries
208- [ ] Write tests
209- [ ] Add to workspace
205- [x] Create `packages/cms/` with standard package structure
206- [x] Implement `defineCollection()` with typed schemas
207- [x] Implement `getContent()` and collection queries
208- [x] Write tests
209- [x] Add to workspace
210210
211211### 20. `@stacksjs/analytics` — Privacy-Friendly Analytics
212212
213- [ ] Create `packages/analytics/` with standard package structure
214- [ ] Implement SQLite-backed page view tracking
215- [ ] Implement `@analytics` directive
216- [ ] Implement dashboard queries
217- [ ] Write tests
218- [ ] Add to workspace
213- [x] Create `packages/analytics/` with standard package structure
214- [x] Implement SQLite-backed page view tracking
215- [x] Implement `@analytics` directive
216- [x] Implement dashboard queries
217- [x] Write tests
218- [x] Add to workspace
219219
220220---
221221