Skip to content

Commit

Permalink
Update Pub/Sub samples.
Browse files Browse the repository at this point in the history
  • Loading branch information
jmdobry committed Nov 18, 2016
1 parent 073fe3e commit 4d81dc9
Show file tree
Hide file tree
Showing 35 changed files with 725 additions and 995 deletions.
1 change: 1 addition & 0 deletions appengine/loopback/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/client/
3 changes: 3 additions & 0 deletions appengine/loopback/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "loopback"
}
2 changes: 0 additions & 2 deletions appengine/loopback/.jshintignore

This file was deleted.

21 changes: 0 additions & 21 deletions appengine/loopback/.jshintrc

This file was deleted.

5 changes: 0 additions & 5 deletions appengine/loopback/client/index.html

This file was deleted.

8 changes: 8 additions & 0 deletions appengine/loopback/common/models/message.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module.exports = function(Message) {
Message.greet = function(msg, cb) {
process.nextTick(function() {
msg = msg || 'hello';
cb(null, 'Sender says ' + msg + ' to receiver');
});
};
};
24 changes: 24 additions & 0 deletions appengine/loopback/common/models/message.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"name": "Message",
"base": "Model",
"properties": {},
"methods": {
"greet": {
"isStatic": true,
"accepts": [{
"arg": "msg",
"type": "string",
"http": {
"source": "query"
}
}],
"returns": {
"arg": "greeting",
"type": "string"
},
"http": {
"verb": "get"
}
}
}
}
18 changes: 0 additions & 18 deletions appengine/loopback/common/models/person.js

This file was deleted.

23 changes: 0 additions & 23 deletions appengine/loopback/common/models/person.json

This file was deleted.

29 changes: 18 additions & 11 deletions appengine/loopback/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,26 @@
"engines": {
"node": ">=4.3.2"
},
"main": "server/server.js",
"scripts": {
"pretest": "jshint .",
"start": "node server/server.js"
"lint": "eslint .",
"start": "node .",
"posttest": "npm run lint && nsp check"
},
"dependencies": {
"compression": "1.0.3",
"cors": "2.5.2",
"errorhandler": "1.1.1",
"jshint": "2.5.6",
"loopback": "2.14.0",
"loopback-boot": "2.6.5",
"loopback-datasource-juggler": "2.19.0",
"loopback-explorer": "1.1.0",
"serve-favicon": "2.0.1"
"compression": "^1.0.3",
"cors": "^2.5.2",
"helmet": "^1.3.0",
"loopback-boot": "^2.6.5",
"loopback-component-explorer": "^2.4.0",
"serve-favicon": "^2.0.1",
"strong-error-handler": "^1.0.1",
"loopback-datasource-juggler": "^2.39.0",
"loopback": "^2.22.0"
},
"devDependencies": {
"eslint": "^2.13.1",
"eslint-config-loopback": "^4.0.0",
"nsp": "^2.1.0"
}
}
2 changes: 2 additions & 0 deletions appengine/loopback/server/boot/authentication.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

