Skip to content
This repository has been archived by the owner on Sep 25, 2019. It is now read-only.

[WIP]: Cloud endpoints and GAE Flex support #116

Closed
wants to merge 29 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
f1f51f1
update(api): enable Google Edge caching.
Splaktar Mar 17, 2017
2dc4bf8
update(express): remove blitzio magic endpoint and returning 42.
Splaktar Mar 17, 2017
651b9f2
update(about): remove out of date references to Yeoman, Redis, Openshift
Splaktar Mar 17, 2017
bbaed00
update(server): remove Redis, clustering. Convert session storage to …
Splaktar Mar 17, 2017
43c57cc
update(server): setup for GAE Flex and Cloud Endpoints.
Splaktar Mar 18, 2017
66db763
update(server): enable cloud debug and cloud trace
Splaktar Mar 18, 2017
c5c854f
fix(build): jshint and karma warnings
Splaktar Mar 18, 2017
4f76f3b
Merge branch 'removeRedis' into cloudEndpointsAndGaeFlex
Splaktar Mar 18, 2017
f44fa9b
update(ci): drop testing of Node 0.12 and 5.x. Add 7.x testing.
Splaktar Mar 18, 2017
b27772c
update(express): clarify cache config. disable yes-https for now.
Splaktar Mar 18, 2017
ca34f27
update(ci): revert change to remove bower install
Splaktar Mar 18, 2017
429e24b
update(npm): update uglify and phantomjs
Splaktar Mar 18, 2017
3db4882
update(server): changes that finally got the API working on GAE Flex!…
Splaktar Mar 18, 2017
3d00dc1
update(server): move health checks up so that they aren't double logged
Splaktar Mar 18, 2017
17c1f3e
update(server): remote rate metering
Splaktar Mar 18, 2017
c090780
Merge branch 'removeRedis' into cloudEndpointsAndGaeFlex
Splaktar Mar 18, 2017
93930d8
update(server): setup for GAE Flex and Cloud Endpoints.
Splaktar Mar 18, 2017
1f3f57b
update(server): enable cloud debug and cloud trace
Splaktar Mar 18, 2017
5308488
update(ci): drop testing of Node 0.12 and 5.x. Add 7.x testing.
Splaktar Mar 18, 2017
4e8231f
update(express): clarify cache config. disable yes-https for now.
Splaktar Mar 18, 2017
cce809a
update(ci): revert change to remove bower install
Splaktar Mar 18, 2017
df8d2cd
update(npm): update uglify and phantomjs
Splaktar Mar 18, 2017
f4beee3
update(server): changes that finally got the API working on GAE Flex!…
Splaktar Mar 18, 2017
dc344c7
update(server): move health checks up so that they aren't double logged
Splaktar Mar 18, 2017
e5eceab
Merge remote-tracking branch 'origin/cloudEndpointsAndGaeFlex' into c…
Splaktar Mar 18, 2017
9254820
Merge remote-tracking branch 'upstream/cloudEndpointsAndGaeFlex' into…
Splaktar Mar 18, 2017
a080d7c
fix(api): fix merge issue
Splaktar Mar 18, 2017
8ab1945
update(npm): update to latest csurf
Splaktar Mar 21, 2017
b2b22e5
fix(keys): fix error when process.env.ANDROID_CLIENT_IDS is undefined
Splaktar May 10, 2017
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
16 changes: 16 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
test/

node_modules/
.git/
coverage/
npm-debug.log

.dockerignore
Dockerfile

