-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor api response pattern (#11865)
- Loading branch information
Showing
28 changed files
with
1,078 additions
and
724 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,20 @@ | ||
import handler from "../handler-lib"; | ||
import dynamoDb from "../../utils/dynamo/dynamodb-lib"; | ||
// types | ||
import { StatusCodes } from "../../utils/types"; | ||
// utils | ||
import { error } from "../../utils/constants/constants"; | ||
import { badRequest, ok } from "../../utils/responses/response-lib"; | ||
|
||
export const fetchBanner = handler(async (event, _context) => { | ||
if (!event?.pathParameters?.bannerId!) { | ||
throw new Error(error.NO_KEY); | ||
return badRequest(error.NO_KEY); | ||
} | ||
const params = { | ||
TableName: process.env.BANNER_TABLE_NAME!, | ||
Key: { | ||
key: event?.pathParameters?.bannerId!, | ||
key: event.pathParameters.bannerId, | ||
}, | ||
}; | ||
const response = await dynamoDb.get(params); | ||
|
||
const status = StatusCodes.SUCCESS; | ||
return { status: status, body: response }; | ||
return ok(response); | ||
}); |
Oops, something went wrong.