Building a Serverless “Voter Ipsum” API as Quick as Voting

My Serverless #noServerNovember Submission

Image for post
Image for post
$ npm install serverless -g
$ serverless create --template aws-nodejs --path voter-ipsum
$ cd voter-ipsum
service: voteripsumprovider:
name: aws
runtime: nodejs8.10
functions:
hello:
handler: handler.vote
events:
- http: GET vote
'use strict'const loremIpsum = require('lorem-ipsum')module.exports.vote = (event, context, callback) => {
const output = loremIpsum({
count: 1,
units: 'paragraph',
words: ['go', 'vote', 'today']
})
const response = {
statusCode: 200,
body: JSON.stringify({
"voter-ipsum": output
})
}
callback(null, response)
}
serverless deploy -v

Written by

I develop websites for rock 'n' roll bands and get paid in sex and drugs. Previously Silva Artist Management, SoundCloud, and Songkick. Currently: Available

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store