.gitignore
.gitattributes
.editorconfig
.idea/
*.md
*.iml
16 changes: 9 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
.DS_Store
node_modules
public
.tmp
/node_modules
/public
/.tmp
/tmp
.sass-cache
app/bower_components
heroku
/app/bower_components
/views
dist
.idea
/dist
/.idea
newrelic_agent.log
.c9
mongodb
*.log
.env
.env-prod
npm-debug.log.*
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4.6.1
6.9.2
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
language: node_js
node_js:
- '0.12'
- '4'
- '5'
- '6'
- '7'
before_script:
- npm install -g bower grunt-cli
- bower install
Expand Down
3 changes: 1 addition & 2 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,6 @@ module.exports = function (grunt) {
src: [
'package.json',
'server.js',
'newrelic.js',
'lib/**/*'
]
}]
Expand Down Expand Up @@ -352,7 +351,7 @@ module.exports = function (grunt) {

grunt.registerTask('serve', function (target) {
if (target === 'dist') {
return grunt.task.run(['build', 'express:prod', 'open', 'express-keepalive']);
return grunt.task.run(['build', 'express:prod', 'express-keepalive']);
}

grunt.task.run([
Expand Down
15 changes: 15 additions & 0 deletions app.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
runtime: nodejs
env: flex
handlers:
- url: /.*
script: IGNORED
endpoints_api_service:
name: api.gdgx.io
config_id: 2017-03-18r0
network:
instance_tag: https-server
name: default
automatic_scaling:
min_num_instances: 1
max_num_instances: 2
cool_down_period_sec: 300
4 changes: 4 additions & 0 deletions cron.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
cron:
- description: daily 9am EST ingestion job
url: /
schedule: every day 13:00
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • update this to do ingestion jobs once OpenAPI spec is done and Cloud Endpoints are all working.

9 changes: 7 additions & 2 deletions lib/config/env/all.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,17 @@ var rootPath = path.normalize(__dirname + '/../../..');

module.exports = {
root: rootPath,
port: process.env.PORT || process.env.NODEJS_PORT || 3000,
hostname: process.env.NODEJS_IP || undefined,
port: process.env.PORT || 3000,
hostname: undefined,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was key in getting GAE Flex working. If I put anything in here it would cause forwarding from the GAE proxy to Express to fail and give 503 errors.

mongo: {
options: {
db: {
safe: true
},
server: {
socketOptions: {
keepAlive: 1
}
}
}
},
Expand Down
19 changes: 15 additions & 4 deletions lib/config/express.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,17 @@ var express = require('express'),
path = require('path'),
passport = require('passport'),
config = require('./config');
var errorhandler = require('errorhandler');
var errorHandler = require('errorhandler');
var morgan = require('morgan');
var compression = require('compression');
var bodyParser = require('body-parser');
// var yesHttps = require('yes-https');
const MongoStore = require('connect-mongo')(session);
// var csrf = require('csurf');
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Re-enable CSRF protection


const STATIC_FILE_CACHE_AGE = 604800000; // 1 week
// const YES_HTTPS_MAX_AGE = 120000; // 2 minutes

/**
* Express configuration
*/
Expand All @@ -34,7 +38,7 @@ module.exports = function (app) {

app.use(express.static(path.join(config.root, '.tmp')));
app.use(express.static(path.join(config.root, 'app')));
app.use(errorhandler());
app.use(errorHandler());
app.set('views', config.root + '/app/views');

app.use(session({
Expand All @@ -49,8 +53,8 @@ module.exports = function (app) {
if (process.env.NODE_ENV === 'production') {
app.use(favicon(path.join(config.root, 'public', 'favicon.ico'), {}));
app.use(compression());
app.use(express.static(path.join(config.root, 'public'), {maxAge: 604800000}));
app.set('views', config.root + '/views');
app.use(express.static(path.join(config.root, 'public'), { maxAge: STATIC_FILE_CACHE_AGE, etag: true }));
app.set('views', config.root + '/public/views');

app.use(session({
cookie: { secure: true },
Expand All @@ -61,6 +65,13 @@ module.exports = function (app) {
}));
}

// Configure GAE proxy and health checks. Force HTTPS.
app.enable('trust proxy');
// app.use(yesHttps({ maxAge: YES_HTTPS_MAX_AGE, includeSubdomains: true, preload: true }));
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Re-enable yes-http once HTTPS is working with hub.gdgx.io on Cloud Endpoints.

app.get('/_ah/health', (req, res) => {
res.sendStatus(200);
});

app.engine('html', require('ejs').renderFile);
app.set('view engine', 'html');
app.use(morgan('[' + process.pid + '] :method :url :status :response-time ms - :res[content-length]'));
Expand Down
2 changes: 1 addition & 1 deletion lib/config/keys.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ module.exports = {
},
frisbee: {
serverClientId: process.env.SERVER_KEY_SECRET,
androidClientIds: process.env.ANDROID_CLIENT_IDS.split(',')
androidClientIds: process.env.ANDROID_CLIENT_IDS ? process.env.ANDROID_CLIENT_IDS.split(',') : []
}
}
};
131 changes: 131 additions & 0 deletions openapi.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
{
"swagger": "2.0",
"info": {
"version": "1.0.0",
"title": "GDG-X Hub API",
"description": "API for using data from the Google Developer Groups (GDG) Hub.",
"license": {
"name": "MIT"
},
"contact": {
"name": "GDG-X Support",
"email": "[email protected]"
}
},
"host": "api.gdgx.io",
"basePath": "/api/v1",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"schemes": [
"https"
],
"paths": {
"/chapters": {
Copy link
Contributor Author

@Splaktar Splaktar Mar 18, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OpenAPI Spec TODO:

  • events API
  • admin API
  • applications API
  • frisbee API
  • metrics API
  • tags API
  • users API
  • auth API

"get": {
"operationId": "listChapters",
"description": "Returns a list containing all Chapters",
"responses": {
"200": {
"description": "Success",
"schema": {
"$ref": "#/definitions/ChapterList"
}
}
}
}
}
},
"definitions": {
"ChapterList": {
"type": "object",
"properties": {
"count": {
"type": "number"
},
"pages": {
"type": "number"
},
"page": {
"type": "number"
},
"perpage": {
"type": "number"
},
"items": {
"type": "array",
"items": {
"$ref": "#/definitions/Chapter"
}
}
}
},
"Chapter": {
"type": "object",
"properties": {
"_id": {
"type": "string"
},
"created_at": {
"type": "string"
},
"updated_at": {
"type": "string"
},
"site": {
"type": "string"
},
"group_type": {
"type": "string"
},
"country": {
"type": "string"
},
"state": {
"type": "string"
},
"city": {
"type": "string"
},
"name": {
"type": "string"
},
"__v": {
"type": "number"
},
"organizers": {
"type": "array",
"items": {
"type": "string"
}
},
"geo": {
"$ref": "#/definitions/Location"
}
}
},
"Location": {
"type": "object",
"required": [
"lng", "lat"
],
"properties": {
"lng": {
"type": "number"
},
"lat": {
"type": "number"
}
}
}
},
"security": [

],
"securityDefinitions": {

}
}
Loading