Skip to content

Commit

Permalink
Style and licenses for appengine/express.
Browse files Browse the repository at this point in the history
  • Loading branch information
jmdobry committed Sep 29, 2015
1 parent 8743133 commit fdb21ac
Show file tree
Hide file tree
Showing 10 changed files with 130 additions and 21 deletions.
28 changes: 14 additions & 14 deletions appengine/express/README.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
# Express -> Google App Engine

This is a simple guide to running [expressjs](http://expressjs.com/) on Google App Engine.
This is a simple guide to running [expressjs](http://expressjs.com/) on Google App Engine.

1. [Create a new Express app](http://expressjs.com/starter/generator.html)

2. Create an `app.yaml` in the root of your application with the following contents:

```yaml
runtime: nodejs
vm: true
env_variables:
PORT: 8080
```
```yaml
runtime: nodejs
vm: true
env_variables:
PORT: 8080
```
3. Deploy your app. For convenience, you can use an npm script to run the command. Modify your `package.json` to include:

```js
"scripts": {
"start": "node ./bin/www",
"deploy": "gcloud preview app deploy app.yaml --set-default --project [project id]"
}
```
```js
"scripts": {
"start": "node ./bin/www",
"deploy": "gcloud preview app deploy app.yaml --set-default --project [project id]"
}
```

At the terminal you can now run `npm run deploy` to deploy your application.
At the terminal you can now run `npm run deploy` to deploy your application.
22 changes: 17 additions & 5 deletions appengine/express/app.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
// Copyright 2015, 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 path = require('path');
var favicon = require('serve-favicon');
var logger = require('morgan');
var cookieParser = require('cookie-parser');
var bodyParser = require('body-parser');
Expand All @@ -14,8 +28,6 @@ var app = express();
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'jade');

// uncomment after placing your favicon in /public
//app.use(favicon(__dirname + '/public/favicon.ico'));
app.use(logger('dev'));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
Expand All @@ -37,7 +49,7 @@ app.use(function(req, res, next) {
// development error handler
// will print stacktrace
if (app.get('env') === 'development') {
app.use(function(err, req, res, next) {
app.use(function(err, req, res) {
res.status(err.status || 500);
res.render('error', {
message: err.message,
Expand All @@ -48,7 +60,7 @@ if (app.get('env') === 'development') {

// production error handler
// no stacktraces leaked to user
app.use(function(err, req, res, next) {
app.use(function(err, req, res) {
res.status(err.status || 500);
res.render('error', {
message: err.message,
Expand Down
13 changes: 13 additions & 0 deletions appengine/express/app.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
# Copyright 2015, 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.

runtime: nodejs
api_version: 1
vm: true
Expand Down
2 changes: 2 additions & 0 deletions appengine/express/bin/www
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/usr/bin/env node

'use strict';

/**
* Module dependencies.
*/
Expand Down
13 changes: 13 additions & 0 deletions appengine/express/public/stylesheets/style.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
/** Copyright 2015, 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.
*/
body {
padding: 50px;
font: 14px "Lucida Grande", Helvetica, Arial, sans-serif;
Expand Down
17 changes: 16 additions & 1 deletion appengine/express/routes/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,23 @@
// Copyright 2015, 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 router = express.Router();

/* GET home page. */
router.get('/', function(req, res, next) {
router.get('/', function(req, res) {
res.render('index', { title: 'Express |2|' });
});

Expand Down
17 changes: 16 additions & 1 deletion appengine/express/routes/users.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,23 @@
// Copyright 2015, 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 router = express.Router();

/* GET users listing. */
router.get('/', function(req, res, next) {
router.get('/', function(req, res) {
res.send('respond with a resource');
});

Expand Down
13 changes: 13 additions & 0 deletions appengine/express/views/error.jade
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
// Copyright 2015, 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.
extends layout

block content
Expand Down
13 changes: 13 additions & 0 deletions appengine/express/views/index.jade
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
// Copyright 2015, 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.
extends layout

block content
Expand Down
13 changes: 13 additions & 0 deletions appengine/express/views/layout.jade
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
// Copyright 2015, 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.
doctype html
html
head
Expand Down

0 comments on commit fdb21ac

Please sign in to comment.