Skip to content

Commit 9b10878

Browse files
committed
Merge pull request #42 from GoogleCloudPlatform/bower
Added Bower sample. Closes #24.
2 parents 1801dae + d894fcd commit 9b10878

File tree

11 files changed

+128
-0
lines changed

11 files changed

+128
-0
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ npm-debug.log
33
coverage/
44

55
test/encrypted/nodejs-docs-samples.json
6+
dump.rdb

.jshintignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
appengine/bower/public/bower_components/**
12
appengine/kraken/public/components/**
23
appengine/sails/config/**
34
appengine/sails/tasks/**

appengine/bower/.bowerrc

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"directory": "public/bower_components"
3+
}

appengine/bower/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
public/bower_components/

appengine/bower/README.md

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
## Bower on Google App Engine
2+
3+
> [Bower][1]: A package manager for the web.
4+
5+
Read the [Bower + Express.js on App Engine Tutorial][2] for how to run and
6+
deploy this sample app.
7+
8+
[1]: http://bower.io/
9+
[2]: https://cloud.google.com/nodejs/resources/tools/bower

appengine/bower/app.yaml

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Copyright 2015, Google, Inc.
2+
# Licensed under the Apache License, Version 2.0 (the "License");
3+
# you may not use this file except in compliance with the License.
4+
# You may obtain a copy of the License at
5+
#
6+
# http://www.apache.org/licenses/LICENSE-2.0
7+
#
8+
# Unless required by applicable law or agreed to in writing, software
9+
# distributed under the License is distributed on an "AS IS" BASIS,
10+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
# See the License for the specific language governing permissions and
12+
# limitations under the License.
13+
#
14+
# [START app_yaml]
15+
runtime: nodejs
16+
vm: true
17+
# [END app_yaml]

appengine/bower/bower.json

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"name": "appengine-bower",
3+
"dependencies": {
4+
"jquery": "~2.1.4"
5+
}
6+
}

appengine/bower/package.json

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"name": "appengine-bower",
3+
"description": "An example of running Bower on Google App Engine.",
4+
"version": "0.0.1",
5+
"private": true,
6+
"license": "Apache Version 2.0",
7+
"engines": {
8+
"node": "~4.2"
9+
},
10+
"scripts": {
11+
"start": "node server.js",
12+
"postinstall": "bower install --config.interactive=false",
13+
"deploy": "gcloud preview app deploy app.yaml"
14+
},
15+
"dependencies": {
16+
"bower": "^1.6.5",
17+
"express": "^4.13.3",
18+
"jade": "^1.11.0"
19+
}
20+
}

appengine/bower/server.js

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// Copyright 2015, Google, Inc.
2+
// Licensed under the Apache License, Version 2.0 (the "License");
3+
// you may not use this file except in compliance with the License.
4+
// You may obtain a copy of the License at
5+
//
6+
// http://www.apache.org/licenses/LICENSE-2.0
7+
//
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
14+
'use strict';
15+
16+
var express = require('express');
17+
18+
var app = express();
19+
20+
// Setup view engine
21+
app.set('view engine', 'jade');
22+
23+
app.use(express.static(__dirname + '/public'));
24+
25+
app.get('/', function(req, res) {
26+
res.render('index');
27+
});
28+
29+
var server = app.listen(
30+
process.env.PORT || 8080,
31+
'0.0.0.0',
32+
function () {
33+
var address = server.address().address;
34+
var port = server.address().port;
35+
console.log('App listening at http://%s:%s', address, port);
36+
console.log('Press Ctrl+C to quit.');
37+
}
38+
);

appengine/bower/views/index.jade

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// Copyright 2015, Google, Inc.
2+
// Licensed under the Apache License, Version 2.0 (the "License");
3+
// you may not use this file except in compliance with the License.
4+
// You may obtain a copy of the License at
5+
//
6+
// http://www.apache.org/licenses/LICENSE-2.0
7+
//
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
14+
doctype html
15+
html
16+
head
17+
title= title
18+
script(type='text/javascript', src='bower_components/jquery/dist/jquery.min.js')
19+
body
20+
h1 Hello World!
21+
p Express.js + Bower on Google App Engine.
22+
hr
23+
p Using <span id="module-name"></span>, installed via Bower.
24+
script(type='text/javascript').
25+
$('#module-name').text('jquery')
26+

test/appengine/all.test.js

+6
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@ function getPath(dir) {
2525
}
2626

2727
var sampleTests = [
28+
{
29+
dir: 'bower',
30+
cmd: 'node',
31+
args: ['server.js'],
32+
msg: 'Using jquery, installed via Bower.'
33+
},
2834
{
2935
dir: 'express',
3036
deploy: true,

0 commit comments

Comments
 (0)