Created
September 15, 2017 23:39
-
-
Save theburningmonk/ccf0e88adef88a6e3352c91ded9be2da to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
const co = require('co'); | |
const Promise = require('bluebird'); | |
const protobuf = Promise.promisifyAll(require("protobufjs")); | |
const lib = require('./lib'); | |
const fs = require('fs'); | |
module.exports.handler = co.wrap(function* (event, context, callback) { | |
console.log(JSON.stringify(event)); | |
let players = lib.genPlayers(); | |
let root = yield protobuf.loadAsync("functions/player.proto"); | |
let Players = root.lookupType("protodemo.Players"); | |
let message = Players.create(players); | |
let buffer = Players.encode(message).finish(); | |
const response = { | |
statusCode: 200, | |
headers: { 'Content-Type': 'application/x-protobuf' }, | |
body: buffer.toString('base64'), | |
isBase64Encoded: true | |
}; | |
callback(null, response); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment