Skip to content

Commit 2c4e8b2

Browse files
authored
API response helpers (#7)
* Add API Gateway response utilities and tests * Bump version to 0.2.0-alpha.4 and add prepublish script * Update API response examples and add API Gateway Responses guide * Update documentation: rename "Related Guides" to "Further reading" and enhance links in API Gateway and Logging guides
1 parent 4dd967d commit 2c4e8b2

File tree

8 files changed

+1218
-14
lines changed

8 files changed

+1218
-14
lines changed

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,16 +49,16 @@ export const handler = async (event: any, context: any) => {
4949
### API Response Example
5050

5151
```typescript
52-
import { success, badRequest } from '@leanstacks/lambda-utils';
52+
import { ok, badRequest } from '@leanstacks/lambda-utils';
5353

54-
export const handler = async (event: any) => {
54+
export const handler = async (event: APIGatewayProxyEvent) => {
5555
if (!event.body) {
56-
return badRequest({ message: 'Body is required' });
56+
return badRequest('Body is required');
5757
}
5858

5959
// Process request
6060

61-
return success({ message: 'Request processed successfully' });
61+
return ok({ message: 'Request processed successfully' });
6262
};
6363
```
6464

@@ -108,10 +108,10 @@ logger.error({ message: 'Operation failed', error: err.message });
108108
Generate properly formatted responses for API Gateway:
109109

110110
```typescript
111-
import { success, error, created, badRequest } from '@leanstacks/lambda-utils';
111+
import { ok, created, badRequest } from '@leanstacks/lambda-utils';
112112

113-
export const handler = async (event: any) => {
114-
return success({
113+
export const handler = async (event: APIGatewayProxyEvent) => {
114+
return ok({
115115
data: { id: '123', name: 'Example' },
116116
});
117117
};

0 commit comments

Comments
 (0)