forked from mongodb/mongo-ruby-driver
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.rb
28 lines (23 loc) · 830 Bytes
/
app.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# frozen_string_literal: true
require 'mongo'
require 'faas_test/runner'
# Helpful resources:
# https://dev.to/aws-builders/building-aws-ruby-lambdas-that-require-gems-with-native-extension-17h
# Parameters
# ----------
# event: Hash, required
# API Gateway Lambda Proxy Input Format
# Event doc: https://docs.aws.amazon.com/apigateway/latest/developerguide/set-up-lambda-proxy-integrations.html#api-gateway-simple-proxy-for-lambda-input-format
#
# context: object, required
# Lambda Context runtime methods and attributes
# Context doc: https://docs.aws.amazon.com/lambda/latest/dg/ruby-context.html
def lambda_handler(event:, context:)
client = Mongo::Client.new(ENV['MONGODB_URI'])
runner = FaaSTest::Runner.new(client)
results = runner.run
{
statusCode: 200,
body: results.to_json
}
end