Skip to content

Commit 49c27b4

Browse files
author
Ryan Miville
committed
make ffi private
1 parent 136641e commit 49c27b4

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

README.md

+8-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Write AWS Lambda functions in Gleam!
77

88
Write your Lambda function as an [http](https://github.com/gleam-lang/http) handler, or accept direct events as normal Gleam types.
99

10-
Glambda works by compiling your Gleam code to JavaScript, and then using the AWS Lambda Node.js runtime to run your code.
10+
Glambda only supports the JavaScript target. Your compiled code uses the AWS Lambda Node.js runtime.
1111

1212
```sh
1313
gleam add glambda
@@ -35,6 +35,7 @@ fn handle_request(
3535
|> promise.resolve
3636
}
3737
38+
// This is the actual function lambda invokes
3839
pub fn handler(event, ctx) {
3940
glambda.http_handler(handle_request)(event, ctx)
4041
}
@@ -65,13 +66,18 @@ fn event_handler(
6566
|> promise.resolve
6667
}
6768
69+
// This is the actual function lambda invokes
6870
pub fn handler(event, ctx) {
6971
glambda.api_gateway_proxy_v2_handler(event_handler)(event, ctx)
7072
}
7173
```
7274

75+
Check out the [examples](https://github.com/ryanmiville/glambda/tree/main/examples) directory for examples of each supported event type, deployable with [SST](https://github.com/sst/sst).
76+
7377
## Supported Events
74-
* `ApiGatewayProxyEventV2`
78+
* `ApiGatewayProxyEventV2` (can be handled directly or as a `Request(Option(String))`)
79+
* `EventBridgeEvent`
80+
* `SqsEvent`
7581

7682
Further documentation can be found at <https://hexdocs.pm/glambda>.
7783

src/glambda.gleam

+6-8
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ pub fn http_handler(
297297
})
298298
}
299299

300-
pub fn create_request(event: ApiGatewayProxyEventV2) -> Request(Option(String)) {
300+
fn create_request(event: ApiGatewayProxyEventV2) -> Request(Option(String)) {
301301
let body = event.body
302302
let method =
303303
event.request_context.http.method
@@ -428,21 +428,19 @@ pub fn sqs_handler(
428428
// --- FFI --------------------------------------------------------------------
429429

430430
@external(javascript, "./glambda_ffi.mjs", "toApiGatewayProxyEventV2")
431-
pub fn to_api_gateway_proxy_event_v2(event: JsEvent) -> ApiGatewayProxyEventV2
431+
fn to_api_gateway_proxy_event_v2(event: JsEvent) -> ApiGatewayProxyEventV2
432432

433433
@external(javascript, "./glambda_ffi.mjs", "fromApiGatewayProxyResultV2")
434-
pub fn from_api_gateway_proxy_result_v2(
435-
result: ApiGatewayProxyResultV2,
436-
) -> JsResult
434+
fn from_api_gateway_proxy_result_v2(result: ApiGatewayProxyResultV2) -> JsResult
437435

438436
@external(javascript, "./glambda_ffi.mjs", "toContext")
439437
fn to_context(ctx: JsContext) -> Context
440438

441439
@external(javascript, "./glambda_ffi.mjs", "toEventBridgeEvent")
442-
pub fn to_eventbridge_event(event: JsEvent) -> EventBridgeEvent
440+
fn to_eventbridge_event(event: JsEvent) -> EventBridgeEvent
443441

444442
@external(javascript, "./glambda_ffi.mjs", "toSqsEvent")
445-
pub fn to_sqs_event(event: JsEvent) -> SqsEvent
443+
fn to_sqs_event(event: JsEvent) -> SqsEvent
446444

447445
@external(javascript, "./glambda_ffi.mjs", "fromSqsBatchResponse")
448-
pub fn from_sqs_batch_response(result: SqsBatchResponse) -> JsResult
446+
fn from_sqs_batch_response(result: SqsBatchResponse) -> JsResult

0 commit comments

Comments
 (0)