Skip to content

Commit 7cca18f

Browse files
committed
fix typings on updated api success response
1 parent 574b585 commit 7cca18f

File tree

5 files changed

+18
-4
lines changed

5 files changed

+18
-4
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
44

55
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html)
66

7+
## [1.2.1]  (2019-10-06)
8+
9+
### Fixed
10+
11+
- Added correct type definitions for new API success response method
12+
713
## [1.2.0]  (2019-10-06)
814

915
### Added

examples/ts/app/api.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,15 @@ import 'source-map-support/register';
33

44
export const handler = api(async ({ event, success, error }) => {
55
try {
6-
return success(event);
6+
const replacer = (key, value) => {
7+
switch (key) {
8+
case 'prop-to-ignore':
9+
return undefined;
10+
default:
11+
return value;
12+
}
13+
};
14+
return success(event, replacer);
715
} catch (err) {
816
return error(err);
917
}

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@manwaring/lambda-wrapper",
33
"description": "A lambda handler wrapper to abstract common functionality and provide useful defaults",
4-
"version": "1.2.0",
4+
"version": "1.2.1",
55
"scripts": {
66
"publish-please-dry-run": "publish-please --dry-run",
77
"publish-please": "publish-please",

src/api/wrapper.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export interface ApiSignature {
3535
headers: { [name: string]: string }; // header payload as key-value pairs if exists (otherwise null)
3636
testRequest: boolean; // indicates if this is a test request - looks for a header matching process.env.TEST_REQUEST_HEADER (dynamic from application) or 'Test-Request' (default)
3737
auth: any; // auth context from custom authorizer if exists (otherwise null)
38-
success(payload?: any): void; // returns 200 status with payload
38+
success(payload?: any, replacer?: (this: any, key: string, value: any) => any): void; // returns 200 status with payload
3939
invalid(errors?: string[]): void; // returns 400 status with errors in payload
4040
redirect(url: string): void; // returns 302 redirect with new url
4141
error(error?: any): void; // returns 500 status with error and original request payload

0 commit comments

Comments
 (0)