{"id":15168589,"url":"https://github.com/jonathanstowe/aws-sns-notification","last_synced_at":"2026-01-21T03:32:49.071Z","repository":{"id":66980384,"uuid":"418448852","full_name":"jonathanstowe/AWS-SNS-Notification","owner":"jonathanstowe","description":"Description of an AWS Simple Notification Service message.","archived":false,"fork":false,"pushed_at":"2022-08-07T08:46:38.000Z","size":22,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-15T09:35:23.738Z","etag":null,"topics":["aws","json","message","raku","sns"],"latest_commit_sha":null,"homepage":"","language":"Raku","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"artistic-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jonathanstowe.png","metadata":{"files":{"readme":"README.md","changelog":"Changes","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-10-18T10:20:34.000Z","updated_at":"2021-10-20T11:53:10.000Z","dependencies_parsed_at":"2023-05-16T10:45:38.675Z","dependency_job_id":null,"html_url":"https://github.com/jonathanstowe/AWS-SNS-Notification","commit_stats":{"total_commits":8,"total_committers":1,"mean_commits":8.0,"dds":0.0,"last_synced_commit":"70235c6f1d0d6a67d72161cf23da4bd00d0d6319"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonathanstowe%2FAWS-SNS-Notification","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonathanstowe%2FAWS-SNS-Notification/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonathanstowe%2FAWS-SNS-Notification/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonathanstowe%2FAWS-SNS-Notification/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jonathanstowe","download_url":"https://codeload.github.com/jonathanstowe/AWS-SNS-Notification/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248060459,"owners_count":21041160,"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":["aws","json","message","raku","sns"],"created_at":"2024-09-27T06:23:20.474Z","updated_at":"2026-01-21T03:32:49.037Z","avatar_url":"https://github.com/jonathanstowe.png","language":"Raku","funding_links":[],"categories":[],"sub_categories":[],"readme":"# AWS::SNS::Notification\n\nDescription of an AWS Simple Notification Service message.\n\n[![CI](https://github.com/jonathanstowe/AWS-SNS-Notification/actions/workflows/main.yml/badge.svg)](https://github.com/jonathanstowe/AWS-SNS-Notification/actions/workflows/main.yml)\n\n## Synopsis\n\n```raku\nuse Cro::HTTP::Router;\nuse Cro::HTTP::Server;\nuse AWS::SNS::Notification;\n\n\nmy $app = route {\n    post -\u003e 'sns-message' {\n        # The SNS message has a content-type of 'text/plain' so this will be raw JSON\n        request-body -\u003e $json {\n            my $notification = AWS::SNS::Notification.from-json($json);\n            # Check this is a valid notification\n            if $notification.verify-signature {\n               if $notification.is-notification {\n                   # Do something with the $notification.message\n                   # The format of which depends on the source - an S3 notification will be a JSON String for instance\n               }\n               else {\n                   # This is subscribe or unsubscribe confirmation request\n                   # so perform the confirmation\n                   $notification.respond;\n               }\n            }\n            else {\n                bad-request 'text/plain', 'Fake notification';\n            }\n        }\n    }\n};\n\nmy Cro::Service $service = Cro::HTTP::Server.new(:host\u003c127.0.0.1\u003e, :port\u003c7798\u003e, application =\u003e $app);\n\n$service.start;\n\nreact  { whenever signal(SIGINT) { $service.stop; exit; } }\n\n```\n\nAlternatively you can derive a body parser using [Cro::HTTP::BodyParser::JSONClass](https://github.com/jonathanstowe/Cro-HTTP-BodyParser-JSONClass) :\n\n```raku\nuse Cro::HTTP::Router;\nuse Cro::HTTP::Server;\nuse AWS::SNS::Notification;\nuse Cro::HTTP::BodyParser::JSONClass;\n\nclass SNSBodyParser does Cro::HTTP::BodyParser::JSONClass[AWS::SNS::Notification] {\n\tuse Cro::HTTP::Message;\n    method is-applicable(Cro::HTTP::Message $message --\u003e Bool ) {\n        $message.header('x-amz-sns-message-type').defined \u0026\u0026 $message.header('x-amz-sns-message-id').defined;\n    }\n}\n\n\nmy $app = route {\n    body-parser SNSBodyParser;\n    post -\u003e 'sns-message' {\n        request-body -\u003e $notification {\n            # Check this is a valid notification\n            if $notification.verify-signature {\n               if $notification.is-notification {\n                   # Do something with the $notification.message\n                   # The format of which depends on the source - an S3 notification will be a JSON String for instance\n               }\n               else {\n                   # This is subscribe or unsubscribe confirmation request\n                   # so perform the confirmation\n                   $notification.respond;\n               }\n            }\n            else {\n                bad-request 'text/plain', 'Fake notification';\n            }\n        }\n    }\n};\n\nmy Cro::Service $service = Cro::HTTP::Server.new(:host\u003c127.0.0.1\u003e, :port\u003c7798\u003e, application =\u003e $app);\n\n$service.start;\n\nreact  { whenever signal(SIGINT) { $service.stop; exit; } }\n```\n\n## Description\n\nThis class describes an [AWS Simple Notification Service](https://aws.amazon.com/sns/) message that may be delivered by HTTPS or by a message queue or somesuch.\n\nThe class provides for parsing the JSON payload for the message, verifying the signature of the message against the signing key and responding if necessary to a Subscribe or Unsubscribe confirmation.\n\nThe actual message sent by the source application is accessed through the `.message` accessor - so for instance in the case of an S3 notification this will be a JSON string which will need to be decoded for further processing.\n\n## Installation\n\nAssuming you have a working rakudo installation you can install this with *zef* :\n\n     zef install AWS::SNS::Notification\n\nOr from a local clone of the distribution\n\n     zef install AWS::SNS::Notification\n\n\n## Support\n\nIf you have an feedback/suggestions/patches please send them via [Github](https://github.com/jonathanstowe/AWS-SNS-Notification/issues)\n\n## Licence and Copyright\n\nThis library is free software.  Please see the [LICENCE](LICENCE) file in the distribution for details.\n\n© Jonathan Stowe 2021\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonathanstowe%2Faws-sns-notification","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjonathanstowe%2Faws-sns-notification","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonathanstowe%2Faws-sns-notification/lists"}