lambder 1.0.147 → 2.0.2
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/Readme.md +355 -410
- package/dist/Lambder.d.ts +47 -21
- package/dist/Lambder.js +79 -24
- package/dist/LambderApiContract.d.ts +10 -42
- package/dist/LambderApiContract.js +2 -22
- package/dist/LambderCaller.js +2 -2
- package/dist/LambderMSW.js +0 -4
- package/dist/LambderResolver.d.ts +16 -17
- package/dist/LambderResponseBuilder.d.ts +2 -3
- package/dist/LambderResponseBuilder.js +1 -3
- package/dist/LambderUtils.js +1 -3
- package/dist/index.d.ts +1 -1
- package/docs/LAMBDER_MSW.md +6 -6
- package/docs/TYPE_SAFE_QUICK_START.md +54 -177
- package/examples/msw-testing-example.ts +36 -33
- package/examples/secure-session-example.ts +50 -34
- package/examples/zod-chained-api-example.ts +63 -0
- package/package.json +3 -2
- package/src/Lambder.ts +124 -83
- package/src/LambderApiContract.ts +7 -50
- package/src/LambderCaller.ts +2 -2
- package/src/LambderMSW.ts +0 -7
- package/src/LambderResolver.ts +21 -24
- package/src/LambderResponseBuilder.ts +4 -7
- package/src/LambderUtils.ts +1 -3
- package/src/index.ts +0 -3
- package/tests/UNTESTED_FEATURES.md +263 -0
- package/tests/error-handling.test.ts +585 -0
- package/tests/hooks.test.ts +561 -0
- package/tests/output-type-runtime.test.ts +80 -64
- package/tests/routes.test.ts +542 -0
- package/tests/session.test.ts +38 -24
- package/tests/type-safety.test.ts +147 -97
- package/tests/use-plugin.test.ts +437 -0
- package/OUTPUT_TYPE_ENFORCEMENT_SUMMARY.md +0 -90
- package/examples/output-type-enforcement-example.ts +0 -218
- package/examples/simplified-typed-api-example.ts +0 -365
- package/examples/test-output-type-enforcement.ts +0 -101
- package/test-type-enforcement.ts +0 -111
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
# Untested Features in Lambder
|
|
2
|
+
|
|
3
|
+
This document lists features that currently lack test coverage.
|
|
4
|
+
|
|
5
|
+
## ✅ Currently Tested Features
|
|
6
|
+
|
|
7
|
+
Based on existing test files:
|
|
8
|
+
|
|
9
|
+
1. **Type Safety** (`type-safety.test.ts`)
|
|
10
|
+
- LambderCaller type inference
|
|
11
|
+
- Lambder API type safety
|
|
12
|
+
- Input/output type enforcement
|
|
13
|
+
- Complex type patterns
|
|
14
|
+
- Type inference from contracts
|
|
15
|
+
|
|
16
|
+
2. **Session Management** (`session.test.ts`)
|
|
17
|
+
- Session creation, fetching, updating, deletion
|
|
18
|
+
- Session regeneration
|
|
19
|
+
- Session security (CSRF, validation)
|
|
20
|
+
- Session type safety
|
|
21
|
+
- Sliding expiration
|
|
22
|
+
|
|
23
|
+
3. **Output Type Runtime** (`output-type-runtime.test.ts`)
|
|
24
|
+
- Runtime validation of API outputs
|
|
25
|
+
- Zod schema enforcement at runtime
|
|
26
|
+
- API response format validation
|
|
27
|
+
|
|
28
|
+
4. **Plugin System** (`use-plugin.test.ts`)
|
|
29
|
+
- Basic plugin usage
|
|
30
|
+
- Multiple plugin chaining
|
|
31
|
+
- Plugin type accumulation
|
|
32
|
+
- Nested plugins
|
|
33
|
+
- Plugin reusability
|
|
34
|
+
|
|
35
|
+
## ❌ Untested Features (Needs Test Coverage)
|
|
36
|
+
|
|
37
|
+
### 1. Routes (`addRoute`, `addSessionRoute`)
|
|
38
|
+
**Priority: HIGH**
|
|
39
|
+
|
|
40
|
+
- [x] Basic route matching (string paths)
|
|
41
|
+
- [ ] Path parameter extraction (e.g., `/user/:userId`)
|
|
42
|
+
- [ ] RegExp route matching
|
|
43
|
+
- [ ] Function-based conditional routing
|
|
44
|
+
- [ ] Session-protected routes (`addSessionRoute`)
|
|
45
|
+
- [ ] Route priority/ordering
|
|
46
|
+
- [ ] Wildcard routes
|
|
47
|
+
|
|
48
|
+
**Suggested test file:** `tests/routes.test.ts`
|
|
49
|
+
|
|
50
|
+
### 2. Hooks System
|
|
51
|
+
**Priority: HIGH**
|
|
52
|
+
|
|
53
|
+
- [ ] `beforeRender` hook execution
|
|
54
|
+
- [ ] `afterRender` hook execution
|
|
55
|
+
- [ ] `fallback` hook execution
|
|
56
|
+
- [ ] `created` hook execution
|
|
57
|
+
- [ ] Hook priority ordering
|
|
58
|
+
- [ ] Multiple hooks of same type
|
|
59
|
+
- [ ] Hook error handling
|
|
60
|
+
- [ ] Context modification in hooks
|
|
61
|
+
- [ ] Response modification in hooks
|
|
62
|
+
|
|
63
|
+
**Suggested test file:** `tests/hooks.test.ts`
|
|
64
|
+
|
|
65
|
+
### 3. Error Handling
|
|
66
|
+
**Priority: HIGH**
|
|
67
|
+
|
|
68
|
+
- [ ] `setGlobalErrorHandler` functionality
|
|
69
|
+
- [ ] Error handling with context available
|
|
70
|
+
- [ ] Error handling with null context
|
|
71
|
+
- [ ] Custom error responses
|
|
72
|
+
- [ ] Error in API handlers
|
|
73
|
+
- [ ] Error in route handlers
|
|
74
|
+
- [ ] Error in hooks
|
|
75
|
+
- [ ] Error log accumulation
|
|
76
|
+
|
|
77
|
+
**Suggested test file:** `tests/error-handling.test.ts`
|
|
78
|
+
|
|
79
|
+
### 4. Fallback Handlers
|
|
80
|
+
**Priority: MEDIUM**
|
|
81
|
+
|
|
82
|
+
- [ ] `setRouteFallbackHandler` for unmatched routes
|
|
83
|
+
- [ ] `setApiFallbackHandler` for unmatched APIs
|
|
84
|
+
- [ ] Default fallback behavior (no handler set)
|
|
85
|
+
- [ ] Fallback handler with custom responses
|
|
86
|
+
|
|
87
|
+
**Suggested test file:** `tests/fallback-handlers.test.ts`
|
|
88
|
+
|
|
89
|
+
### 5. Response Methods (LambderResolver/LambderResponseBuilder)
|
|
90
|
+
**Priority: MEDIUM**
|
|
91
|
+
|
|
92
|
+
- [x] `res.api()` - tested in output-type-runtime
|
|
93
|
+
- [ ] `res.json()`
|
|
94
|
+
- [ ] `res.html()`
|
|
95
|
+
- [ ] `res.xml()`
|
|
96
|
+
- [ ] `res.raw()`
|
|
97
|
+
- [ ] `res.file()` with fallback
|
|
98
|
+
- [ ] `res.fileBase64()`
|
|
99
|
+
- [ ] `res.ejsFile()`
|
|
100
|
+
- [ ] `res.ejsTemplate()`
|
|
101
|
+
- [ ] `res.status301()` (redirects)
|
|
102
|
+
- [ ] `res.status404()`
|
|
103
|
+
- [ ] `res.cors()`
|
|
104
|
+
- [ ] `res.die.*` methods (skip afterRender hooks)
|
|
105
|
+
- [ ] Custom headers in responses
|
|
106
|
+
- [ ] `setHeader()` and `addHeader()` in context
|
|
107
|
+
|
|
108
|
+
**Suggested test file:** `tests/response-methods.test.ts`
|
|
109
|
+
|
|
110
|
+
### 6. CORS Support
|
|
111
|
+
**Priority: MEDIUM**
|
|
112
|
+
|
|
113
|
+
- [ ] `enableCors(true)` functionality
|
|
114
|
+
- [ ] CORS headers in responses
|
|
115
|
+
- [ ] OPTIONS request handling (preflight)
|
|
116
|
+
- [ ] CORS disabled behavior
|
|
117
|
+
|
|
118
|
+
**Suggested test file:** `tests/cors.test.ts`
|
|
119
|
+
|
|
120
|
+
### 7. API Version Management
|
|
121
|
+
**Priority: MEDIUM**
|
|
122
|
+
|
|
123
|
+
- [ ] Setting `apiVersion` in constructor
|
|
124
|
+
- [ ] Version mismatch detection
|
|
125
|
+
- [ ] Version expired response
|
|
126
|
+
- [ ] Client version validation
|
|
127
|
+
- [ ] Version header handling
|
|
128
|
+
|
|
129
|
+
**Suggested test file:** `tests/api-versioning.test.ts`
|
|
130
|
+
|
|
131
|
+
### 8. Context Variables
|
|
132
|
+
**Priority: LOW**
|
|
133
|
+
|
|
134
|
+
- [ ] `ctx.host` extraction
|
|
135
|
+
- [ ] `ctx.path` extraction
|
|
136
|
+
- [ ] `ctx.pathParams` for route parameters
|
|
137
|
+
- [ ] `ctx.get` (query parameters)
|
|
138
|
+
- [ ] `ctx.post` (POST body parsing)
|
|
139
|
+
- [ ] `ctx.cookie` parsing
|
|
140
|
+
- [ ] `ctx.headers` access
|
|
141
|
+
- [ ] `ctx.event` (raw Lambda event)
|
|
142
|
+
- [ ] `ctx.lambdaContext` (raw Lambda context)
|
|
143
|
+
- [ ] Base64 encoded body handling
|
|
144
|
+
- [ ] URL-encoded form data parsing
|
|
145
|
+
|
|
146
|
+
**Suggested test file:** `tests/context-extraction.test.ts`
|
|
147
|
+
|
|
148
|
+
### 9. LambderCaller Features
|
|
149
|
+
**Priority: MEDIUM**
|
|
150
|
+
|
|
151
|
+
- [x] Basic API calls - tested in type-safety
|
|
152
|
+
- [ ] `apiRaw()` method
|
|
153
|
+
- [ ] `fetchStartedHandler` callback
|
|
154
|
+
- [ ] `fetchEndedHandler` callback
|
|
155
|
+
- [ ] `errorMessageHandler` callback
|
|
156
|
+
- [ ] `activeFetchList` tracking
|
|
157
|
+
- [ ] Error response handling
|
|
158
|
+
- [ ] Session expired handling
|
|
159
|
+
- [ ] Version expired handling
|
|
160
|
+
- [ ] Not authorized handling
|
|
161
|
+
- [ ] Custom headers in requests
|
|
162
|
+
- [ ] CORS mode handling
|
|
163
|
+
|
|
164
|
+
**Suggested test file:** `tests/lambder-caller.test.ts`
|
|
165
|
+
|
|
166
|
+
### 10. LambderMSW Features
|
|
167
|
+
**Priority: MEDIUM**
|
|
168
|
+
|
|
169
|
+
- [ ] `mockApi()` basic functionality
|
|
170
|
+
- [ ] `mockSessionExpired()` helper
|
|
171
|
+
- [ ] `mockNotAuthorized()` helper
|
|
172
|
+
- [ ] `mockVersionExpired()` helper
|
|
173
|
+
- [ ] Custom mock options (delay, message, errorMessage)
|
|
174
|
+
- [ ] Type safety in mocks
|
|
175
|
+
- [ ] Multiple API mocks
|
|
176
|
+
- [ ] Mock priority/ordering
|
|
177
|
+
|
|
178
|
+
**Suggested test file:** `tests/lambder-msw.test.ts`
|
|
179
|
+
|
|
180
|
+
### 11. EJS Template Rendering
|
|
181
|
+
**Priority: LOW**
|
|
182
|
+
|
|
183
|
+
- [ ] `res.ejsFile()` rendering
|
|
184
|
+
- [ ] `res.ejsTemplate()` rendering
|
|
185
|
+
- [ ] Template `page` variable
|
|
186
|
+
- [ ] Partial `partial` variable
|
|
187
|
+
- [ ] `include()` function in templates
|
|
188
|
+
- [ ] Template error handling
|
|
189
|
+
- [ ] Custom headers with EJS
|
|
190
|
+
|
|
191
|
+
**Suggested test file:** `tests/ejs-templates.test.ts`
|
|
192
|
+
|
|
193
|
+
### 12. File Serving
|
|
194
|
+
**Priority: LOW**
|
|
195
|
+
|
|
196
|
+
- [ ] Static file serving with `res.file()`
|
|
197
|
+
- [ ] Fallback file (e.g., index.html)
|
|
198
|
+
- [ ] MIME type detection
|
|
199
|
+
- [ ] Base64 file responses
|
|
200
|
+
- [ ] File not found handling
|
|
201
|
+
- [ ] Public path configuration
|
|
202
|
+
|
|
203
|
+
**Suggested test file:** `tests/file-serving.test.ts`
|
|
204
|
+
|
|
205
|
+
### 13. Utility Methods
|
|
206
|
+
**Priority: LOW**
|
|
207
|
+
|
|
208
|
+
- [ ] `lambder.utils.*` methods
|
|
209
|
+
- [ ] `getSessionController()` helper
|
|
210
|
+
- [ ] `getResponseBuilder()` helper
|
|
211
|
+
- [ ] `getHandler()` export
|
|
212
|
+
|
|
213
|
+
**Suggested test file:** `tests/utilities.test.ts`
|
|
214
|
+
|
|
215
|
+
### 14. Edge Cases & Integration
|
|
216
|
+
**Priority: LOW**
|
|
217
|
+
|
|
218
|
+
- [ ] Multiple simultaneous requests
|
|
219
|
+
- [ ] Race conditions in session management
|
|
220
|
+
- [ ] Large payload handling
|
|
221
|
+
- [ ] Invalid JSON in request body
|
|
222
|
+
- [ ] Missing required fields
|
|
223
|
+
- [ ] Empty/null payloads
|
|
224
|
+
- [ ] Very long session data
|
|
225
|
+
- [ ] Malformed Lambda events
|
|
226
|
+
|
|
227
|
+
**Suggested test file:** `tests/edge-cases.test.ts`
|
|
228
|
+
|
|
229
|
+
## Test Coverage Priorities
|
|
230
|
+
|
|
231
|
+
### Must Have (Before v2.0 stable)
|
|
232
|
+
1. Routes and path parameters
|
|
233
|
+
2. Hooks system
|
|
234
|
+
3. Error handling
|
|
235
|
+
4. Response methods (at least common ones)
|
|
236
|
+
|
|
237
|
+
### Should Have (Before v2.1)
|
|
238
|
+
1. CORS support
|
|
239
|
+
2. API versioning
|
|
240
|
+
3. LambderCaller edge cases
|
|
241
|
+
4. Fallback handlers
|
|
242
|
+
|
|
243
|
+
### Nice to Have (Future releases)
|
|
244
|
+
1. EJS templates
|
|
245
|
+
2. File serving
|
|
246
|
+
3. Edge cases and stress testing
|
|
247
|
+
4. Integration tests
|
|
248
|
+
|
|
249
|
+
## How to Run Tests
|
|
250
|
+
|
|
251
|
+
```bash
|
|
252
|
+
# Run all tests
|
|
253
|
+
npm run test
|
|
254
|
+
|
|
255
|
+
# Run specific test file
|
|
256
|
+
npm run test -- tests/routes.test.ts
|
|
257
|
+
|
|
258
|
+
# Run tests in watch mode
|
|
259
|
+
npm run test -- --watch
|
|
260
|
+
|
|
261
|
+
# Run tests with coverage
|
|
262
|
+
npm run test -- --coverage
|
|
263
|
+
```
|