index.ic 939 B

123456789101112131415161718192021222324252627282930313233343536
  1. from iclab import simple
  2. from . import assets
  3. @resource
  4. def brick(
  5. community_name,
  6. slack_url,
  7. slack_token,
  8. invite_token="",
  9. recaptcha_site_key="",
  10. recaptcha_secret_key="",
  11. locale="en",
  12. ):
  13. api = simple.api("api", "express", "0.1.2")
  14. func = simple.function(
  15. "func",
  16. "nodejs8.10",
  17. assets["lambda.zip"],
  18. handler="lambda.handler",
  19. memory_size=1024,
  20. timeout=10,
  21. environ=dict(
  22. COMMUNITY_NAME=community_name,
  23. SLACK_URL=slack_url,
  24. SLACK_TOKEN=slack_token,
  25. INVITE_TOKEN=invite_token,
  26. RECAPTCHA_SITE=recaptcha_site_key,
  27. RECAPTCHA_SECRET=recaptcha_secret_key,
  28. LOCALE=locale,
  29. ),
  30. )
  31. func.http(api, "any", "/{proxy+}", binary_media="*/*")
  32. func.http(api, "any", "/", binary_media="*/*")
  33. return dict(api=dict(id=api["api"]["ref"], url=f'{api["url"]}/'))