module.exports = function enableAuthentication(server) {
// enable authentication
server.enableAuth();
Expand Down
27 changes: 0 additions & 27 deletions appengine/loopback/server/boot/explorer.js

This file was deleted.

4 changes: 0 additions & 4 deletions appengine/loopback/server/boot/rest-api.js

This file was deleted.

8 changes: 8 additions & 0 deletions appengine/loopback/server/boot/root.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
'use strict';

module.exports = function(server) {
// Install a `/` route that returns server status
var router = server.loopback.Router();
router.get('/', server.loopback.status());
server.use(router);
};
5 changes: 5 additions & 0 deletions appengine/loopback/server/component-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"loopback-component-explorer": {
"mountPath": "/explorer"
}
}
10 changes: 3 additions & 7 deletions appengine/loopback/server/config.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
{
"restApiRoot": "/api",
"host": "0.0.0.0",
"port": 8080,
"port": 3000,
"remoting": {
"context": {
"enableHttpContext": false
},
"context": false,
"rest": {
"normalizeHttpPath": false,
"xml": false
Expand All @@ -19,9 +17,7 @@
"limit": "100kb"
},
"cors": false,
"errorHandler": {
"disableStackTrace": false
}
"handleErrors": false
},
"legacyExplorer": false
}
10 changes: 10 additions & 0 deletions appengine/loopback/server/middleware.development.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"final:after": {
"strong-error-handler": {
"params": {
"debug": true,
"log": true
}
}
}
}
30 changes: 25 additions & 5 deletions appengine/loopback/server/middleware.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,41 @@
"credentials": true,
"maxAge": 86400
}
},
"helmet#xssFilter": {},
"helmet#frameguard": {
"params": [
"deny"
]
},
"helmet#hsts": {
"params": {
"maxAge": 0,
"includeSubdomains": true
}
},
"helmet#hidePoweredBy": {},
"helmet#ieNoOpen": {},
"helmet#noSniff": {},
"helmet#noCache": {
"enabled": false
}
},
"session": {},
"auth": {},
"parse": {},
"routes": {},
"files": {
"loopback#static": {
"params": "$!../client"
"routes": {
"loopback#rest": {
"paths": [
"${restApiRoot}"
]
}
},
"files": {},
"final": {
"loopback#urlNotFound": {}
},
"final:after": {
"errorhandler": {}
"strong-error-handler": {}
}
}
5 changes: 2 additions & 3 deletions appengine/loopback/server/model-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@
"dataSource": "db",
"public": false
},
"person": {
"dataSource": "db",
"public": true
"Message": {
"dataSource": null
}
}
29 changes: 8 additions & 21 deletions appengine/loopback/server/server.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,5 @@
// 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.

'use strict';

// [START server]
var loopback = require('loopback');
var boot = require('loopback-boot');

Expand All @@ -23,20 +9,21 @@ app.start = function() {
// start the web server
return app.listen(function() {
app.emit('started');
console.log('Web server listening at: %s', app.get('url'));
var baseUrl = app.get('url').replace(/\/$/, '');
console.log('Web server listening at: %s', baseUrl);
if (app.get('loopback-component-explorer')) {
var explorerPath = app.get('loopback-component-explorer').mountPath;
console.log('Browse your REST API at %s%s', baseUrl, explorerPath);
}
});
};

// Bootstrap the application, configure models, datasources and middleware.
// Sub-apps like REST API are mounted via boot scripts.
boot(app, __dirname, function(err) {
if (err) {
throw err;
}
if (err) throw err;

// start the server if `$ node server.js`
if (require.main === module) {
if (require.main === module)
app.start();
}
});
// [START server]
2 changes: 1 addition & 1 deletion appengine/system-test/all.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ var sampleTests = [
dir: 'appengine/loopback',
cmd: 'node',
args: ['server/server.js'],
msg: 'LoopBack.js on Google App Engine.',
msg: 'started',
code: 304
},
{
Expand Down
6 changes: 3 additions & 3 deletions logging/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
"system-test": "cd ..; npm run st -- logging/system-test/*.test.js"
},
"dependencies": {
"@google-cloud/logging": "0.5.0",
"@google-cloud/storage": "0.4.0",
"@google-cloud/logging": "0.5.1",
"@google-cloud/storage": "0.5.0",
"express": "4.14.0",
"fluent-logger": "2.0.1",
"fluent-logger": "2.2.0",
"yargs": "6.4.0"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion logging/system-test/quickstart.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ describe(`logging:quickstart`, () => {

const log = logging.log(logName);
const text = `Hello, world!`;
const entry = log.entry({ type: `global` }, text);
const entry = log.entry({ resource: { type: `global` } }, text);
log.write(entry, (err, apiResponse) => {
_callback(err, apiResponse);
assert.ifError(err);
Expand Down
Loading

0 comments on commit 4d81dc9

Please sign in to comment.