From 334a216ee504606ca1ba8d476f660c6d79ce8a8e Mon Sep 17 00:00:00 2001 From: Bill Prin Date: Thu, 24 Mar 2016 14:27:13 -0700 Subject: [PATCH] [DO NOT MERGE] Add Leftpad SDK Example --- appengine/leftpad/app.js | 34 ++++++++++++++++++++++++++++++++++ appengine/leftpad/app.yaml | 20 ++++++++++++++++++++ appengine/leftpad/package.json | 20 ++++++++++++++++++++ 3 files changed, 74 insertions(+) create mode 100644 appengine/leftpad/app.js create mode 100644 appengine/leftpad/app.yaml create mode 100644 appengine/leftpad/package.json diff --git a/appengine/leftpad/app.js b/appengine/leftpad/app.js new file mode 100644 index 0000000000..71cc39a635 --- /dev/null +++ b/appengine/leftpad/app.js @@ -0,0 +1,34 @@ +// Copyright 2016, Google, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +'use strict'; + +var express = require('express'); +var leftPadIOSDK = require('left-pad-io-sdk'); + +var app = express(); + +app.get('/', function(req, res) { + leftPadIOSDK.leftPad(res.query.str, res.query.len, res.query.ch).then(function(response){ + console.log(response); // logs the response + res.status(200).send(response); + }) +}); + +// Start the server +var server = app.listen(process.env.PORT || '8080', '0.0.0.0', function() { + console.log('App listening at http://%s:%s', server.address().address, + server.address().port); + console.log('Press Ctrl+C to quit.'); +}); diff --git a/appengine/leftpad/app.yaml b/appengine/leftpad/app.yaml new file mode 100644 index 0000000000..c1c22cd8cb --- /dev/null +++ b/appengine/leftpad/app.yaml @@ -0,0 +1,20 @@ +# Copyright 2015-2016, Google, Inc. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# [START app_yaml] +runtime: nodejs +vm: true + +skip_files: + - ^(.*/)?.*/node_modules/.*$ +# [END app_yaml] diff --git a/appengine/leftpad/package.json b/appengine/leftpad/package.json new file mode 100644 index 0000000000..13334de5f2 --- /dev/null +++ b/appengine/leftpad/package.json @@ -0,0 +1,20 @@ +{ + "name": "appengine-leftpad", + "description": "Simple Leftpad Node.js sample for Google App Engine", + "version": "0.0.1", + "private": true, + "license": "Apache Version 2.0", + "author": "Google Inc.", + "engines": { + "node": "~4.2" + }, + "scripts": { + "start": "node app.js", + "monitor": "nodemon app.js", + "deploy": "gcloud preview app deploy" + }, + "dependencies": { + "express": "^4.13.4", + "left-pad-io-js-sdk": "1.0.1" + } +}