Split out fxa-basket-proxy into a standalone project. #2
Conversation
|
I'm opening this for anyone who'd like to give it an initial look-over to offer feedback, but will continue to work on it a little until I'm happy with the over all shape. @shane-tomlinson and/or @jrgm any thoughts on the proposed split-out from content-server repo? |
|
Looks good. I have one question: is the intent to run this on the same instances as fxa-content-server, or as a separate service? I'd prefer the former. |
Your call :-) Running on the same instances sounds fine to me. In that case, would it make sense for it to continue sharing the same I think we should also move the basket SQS consumer from [1] into this repo, to keep all the basket stuff together. But that just pulls things off a queue and posts them to an endpoint, so ISTM there should be no problem moving that to the content-server instances as well if necessary. [1] https://github.com/mozilla/fxa-auth-server/blob/master/bin/basket.js |
| - Your patch should include new tests that cover your changes. It is your and your reviewer's responsibility to ensure your patch includes adequate tests. | ||
|
|
||
| When submitting a PR: | ||
| - You agree to license your code under the project's open source license ([MPL 2.0](/LICENSE)). |
pdehaan
Sep 10, 2015
I think we need to add a /LICENSE file.
I think we need to add a /LICENSE file.
shane-tomlinson
Sep 22, 2015
Member
Added.
Added.
| module.exports = function (grunt) { | ||
| grunt.config('bump', { | ||
| options: { | ||
| files: [ 'package.json', 'npm-shrinkwrap.json' ], |
pdehaan
Sep 10, 2015
Not sure if we have a shrinkwrap file in this repo [yet].
Not sure if we have a shrinkwrap file in this repo [yet].
| '<%= eslint.files %>' | ||
| ], | ||
| options: { | ||
| config: '.jscsrc', |
pdehaan
Sep 10, 2015
We may need to copy over the .jscsrc file as well. ¯_(ツ)_/¯
We may need to copy over the .jscsrc file as well. ¯_(ツ)_/¯
rfk
Sep 23, 2015
Author
Member
Ugh, it was being ignored by the .gitignore so didn't get checked in, I've added it now
Ugh, it was being ignored by the .gitignore so didn't get checked in, I've added it now
| return { | ||
| status: 'error', | ||
| desc: String(desc), | ||
| code: code || module.exports.UNKNOWN_ERROR |
pdehaan
Sep 10, 2015
module.exports.errors.UNKNOWN_ERROR?
module.exports.errors.UNKNOWN_ERROR?
| .tmp/** | ||
| app/bower_components/** | ||
| app/scripts/vendor/** | ||
| dist/** |
pdehaan
Sep 10, 2015
I don't know if any of these paths apply to this repo. We may be able to nuke this file.
I don't know if any of these paths apply to this repo. We may be able to nuke this file.
|
|
||
| | TASK | DESCRIPTION | | ||
| |------|-------------| | ||
| | `grunt lint` | run ESLint, JSONLint, and JSCS (code style checker) on the code. | |
pdehaan
Sep 10, 2015
Technically I don't think we're using JSONLint anywhere here.
Technically I don't think we're using JSONLint anywhere here.
|
|
||
| Before submitting a PR: | ||
| - Your code must run and pass all the automated tests before you submit your PR for review. "Work in progress" pull requests are allowed to be submitted, but should be clearly labeled as such and should not be merged until all tests pass and the code has been reviewed. | ||
| - Run `grunt eslint` to make sure your code passes linting. |
pdehaan
Sep 10, 2015
We should probably generic this down to grunt lint (which runs ESLint and JSCS; https://github.com/mozilla/fxa-basket-proxy/pull/2/files#diff-04c6e90faac2675aa89e2176d2eec7d8R25)
We should probably generic this down to grunt lint (which runs ESLint and JSCS; https://github.com/mozilla/fxa-basket-proxy/pull/2/files#diff-04c6e90faac2675aa89e2176d2eec7d8R25)
| @@ -0,0 +1,33 @@ | |||
| # Firefox Accounts Basket Proxy | |||
|
|
|||
| [](https://travis-ci.org/mozilla/fxa-basket-proxy) | |||
pdehaan
Sep 10, 2015
I think I enabled Travis-CI for this repo, but not sure how to set up coveralls below.
I think I enabled Travis-CI for this repo, but not sure how to set up coveralls below.
| grunt.registerTask('lint', 'lint all the things', SUBTASKS); | ||
| grunt.registerTask('quicklint', 'lint the modified files', SUBTASKS.map(function (task) { | ||
| return 'newer:' + task; | ||
| })); |
pdehaan
Sep 10, 2015
If we don't plan on using the Git pre-commit hooks in this repo, we can remove the quicklint task and probably remove a dependency or two.
If we don't plan on using the Git pre-commit hooks in this repo, we can remove the quicklint task and probably remove a dependency or two.
| "grunt-nodemon": "^0.4.0", | ||
| "grunt-nsp-shrinkwrap": "0.0.3", | ||
| "grunt-todo": "0.5.0", | ||
| "husky": "0.9.2", |
pdehaan
Sep 10, 2015
If we don't plan on adding git pre-commit hooks to this repo (see #2 (comment)), we can remove the husky and grunt-newer dependencies above.
If we don't plan on adding git pre-commit hooks to this repo (see #2 (comment)), we can remove the husky and grunt-newer dependencies above.
| "mocha-text-cov": "^0.1.0", | ||
| "nock": "2.10", | ||
| "proxyquire": "1.6.0", | ||
| "sinon": "1.15.4", |
pdehaan
Sep 10, 2015
I don't think we're using proxyquire or sinon anywhere in these files.
I don't think we're using proxyquire or sinon anywhere in these files.
|
@pdehaan |
|
@rfk: To be clear, I add nothing to the conversation. I'm happy to merge this as-is and we can do future nit PRs to smooth the edges. |
|
No no, I will definitely go through and apply these fixes. It's the sort of stuff that I can no longer notice because I've been shuffling all these files around for too long, and I deliberately pushed it thinking "I bet @pdehaan will notice a bunch of nits in the repo infrastructure" :-) |
|
(force-pushed with @pdehaan nits addressed, and travis does indeed appear to be running it) |
|
OK, test coverage up to 95%, I think this is ready for a preliminary r?. @zaach since Shane's PTO this weekend, would you mind giving this a look over? Concurrently, I'll work on getting it running locally in fxa-local-dev to check that functional tests still pass. |
|
|
||
| module.exports = function (grunt) { | ||
| // load all grunt tasks based on environment | ||
| if (process.env.NODE_ENV && process.env.NODE_ENV === 'production') { |
pdehaan
Sep 11, 2015
Nit: this may need some tweaking as well.
According to lib/config.js, it looks like the NODE_ENV may be "prod", not "production":
var conf = module.exports = convict({
env: {
doc: 'The current node.js environment',
default: 'prod',
format: [ 'dev', 'test', 'stage', 'prod' ],
env: 'NODE_ENV'
},
Not sure if this is worth wrapping in a conf.get('env') === 'prod'; style thing, or maybe we need a better abstraction for determining if we're running in dev/stage/prod environment.
Nit: this may need some tweaking as well.
According to lib/config.js, it looks like the NODE_ENV may be "prod", not "production":
var conf = module.exports = convict({
env: {
doc: 'The current node.js environment',
default: 'prod',
format: [ 'dev', 'test', 'stage', 'prod' ],
env: 'NODE_ENV'
},Not sure if this is worth wrapping in a conf.get('env') === 'prod'; style thing, or maybe we need a better abstraction for determining if we're running in dev/stage/prod environment.
rfk
Sep 23, 2015
Author
Member
I changed lib/config.js to match what's in content-server, so they can share the same config file in deployment.
I changed lib/config.js to match what's in content-server, so they can share the same config file in deployment.
| "env": "prod", | ||
| "basket": { | ||
| "apiUrl": "https://basket.mozilla.org/news" | ||
| } |
| "publicUrl": "http://127.0.0.1:1114", | ||
| "env": "dev", | ||
| "log": { | ||
| "format": "pretty", |
| @@ -0,0 +1,8 @@ | |||
| { | |||
| "publicUrl": "http://127.0.0.1:1114", | |||
| * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
|
||
| module.exports = { | ||
| version: require('./version'), |
shane-tomlinson
Sep 16, 2015
Member
Can you alphabetize these?
Can you alphabetize these?
| code: res.statusCode, | ||
| method: req.method, | ||
| path: req.path, | ||
| agent: req.headers['user-agent'], |
shane-tomlinson
Sep 16, 2015
Member
Alphabetization would be nice here too.
Alphabetization would be nice here too.
| * License, v. 2.0. If a copy of the MPL was not distributed with this | ||
| * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
|
||
| /** |
shane-tomlinson
Sep 16, 2015
Member
We use the core version fetch logic in a couple of repos, think we should extract it into its own library to share?
We use the core version fetch logic in a couple of repos, think we should extract it into its own library to share?
|
Thanks @shane-tomlinson! I've addressed all of your notes, except for the query about CORS
|
|
This seems to be working OK with mozilla/fxa-local-dev#32, I think it's ready for a final r? |
| !.git* | ||
| !.eslint* | ||
| !.npmignore | ||
| !.travis.yml |
shane-tomlinson
Sep 22, 2015
Member
We would want .gitignore, .eslint, and .travis.yml updates to be noticed, wouldn't we?
We would want .gitignore, .eslint, and .travis.yml updates to be noticed, wouldn't we?
rfk
Sep 23, 2015
Author
Member
Yes, so IIUC this is saying "ignore all dot-files except the ones explicitly named here"
Yes, so IIUC this is saying "ignore all dot-files except the ones explicitly named here"
| eslintrc: '.eslintrc' | ||
| }, | ||
| files: [ | ||
| '{,bin/,config/,grunttasks/,lib/**/,test/,test/lib/mocks}*.js' |
shane-tomlinson
Sep 22, 2015
Member
Woah, I've never seen this form.
Woah, I've never seen this form.
rfk
Sep 22, 2015
Author
Member
test/lib/blanket.js is not our code so I excluded it from the checks, particularly to prevent being nagged about a missing MPL license header. I wonder if this fantastical glob syntax has a way to say "not this file" which would make it clearer...
test/lib/blanket.js is not our code so I excluded it from the checks, particularly to prevent being nagged about a missing MPL license header. I wonder if this fantastical glob syntax has a way to say "not this file" which would make it clearer...
pdehaan
Sep 22, 2015
You could try something like:
'{,bin/,config/,grunttasks/,lib/**/,test/**/,!test/lib/blanket}*.js'
Or maybe split it into two things:
'{,bin/,config/,grunttasks/,lib/**/,test/**/}*.js',
'!test/lib/blanket.js'
Or if you're saying it's because of the copyright task, exclude the blanket.js file in grunttasks/copyright.js:
src: [
'<%= eslint.files %>',
'!test/lib/blanket.js'
]
You could try something like:
'{,bin/,config/,grunttasks/,lib/**/,test/**/,!test/lib/blanket}*.js'
Or maybe split it into two things:
'{,bin/,config/,grunttasks/,lib/**/,test/**/}*.js',
'!test/lib/blanket.js'Or if you're saying it's because of the copyright task, exclude the blanket.js file in grunttasks/copyright.js:
src: [
'<%= eslint.files %>',
'!test/lib/blanket.js'
]
rfk
Sep 23, 2015
Author
Member
exclude the blanket.js file in grunttasks/copyright.js
👍 thank-you your globbiness, I shall follow this path.
exclude the blanket.js file in grunttasks/copyright.js
| api_timeout: { | ||
| doc: 'Timeout for talking to the Basket API server, in ms', | ||
| format: Number, | ||
| default: 5 * 1000 // 5 seconds |
shane-tomlinson
Sep 22, 2015
Member
We talked about using the 5 seconds format in another repo, applicable here?
We talked about using the 5 seconds format in another repo, applicable here?
rfk
Sep 23, 2015
Author
Member
nice catch, done
nice catch, done
| var startTime = Date.now(); | ||
| onFinished(res, function logSummary(err, res) { | ||
| var line = { | ||
| agent: req.headers['user-agent'], |
shane-tomlinson
Sep 22, 2015
Member
I love that you alphabetized the keys.
I love that you alphabetized the keys.
|
@rfk - there were a couple of outstanding items that @pdehaan initially brought up. I added a couple of notes, one about the config duration format, and .gitignore. All content server functional tests pass when using this repo from fxa-local-dev. Once the few nits are either explicitly ignored or taken care of, merge away! |
This commit imports the fxa-basket-proxy code from [1] as a standalone project, splitting it up into smaller chunks and adding some basic repo infrastructure and tests. The logic of the code itself is unchanged apart from some config-loading and logging tweaks. [1] https://github.com/mozilla/fxa-content-server/blob/13a59b2457d373190f1853c513604a5b72bb5106/server/bin/basket-proxy-server.js
|
Thanks @shane-tomlinson @pdehaan! Nits addressed, will merge when travis gives the final green light. |
Split out fxa-basket-proxy into a standalone project; r=shane-tomlinson
This commit imports the fxa-basket-proxy code from [1] as a standalone
project, splitting it up into smaller chunks and adding some basic
repo infrastructure and tests. The logic of the code itself is unchanged
apart from some config-loading and logging tweaks.
[1] https://github.com/mozilla/fxa-content-server/blob/13a59b2457d373190f1853c513604a5b72bb5106/server/bin/basket-proxy-server.js