Created
April 18, 2018 20:16
-
-
Save amitsnyderman/bdbdde8470b72ee99ff16f734256802f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git a/app.js b/app.js | |
| index 1a60c1d..5dea4f8 100644 | |
| --- a/app.js | |
| +++ b/app.js | |
| @@ -16,8 +16,26 @@ module.exports = ({ resolver }) => { | |
| app.use(compress()); | |
| app.use(etag()); | |
| + app.use(async (ctx, next) => { | |
| + try { | |
| + await next(); | |
| + } finally { | |
| + console.log({ | |
| + httpRequest: { | |
| + requestUrl: ctx.req.url, | |
| + requestMethod: ctx.req.method, | |
| + remoteIp: ctx.req.connection.remoteAddress, | |
| + userAgent: ctx.req.headers['user-agent'], | |
| + referer: ctx.req.headers['referer'], | |
| + status: ctx.res.statusCode, | |
| + }, | |
| + }); | |
| + } | |
| + }); | |
| + | |
| app.use(route.get('/', (ctx) => { | |
| - ctx.throw(404); | |
| + ctx.status = 200; | |
| + ctx.body = 'hi'; | |
| })); | |
| app.use(route.get('/(.+?)', async (ctx, payload) => { | |
| diff --git a/app.yaml b/app.yaml | |
| new file mode 100644 | |
| index 0000000..c74b007 | |
| --- /dev/null | |
| +++ b/app.yaml | |
| @@ -0,0 +1,5 @@ | |
| +runtime: nodejs | |
| +env: flex | |
| + | |
| +manual_scaling: | |
| + instances: 1 | |
| \ No newline at end of file | |
| diff --git a/config/development.json b/config/development.json | |
| index 82e5123..72ddf64 100644 | |
| --- a/config/development.json | |
| +++ b/config/development.json | |
| @@ -1,7 +1,7 @@ | |
| { | |
| "server": { | |
| "host": "localhost", | |
| - "port": 9999 | |
| + "port": 8080 | |
| }, | |
| "resolver": { | |
| "strategy": "http", | |
| diff --git a/package.json b/package.json | |
| index ca68fb9..7514cc6 100644 | |
| --- a/package.json | |
| +++ b/package.json | |
| @@ -4,10 +4,17 @@ | |
| "description": "Asset concatenation server", | |
| "main": "index.js", | |
| "author": "", | |
| - "license": "ISC", | |
| + "license": "Apache-2.0", | |
| "scripts": { | |
| + "deploy": "gcloud app deploy", | |
| + "deploy:verbose": "gcloud app deploy --verbosity=debug", | |
| + "start": "node index.js --config=config/development.json", | |
| "test": "jest" | |
| }, | |
| + "engines": { | |
| + "node": "9.x", | |
| + "npm": "5.x" | |
| + }, | |
| "dependencies": { | |
| "koa": "^2.5.0", | |
| "koa-compress": "^2.0.0", |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment