Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added comments so code can be included in our site docs. #13

Merged
merged 1 commit into from
Oct 7, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions appengine/express/app.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@
# 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
api_version: 1
env_variables:
PORT: 8080
PORT: 8080
# [END app_yaml]
10 changes: 4 additions & 6 deletions appengine/express/bin/www
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@

'use strict';

// [START server]

/**
* Module dependencies.
*/

var app = require('../app');
var debug = require('debug')('express:server');
var http = require('http');

/**
* Get port from environment and store in Express.
*/

var port = normalizePort(process.env.PORT || 8080);
app.set('port', port);

Expand All @@ -26,15 +26,15 @@ var server = http.createServer(app);
/**
* Listen on provided port, on all network interfaces.
*/

server.listen(port);
server.on('error', onError);
server.on('listening', onListening);

// [END server]

/**
* Normalize a port into a number, string, or false.
*/

function normalizePort(val) {
var port = parseInt(val, 10);

Expand All @@ -54,7 +54,6 @@ function normalizePort(val) {
/**
* Event listener for HTTP server "error" event.
*/

function onError(error) {
if (error.syscall !== 'listen') {
throw error;
Expand Down Expand Up @@ -82,7 +81,6 @@ function onError(error) {
/**
* Event listener for HTTP server "listening" event.
*/

function onListening() {
var addr = server.address();
var bind = typeof addr === 'string'
Expand Down
5 changes: 3 additions & 2 deletions appengine/express/routes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@
var express = require('express');
var router = express.Router();

/* GET home page. */
// [START hello_world]
router.get('/', function(req, res) {
res.render('index', { title: 'Express 4 on Google App Engine' });
res.render('index', { title: 'Hello World!' });
});
// [END hello_world]

module.exports = router;
6 changes: 4 additions & 2 deletions appengine/geddy/app.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@
# 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
api_version: 1
env_variables:
PORT: 8080
PORT: 8080
# [END app_yaml]
2 changes: 2 additions & 0 deletions appengine/geddy/app/controllers/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

'use strict';

// [START main]
var Main = function () {
this.index = function (req, resp, params) {
this.respond({params: params}, {
Expand All @@ -28,3 +29,4 @@ var Main = function () {
};

exports.Main = Main;
// [END main]
4 changes: 3 additions & 1 deletion appengine/geddy/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@

'use strict';

// [START server]
var geddy = require('geddy');

geddy.start({
port: process.env.PORT || 8080
});
});
// [END server]
27 changes: 16 additions & 11 deletions appengine/grunt/Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
module.exports = function(grunt) {

grunt.initConfig({
// [START config]
jshint: {
files: ['Gruntfile.js', 'src/**/*.js'],
options: {
Expand All @@ -26,30 +27,34 @@ module.exports = function(grunt) {
}
},
cssmin: {
minify: {
src: 'src/public/stylesheets/style.css',
dest: 'src/public/stylesheets/style.min.css'
}
minify: {
src: 'src/public/stylesheets/style.css',
dest: 'src/public/stylesheets/style.min.css'
}
},
// [END config]
clean: ['src/public/stylesheets/style.min.css'],
watch: {
js: {
files: ['<%= jshint.files %>'],
tasks: ['jshint']
files: ['<%= jshint.files %>'],
tasks: ['jshint']
},

css: {
files: ['<%= cssmin.minify.src %>'],
tasks: ['cssmin']
files: ['<%= cssmin.minify.src %>'],
tasks: ['cssmin']
}
}
});
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-clean');

// [START tasks]
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.loadNpmTasks('grunt-contrib-clean');

grunt.registerTask('build', ['jshint', 'cssmin']);
// [END tasks]

grunt.registerTask('default', ['watch']);
};
};
6 changes: 4 additions & 2 deletions appengine/grunt/app.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@
# 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
api_version: 1
env_variables:
PORT: 8080
PORT: 8080
# [END app_yaml]
7 changes: 2 additions & 5 deletions appengine/grunt/src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

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 @@ -29,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 @@ -52,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 @@ -63,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
14 changes: 7 additions & 7 deletions appengine/grunt/src/bin/www
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
#!/usr/bin/env node

'use strict';

// [START server]

/**
* Module dependencies.
*/

var app = require('../app');
var debug = require('debug')('src:server');
var debug = require('debug')('express:server');
var http = require('http');

/**
* Get port from environment and store in Express.
*/

var port = normalizePort(process.env.PORT || 8080);
app.set('port', port);

Expand All @@ -24,15 +26,15 @@ var server = http.createServer(app);
/**
* Listen on provided port, on all network interfaces.
*/

server.listen(port);
server.on('error', onError);
server.on('listening', onListening);

// [END server]

/**
* Normalize a port into a number, string, or false.
*/

function normalizePort(val) {
var port = parseInt(val, 10);

Expand All @@ -52,7 +54,6 @@ function normalizePort(val) {
/**
* Event listener for HTTP server "error" event.
*/

function onError(error) {
if (error.syscall !== 'listen') {
throw error;
Expand Down Expand Up @@ -80,7 +81,6 @@ function onError(error) {
/**
* Event listener for HTTP server "listening" event.
*/

function onListening() {
var addr = server.address();
var bind = typeof addr === 'string'
Expand Down
7 changes: 4 additions & 3 deletions appengine/grunt/src/routes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@
var express = require('express');
var router = express.Router();

/* GET home page. */
router.get('/', function(req, res, next) {
res.render('index', { title: 'Grunt + Express 4 on Google App Engine' });
// [START hello_world]
router.get('/', function(req, res) {
res.render('index', { title: 'Hello World!' });
});
// [END hello_world]

module.exports = router;
4 changes: 3 additions & 1 deletion appengine/hapi/app.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@
# 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
api_version: 1
env_variables:
PORT: 8080
# [END app_yaml]
10 changes: 7 additions & 3 deletions appengine/hapi/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

'use strict';

// [START server]
var Hapi = require('hapi');

// Create a server with a host and port
Expand All @@ -21,15 +22,17 @@ server.connection({
host: '127.0.0.1',
port: process.env.PORT || 8080
});
// [END server]

// Add an index route
// [START index]
server.route({
method: 'GET',
path:'/',
handler: function (request, reply) {
reply('hello world');
}
});
// [END index]

// Add another route
server.route({
Expand All @@ -40,7 +43,8 @@ server.route({
}
});

// Start the server
// [START server_start]
server.start(function () {
console.log('Server running at:', server.info.uri);
});
});
// [END server_start]
4 changes: 3 additions & 1 deletion appengine/koa/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@

'use strict';

// [START server]
var koa = require('koa');
var app = koa();

app.use(function *(){
this.body = 'Hello World';
});

app.listen(process.env.PORT || 8080);
app.listen(process.env.PORT || 8080);
// [END server]
8 changes: 5 additions & 3 deletions appengine/koa/app.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@
# 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
api_version: 1
vm: true
api_version: 1
env_variables:
PORT: 8080
PORT: 8080
# [END app_yaml]
1 change: 1 addition & 0 deletions appengine/kraken/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ vm: true
api_version: 1
env_variables:
PORT: 8080
```

##### Deploy

Expand Down
Loading