Skip to content

An example of a ClojureScript backend lambda service using the cljs-lambda template.

License

Notifications You must be signed in to change notification settings

JimLynchCodes/Joke-Generator-Service

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Joke Generator Service

An example of a simple ClojureScript backend lambda service using the cljs-lambda template.

The "Fresh" Folders

This project is supposed to help newbies to get started creating AWS lambda functions with ClojureScript. The fresh folders fresh-cljs-lambda and fresh-serverless-cljs show example projects that are freshly scaffolded from Cljs-lambda and Serverless-Cljs respectively.

Joke Generator

The purpose of joke generator is to randomly return one "joke map" from a vector of maps called jokes. The core logic is in the getRandomJoke function. This function, the def jokes, and the special cljs-lambda macro defgateway all live in the core.cljs file.

(ns joke-generator.core
  (:require [cljs-lambda.macros :refer-macros [defgateway]]))

(def jokes
  [{:setup "A guy walked into a bar..." :punchline "Ouch!" :clean? true}
   {:setup "Can a kangaroo jump higher than a house?" :punchline "Of course, a house doesn’t jump at all!" :clean? true}
   {:setup "Me: Do you think it’s strange to talk to yourself?" :punchLine "Me: No." :clean? true}
   {:setup "What happens to a frog's car when it breaks down?" :punchLine "It gets toad away!" :clean? true}
   {:setup "What do cats eat for breakfast?" :punchLine "Mice krispies!" :clean? true}
   {:setup "What did the egg say before it got boiled?" :punchLine "It's gonna take me awhile to get hard, I just got laid by a chick!" :clean? false}
   ])

(defn getRandomJoke []
  (nth jokes (rand-int (count jokes))))

(defgateway getJoke [event ctx]
  (getRandomJoke))

Usage

See the README inside of the joke-generator directory.

About

An example of a ClojureScript backend lambda service using the cljs-lambda template.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published