Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
Lenakh97 committed Jul 2, 2024
1 parent 287cc29 commit 060e9e3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
4 changes: 2 additions & 2 deletions api/res.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import type { APIGatewayProxyResultV2 } from 'aws-lambda'

export const res =
(statusCode: number, options?: { expires: number }) =>
(statusCode: number, options?: { expires: number; contentType?: string }) =>
(body: unknown): APIGatewayProxyResultV2 => ({
statusCode,
headers: {
'Access-Control-Allow-Origin': '*',
'Content-Type': 'application/json',
'Content-Type': options?.contentType ?? 'application/json',
...(options?.expires !== undefined && {
'Cache-Control': `public, max-age=${options.expires}`,
Expires: new Date(
Expand Down
10 changes: 8 additions & 2 deletions lambda/getBasicInformationLambda.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@ export const handler = async (
//Check if iccid is existing
const issuer = identifyIssuer(iccid)
if (issuer === undefined) {
return res(toStatusCode[ErrorType.BadRequest], { expires: 60 })({
return res(toStatusCode[ErrorType.BadRequest], {
expires: 60,
contentType: 'application/problem+json',
})({
type: 'https://example.net/validation-error',
title: "Your request parameters didn't validate.",
'invalid-params': [
Expand All @@ -55,7 +58,10 @@ export const handler = async (
//Check if iccid from a valid issuer
const isValidIccid = validIssuers.includes(issuer.issuerIdentifierNumber)
if (isValidIccid === false) {
return res(toStatusCode[ErrorType.BadRequest], { expires: 60 })({
return res(toStatusCode[ErrorType.BadRequest], {
expires: 60,
contentType: 'application/problem+json',
})({
type: 'https://example.net/validation-error',
title: "Your request parameters didn't validate.",
'invalid-params': [
Expand Down

0 comments on commit 060e9e3

Please sign in to comment.