{"id":15285503,"url":"https://github.com/ahrefs/bs-aws-lambda","last_synced_at":"2025-04-13T02:28:49.636Z","repository":{"id":57095686,"uuid":"122269821","full_name":"ahrefs/bs-aws-lambda","owner":"ahrefs","description":"aws lambda bucklescript bindings","archived":false,"fork":false,"pushed_at":"2021-12-03T16:27:38.000Z","size":74,"stargazers_count":38,"open_issues_count":0,"forks_count":8,"subscribers_count":35,"default_branch":"master","last_synced_at":"2025-04-11T20:48:41.271Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Reason","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ahrefs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-02-20T23:28:41.000Z","updated_at":"2023-07-25T14:15:10.000Z","dependencies_parsed_at":"2022-08-22T21:40:29.660Z","dependency_job_id":null,"html_url":"https://github.com/ahrefs/bs-aws-lambda","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ahrefs%2Fbs-aws-lambda","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ahrefs%2Fbs-aws-lambda/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ahrefs%2Fbs-aws-lambda/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ahrefs%2Fbs-aws-lambda/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ahrefs","download_url":"https://codeload.github.com/ahrefs/bs-aws-lambda/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248657592,"owners_count":21140837,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-09-30T15:05:39.747Z","updated_at":"2025-04-13T02:28:49.615Z","avatar_url":"https://github.com/ahrefs.png","language":"Reason","readme":"# bs-aws-lambda\n\n`bs-aws-lambda` is a set of types to use when creating [AWS\nlambda](http://docs.aws.amazon.com/lambda) handlers.\n\nThose types are inspired by the\n[`@types/aws-lambda`](https://www.npmjs.com/package/@types/aws-lambda)\npackage with typescript types.\n\n## Installation\n\n```\nyarn add @ahrefs/bs-aws-lambda\n```\n\nor to follow the master version:\n\n```\nyarn add https://github.com/ahrefs/bs-aws-lambda.git\n```\n\n## Usage\n\nAdd `@ahrefs/bs-aws-lambda` to the `bs-dependencies` of `bsconfig.json`.\n\nThen when you create a function handler for a lambda, you can annotate\nit with one of `AwsLambda.Scheduled.handler`,\n`AwsLambda.Dynamodb.streamHandler`, `AwsLambda.Sns.handler`, etc. This\nway you are sure to expose a function which respect the signature\nexpected by Lambda and you get types information for all the\nparameters this function will receive.\n\n## Example\n\nA full example is documented\n[here](https://tech.ahrefs.com/create-aws-lambda-using-reasonml-and-bucklescript-15a0820ff55b). It\nis using the sources from the [`example`](example) directory.\n\nSimple echo function for the API Gateway. This might seem a little\nverbose compare to a typescript version. But using this package, you\nare sure to handle all the possible cases where a value is actually\nnull or base64 encoded. Plus the returned object given to the callback\nwill always have the expected fields and types.\n\n```reason\nlet handler: AwsLambda.APIGatewayProxy.handler =\n  (event, _context) =\u003e {\n    open AwsLambda.APIGatewayProxy;\n\n    let parameter =\n      event\n      -\u003eEvent.queryStringParametersGet\n      -\u003eJs.Nullable.toOption\n      -\u003eBelt.Option.flatMap(params =\u003e Js.Dict.get(params, \"userid\"));\n\n    switch (parameter) {\n    | Some(userid) =\u003e Js.log2(\"executing lambda for\", userid)\n    | None =\u003e Js.log(\"executing lambda for anonymous user\")\n    };\n\n    let result =\n      switch (event-\u003eEvent.bodyGet-\u003eJs.Nullable.toOption) {\n      | None =\u003e\n        Js.log(\"error: no body available in the request\");\n        result(\n          ~body=`Plain({|{\"status\": \"no body available in the request\"}|}),\n          ~statusCode=400,\n          (),\n        );\n      | Some(body) =\u003e\n        Result.make(\n          ~statusCode=200,\n          ~body,\n          ~isBase64Encoded=event-\u003eEvent.isBase64EncodedGet,\n          (),\n        )\n      };\n\n    Js.Promise.resolve(result);\n  };\n```\n\nThe typescript equivalent of the type annotation is actually more verbose:\n\n```typescript\nexport const handle: Lambda.APIGatewayProxyHandler = async (\n    event: Lambda.APIGatewayEvent,\n    context: Lambda.Context,\n    cb: Lambda.APIGatewayProxyCallback) =\u003e {\n}\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fahrefs%2Fbs-aws-lambda","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fahrefs%2Fbs-aws-lambda","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fahrefs%2Fbs-aws-lambda/lists"}