Releases: inversify/inversify-express-utils
5.2.1
Update package.json
5.2.0
Issue 590 (#97) * Added test case * WIP implementation * Implemented issue 590
5.1.2
Fixed issues when no pram metadata is available (#90)
5.1.1
improved docs (#89)
5.1.0
Implemented route map util (#88) * Implemented route map util * Renamed path * lock dep
5.0.0
New features
-
Reduced amount of required boilerplate code:
- The
@injectable
annotation is no longer required in classes annotated with@controller
. - Declaring bindings is no longer required in classes annotated with
@controller
.
- The
-
Support for
HttpContext
:- The current
HttpContext
can be accessed from a controller that extends theBaseHttpController
class or that gets it injected using the@injectHttpContext
decorator. - The current
HttpContext
can be accessed from middleware that extends theBaseMiddleware
class.
- The current
-
Support for
BaseMiddleware
. ExtendingBaseMiddleware
allow us to inject dependencies into a middleware function. ExtendingBaseMiddleware
also allows us to access the currentHttpContext
from a middleware function. -
Support for
AuthProvider
. If you provide an implementation ofAuthProvider
, you will be able to access the current user via the currentHttpContext
.
Breaking changes
- The
@injectable
annotation is no longer required in classes annotated with@controller
. - Declaring bindings is no longer required in classes annotated with
@controller
.
import "./controllers/some_controller"
) the class is declared and the metadata is generated. If you don't import it the metadata is never generated and therefore the controller is not found. An example of this can be found here.
If you run the application multiple times within a shared runtime process (e.g. unit testing) you might need to clean up the existing metadata before each test.
import { cleanUpMetadata } from "inversify-express-utils";
describe("Some Component", () => {
beforeEach(() => {
cleanUpMetadata();
});
it("Some test case", () => {
// ...
});
});
You can find an example of this in our unit tests.
5.0.0-beta.1
Breaking change
- The
@injectable
annotation is no longer required in classes annotated with@controller
. - Declaring bindings is no longer required in classes annotated with
@controller
.
⚠️ Note: declaring a binding is not required for Controllers but it is required to import the controller at least once. When the controller file is imported (e.g.import "./controllers/some_controller"
) the class is declared and the metadata is generated. If you don't import it the metadata is never generated and therefore the controller is not found.
- If you run the application multiple times within a shared runtime process (e.g. unit testing) you might need to clean up the existing metadata before each test.
import { cleanUpMetadata } from "inversify-express-utils";
describe("Integration Tests:", () => {
beforeEach((done) => {
cleanUpMetadata();
container = new Container();
done();
});
describe("Routing & Request Handling:", () => {
it("should work for async controller methods", (done) => {
// ...
done();
});
});
});
You can find an example of this in our unit tests.
An example of migration can be found at inversify/inversify-express-example#257.
4.2.2
Fixed path issue (#74)
4.2.1
4.2.0
- Implemented HttpContext support