@lynnaloo
@lynnaloo
@lynnaloo
@lynnaloo
@lynnaloo
@lynnaloo
@lynnaloo
@lynnaloo
@lynnaloo
@lynnaloo
@lynnaloo
@lynnaloo
@lynnaloo
Stateless functions running in containers managed by a service provider (not you!).
@lynnaloo
@lynnaloo
@lynnaloo
@lynnaloo
@lynnaloo
@lynnaloo
@lynnaloo
@lynnaloo
# Install serverless cli
$ npm install serverless -g
# Create AWS Service
$ serverless create --template aws-nodejs --path cat-name-service
# Change into the service directory
$ cd cat-name-service
# Deploy to cloud provider
$ serverless deploy -v
cat-name-service/
package.json
serverless.yml
handler.js
dog-name-service/
package.json
serverless.yml
handler.js
@lynnaloo
#serverless.yml
service: cat-name-service
provider:
name: aws
runtime: nodejs6.10
functions:
catName:
handler: handler.getCatName
events:
- http:
path: cats/name
method: get
@lynnaloo
'use strict';
const catNames = require('cat-names');
function getCatName(event, context, callback) {
callback(null, { payload: `Your cat name is ${catNames.random()}.` });
}
module.exports.getCatName;
@lynnaloo
@lynnaloo
'use strict';
const catNames = require('cat-names');
const AmazonDb = require('amazon-db-module');
function getCatName(event, context, callback) {
const amazonDb = new AmazonDb();
const catName = catNames.random();
amazonDb.update(catName);
callback(null, { payload: `Your cat name is ${catName}.` });
}
module.exports.getCatName;
'use strict';
const catNames = require('cat-names');
const GoogleDb = require('google-db-module');
function getCatName(request, response) {
const googleDb = new GoogleDb();
const catName = catNames.random();
googleDb.update(catName);
return response.status(200).send(`Your cat name is ${catName}.`);
}
module.exports.getCatName;
@lynnaloo
@lynnaloo
github.com/lynnaloo/beatlemania
@lynnaloo