Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom router wan't used #31

Merged
merged 3 commits into from
Feb 6, 2017
Merged

Custom router wan't used #31

merged 3 commits into from
Feb 6, 2017

Conversation

maxmalov
Copy link
Contributor

@maxmalov maxmalov commented Feb 4, 2017

Description

Related Issue

inversify/InversifyJS#486

Motivation and Context

inversify/InversifyJS#486

How Has This Been Tested?

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

src/server.ts Outdated
}
});

this._app.use("/", this._router);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Probably hardcoding "/" here isn't the best part. Usually APIs have root namespace such as /api or smth. So probably additional configuration is needed. What do you guys think about that?

Copy link
Contributor

Choose a reason for hiding this comment

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

I totally agree with that.

Copy link
Member

Choose a reason for hiding this comment

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

👍

README.md Outdated
@@ -105,6 +105,16 @@ server.setErrorConfig((app) => {
});
```

### `.setRoutingConfig(routingConfig)`
Copy link
Member

Choose a reason for hiding this comment

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

Can you please add a note about the default value { rootPath: "/" } being used here.

src/server.ts Outdated
@@ -25,6 +26,9 @@ export class InversifyExpressServer {
) {
this._container = container;
this._router = customRouter || express.Router();
this._routingConfig = {
rootPath: "/"
Copy link
Member

Choose a reason for hiding this comment

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

You probably need an extra additional optional argument for the default value.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure I've got your point here, do you mean provide default routing config or default root path via optional constructor argument?

Copy link
Member

Choose a reason for hiding this comment

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

I think it is a good idea to add an optional constructor argument for routingConfig. I know they can use setRoutingConfig as well but I feel like is nicer to be able to configure everything via the constructor. What do you think? Thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, that sounds good to me. Besides there is no need for setRoutingConfig in this approach 👌

@remojansen
Copy link
Member

remojansen commented Feb 5, 2017

@maxmalov thanks for the PR 👍 I have added a couple of comments after doing the code review

src/server.ts Outdated
@@ -96,9 +101,11 @@ export class InversifyExpressServer {
router[metadata.method](metadata.path, ...metadata.middleware, handler);
});

this._app.use(controllerMetadata.path, ...controllerMetadata.middleware, router);
this._router.use(controllerMetadata.path, ...controllerMetadata.middleware, router);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, missed this newly created router. It should be replaced with custom router too.

@maxmalov
Copy link
Contributor Author

maxmalov commented Feb 5, 2017

@remojansen I've updated PR accroding to requested changes ☝️

@remojansen remojansen merged commit 74d46f3 into inversify:master Feb 6, 2017
@remojansen
Copy link
Member

remojansen commented Feb 6, 2017

@maxmalov thanks a lot for this PR 👍

@maxmalov maxmalov deleted the use-custom-router branch February 6, 2017 08:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants