Skip to content

configurable directory support for component and middleware#171

Closed
ashwinik001 wants to merge 8 commits intostrongloop:masterfrom
ashwinik001:component-and-middleware-rootpath-configuration
Closed

configurable directory support for component and middleware#171
ashwinik001 wants to merge 8 commits intostrongloop:masterfrom
ashwinik001:component-and-middleware-rootpath-configuration

Conversation

@ashwinik001
Copy link
Copy Markdown
Contributor

Hi,

In one of my project because of increasing number of configuration files due to number of deployment environments, I needed to separate out the app-config, datasources, middleware, component-config in separate folders. Hence, this PR.

It was a simple change to start the support for making component-config and middleware root directory configurable.

Please review.

Thanks.

@slnode
Copy link
Copy Markdown

slnode commented Feb 3, 2016

Can one of the admins verify this patch? To accept patch and trigger a build add comment ".ok\W+to\W+test."

@bajtos
Copy link
Copy Markdown
Member

bajtos commented Feb 4, 2016

@slnode ok to test

@bajtos
Copy link
Copy Markdown
Member

bajtos commented Feb 4, 2016

Hi @dopeddude, thank you for the pull request. Could you please add unit-tests to verify your new change and prevent regressions in the future?

@ashwinik001
Copy link
Copy Markdown
Contributor Author

@bajtos : sure, I will. Thanks.

I will update my PR to include the unit-tests.

@ashwinik001
Copy link
Copy Markdown
Contributor Author

Hi @bajtos ,

I have updated my code to include some unit-tests.

Please review and let me know your thoughts on it.

Regards.

@bajtos
Copy link
Copy Markdown
Member

bajtos commented Feb 10, 2016

@dopeddude thank you for the update, I'll take a look.

Could you please sign our CLA in the mean time? I cannot land the patch without that.

https://cla.strongloop.com/agreements/strongloop/loopback-boot

@ashwinik001
Copy link
Copy Markdown
Contributor Author

@bajtos : I have signed the CLA.

it('Suports `middlewareRootDir` Option And ' +
'emits middleware instructions', function() {
testMiddlewareRegistration('loopback/server/middleware/url-not-found',
sourceFileForUrlNotFound, true);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I find it rather difficult to understand what's happening under the hood and how is this different from the test above, because the single true argument does not convey almost any information.

I believe one test is enough to verify that middleware registration looks at the correct json file, there is no need to test all different flavours of middleware name, thus testMiddlewareRegistration can remain unmodified.

it('supports `middlewareRootDir` option', function() {
  var middlewareJson = {
    custom: {
      'loopback#urlNotFound': {}
    }
  };
  var customDir = path.resolve(appdir.PATH, 'custom');
  fs.mkdirsSync(customDir);
  fs.writeJsonSync(path.resolve(customDir, 'middleware.json'), middlewareJson);

  var instructions = boot.compile({
    appRootDir: appdir.PATH,
    middlewareRootDir: path.resolve(appdir.PATH, 'custom')
  });

  expect(instructions.middleware).to.eql([{
    sourceFile: sourceFileForUrlNotFound,
    config: { phase: 'custom' }
  }]);
);

@bajtos
Copy link
Copy Markdown
Member

bajtos commented Jun 13, 2016

@dopeddude I sincerely apologise for the long delay here. If you are still keen to finish, then please simplify the new tests per my comments above. Let me know what do you think!

@slnode
Copy link
Copy Markdown

slnode commented Jun 13, 2016

Can one of the admins verify this patch? To accept patch and trigger a build add comment ".ok\W+to\W+test."

@slnode
Copy link
Copy Markdown

slnode commented Jun 28, 2016

Can one of the admins verify this patch?

1 similar comment
@slnode
Copy link
Copy Markdown

slnode commented Jun 28, 2016

Can one of the admins verify this patch?

@ashwinik001
Copy link
Copy Markdown
Contributor Author

Hi, @bajtos, apologies for the delay.
I have updated the code as per your comments. Could you please take a look.
Thanks.

@bajtos
Copy link
Copy Markdown
Member

bajtos commented Jul 27, 2016

Landed via 1382e8a, thank you @dopeddude for the contribution and your patience with us.

@bajtos
Copy link
Copy Markdown
Member

bajtos commented Jul 27, 2016

Released as loopback-boot@2.21.0

davidcheung pushed a commit that referenced this pull request Sep 12, 2016
davidcheung pushed a commit that referenced this pull request Sep 16, 2016
davidcheung pushed a commit that referenced this pull request Sep 16, 2016
davidcheung pushed a commit that referenced this pull request Sep 19, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants