Skip to content

Commit

Permalink
update(server): setup for GAE Flex and Cloud Endpoints.
Browse files Browse the repository at this point in the history
Relates to gdg-x#100
  • Loading branch information
Splaktar committed Mar 18, 2017
1 parent bbaed00 commit 43c57cc
Show file tree
Hide file tree
Showing 9 changed files with 223 additions and 47 deletions.
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 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: gdg-x
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
8 changes: 8 additions & 0 deletions lib/config/express.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ 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);

/**
Expand Down Expand Up @@ -73,4 +74,11 @@ module.exports = function (app) {
// Passport
app.use(passport.initialize());
app.use(passport.session());

// Configure GAE proxy and health checks. Force HTTPS.
app.enable('trust proxy');
app.use(yesHttps({ maxAge: 31536000, includeSubdomains: true, preload: true }));
app.get('/_ah/health', (req, res) => {
res.sendStatus(200);
});
};
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": {
"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": {

}
}
75 changes: 38 additions & 37 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"dependencies": {
"async": "1.4.2",
"body-parser": "1.17.1",
"bower": "1.8.0",
"burrito": "0.2.12",
"cacher": "1.0.0",
"cheerio": "0.19.0",
Expand All @@ -34,32 +35,10 @@
"express": "4.15.2",
"express-rate": "0.0.1",
"express-session": "1.15.1",
"jpegtran-bin": "0.2.0",
"jshint-stylish": "2.2.1",
"google-oauth-jwt": "0.1.7",
"googleapis": "0.8.0",
"lodash": "2.4.1",
"method-override": "2.3.7",
"methods": "1.1.2",
"moment": "2.10.6",
"mongoose": "3.5.5",
"morgan": "1.8.1",
"node-forge": "0.6.34",
"node-geocoder": "2.2.0",
"node-uuid": "1.4.3",
"nodemailer": "1.4.0",
"passport": "0.3.2",
"passport-http-bearer": "1.0.1",
"passport-http-oauth": "0.1.3",
"passport-localapikey": "0.0.3",
"serve-favicon": "2.4.1",
"slugify": "0.1.1",
"socket.io": "0.9.17",
"superagent": "0.17.0",
"superagent-retry": "0.3.0",
"timequeue": "0.2.2"
},
"devDependencies": {
"bower": "1.7.9",
"connect-livereload": "0.6.0",
"grunt": "0.4.5",
"grunt-autoprefixer": "0.4.0",
"grunt-bower-install": "0.7.0",
Expand All @@ -85,10 +64,35 @@
"grunt-rev": "0.1.0",
"grunt-svgmin": "0.2.0",
"grunt-usemin": "2.0.0",
"jasmine-core": "2.4.1",
"jpegtran-bin": "0.2.0",
"jshint-stylish": "2.2.1",
"karma": "1.2.0",
"load-grunt-tasks": "0.2.0",
"lodash": "2.4.1",
"method-override": "2.3.7",
"methods": "1.1.2",
"moment": "2.10.6",
"mongoose": "3.5.5",
"morgan": "1.8.1",
"node-forge": "0.6.34",
"node-geocoder": "2.2.0",
"node-uuid": "1.4.3",
"nodemailer": "1.4.0",
"passport": "0.3.2",
"passport-http-bearer": "1.0.1",
"passport-http-oauth": "0.1.3",
"passport-localapikey": "0.0.3",
"requirejs": "2.1.20",
"serve-favicon": "2.4.1",
"slugify": "0.1.1",
"socket.io": "0.9.17",
"superagent": "0.17.0",
"superagent-retry": "0.3.0",
"timequeue": "0.2.2",
"time-grunt": "0.2.10",
"yes-https": "0.0.3"
},
"devDependencies": {
"connect-livereload": "0.6.0",
"jasmine-core": "2.4.1",
"karma-chrome-launcher": "2.0.0",
"karma-coverage": "1.1.1",
"karma-firefox-launcher": "1.0.0",
Expand All @@ -100,20 +104,17 @@
"karma-phantomjs-launcher": "1.0.1",
"karma-requirejs": "1.0.0",
"karma-script-launcher": "1.0.0",
"load-grunt-tasks": "0.2.0",
"phantomjs-prebuilt": "2.1.7",
"requirejs": "2.1.20",
"time-grunt": "0.2.10"
"phantomjs-prebuilt": "2.1.7"
},
"engines": {
"node": ">=0.12.0"
"node": ">=6"
},
"scripts": {
"postinstall": "bower install",
"prestart": "grunt",
"start": "grunt serve",
"startProd": "grunt serve:dist",
"configProd": "sudo iptables -A PREROUTING -t nat -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 3000;export PORT=3000;",
"deploy": "gcloud app deploy --project gdgx-cloud --no-promote",
"deploy-promote": "gcloud app deploy --project gdgx-cloud",
"deploy-api": "gcloud service-management deploy openapi.json --project gdgx-cloud",
"start": "grunt serve:dist",
"startDev": "grunt serve",
"test": "grunt test"
}
}

0 comments on commit 43c57cc

Please sign in to comment.