Skip to content

Commit 04508df

Browse files
author
Hidetaka Okamoto
committed
fix: reflect-metadata
1 parent d69b057 commit 04508df

File tree

4 files changed

+81
-6
lines changed

4 files changed

+81
-6
lines changed

__tests__/index.test.ts

Lines changed: 73 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,76 @@
11

2-
import func from '../libs/index'
2+
import {
3+
ServerlessNestjsApplicationFactory
4+
} from '../libs/index'
5+
import { APIGatewayProxyEvent, Context } from 'aws-lambda'
36

4-
describe('dummy', () => {
5-
it('test', () => {
6-
expect(func('John')).toEqual('Hello John !')
7-
})
7+
const event = {
8+
requestId: 'offlineContext_requestId_ck74ytlnx000midk328eoe82y',
9+
requestTimeEpoch: 1582821111007,
10+
httpMethod: 'GET',
11+
path: '/server',
12+
stage: 'development',
13+
resourcePath: '/{proxy*}',
14+
hostname: 'okamotoakanombp.lan',
15+
pid: 48613,
16+
level: 'INFO',
17+
body: null,
18+
headers: {
19+
Host: 'localhost:3000',
20+
'User-Agent': 'curl/7.64.1',
21+
Accept: '*/*'
22+
},
23+
multiValueHeaders: {
24+
Host: [
25+
'localhost:3000'
26+
],
27+
'User-Agent': [
28+
'curl/7.64.1'
29+
],
30+
Accept: [
31+
'*/*'
32+
]
33+
},
34+
multiValueQueryStringParameters: null,
35+
pathParameters: {
36+
proxy: 'server'
37+
},
38+
queryStringParameters: null,
39+
requestContext: {
40+
accountId: 'offlineContext_accountId',
41+
apiId: 'offlineContext_apiId',
42+
authorizer: {
43+
principalId: 'offlineContext_authorizer_principalId'
44+
},
45+
httpMethod: 'GET',
46+
identity: {
47+
accountId: 'offlineContext_accountId',
48+
apiKey: 'offlineContext_apiKey',
49+
caller: 'offlineContext_caller',
50+
cognitoAuthenticationProvider: 'offlineContext_cognitoAuthenticationProvider',
51+
cognitoAuthenticationType: 'offlineContext_cognitoAuthenticationType',
52+
cognitoIdentityId: 'offlineContext_cognitoIdentityId',
53+
cognitoIdentityPoolId: 'offlineContext_cognitoIdentityPoolId',
54+
sourceIp: '127.0.0.1',
55+
user: 'offlineContext_user',
56+
userAgent: 'curl/7.64.1',
57+
userArn: 'offlineContext_userArn'
58+
},
59+
protocol: 'HTTP/1.1',
60+
requestId: 'offlineContext_requestId_ck74ytlnx000midk328eoe82y',
61+
requestTimeEpoch: 1582821111007,
62+
resourceId: 'offlineContext_resourceId',
63+
resourcePath: '/{proxy*}',
64+
stage: 'development'
65+
},
66+
resource: '/{proxy*}',
67+
stageVariables: null,
68+
isOffline: true
69+
} as any as APIGatewayProxyEvent
70+
71+
describe('ServerlessNestjsApplicationFactory', () => {
72+
it('test', async () => {
73+
const app = new ServerlessNestjsApplicationFactory({})
74+
expect(await app.create(event, {} as Context)).toHaveReturned()
75+
})
876
})

libs/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { Server } from 'http'
44
import { ExpressAdapter } from '@nestjs/platform-express'
55
import * as serverless from 'aws-serverless-express'
66
import express from 'express'
7+
import 'reflect-metadata'
78
import { APIGatewayProxyEvent, Context, APIGatewayEvent } from 'aws-lambda'
89

910
let cachedServer: Server

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@
9292
"@nestjs/core": "^6.11.8",
9393
"@nestjs/platform-express": "^6.11.8",
9494
"aws-serverless-express": "^3.3.6",
95-
"express": "^4.17.1"
95+
"express": "^4.17.1",
96+
"reflect-metadata": "^0.1.13"
9697
}
9798
}

yarn.lock

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5603,6 +5603,11 @@ redent@^2.0.0:
56035603
indent-string "^3.0.0"
56045604
strip-indent "^2.0.0"
56055605

5606+
reflect-metadata@^0.1.13:
5607+
version "0.1.13"
5608+
resolved "https://registry.yarnpkg.com/reflect-metadata/-/reflect-metadata-0.1.13.tgz#67ae3ca57c972a2aa1642b10fe363fe32d49dc08"
5609+
integrity sha512-Ts1Y/anZELhSsjMcU605fU9RE4Oi3p5ORujwbIKXfWa+0Zxs510Qrmrce5/Jowq3cHSZSJqBjypxmHarc+vEWg==
5610+
56065611
regenerator-runtime@^0.10.5:
56075612
version "0.10.5"
56085613
resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.10.5.tgz#336c3efc1220adcedda2c9fab67b5a7955a33658"

0 commit comments

Comments
 (0)