# ExpressApplication Type alias
Module | import { ExpressApplication } from "@tsed/common" |
---|---|
Source | /packages/common/src/platform-express/decorators/expressApplication.ts |
# Overview
type ExpressApplication = Express.Application;
/**
* Inject the express application instance.
*
* ::: tip
* Prefer @@PlatformApplication@@ usage if you want to be compliant with the new Platform abstraction.
* :::
*
* ```typescript
* import {ExpressApplication, Service, Inject} from "@tsed/common";
*
* @Service()
* export default class OtherService {
* constructor(@ExpressApplication expressApplication: Express.Application) {}
* }
* ```
*
* @param {Type<any>} target
* @param {string} targetKey
* @param {TypedPropertyDescriptor<Function> | number} descriptor
* @returns {any}
* @decorator
* @deprecated use PlatformApplication instead of
*/
export function ExpressApplication(target: Type<any>, targetKey: string, descriptor: TypedPropertyDescriptor<Function> | number): any;
# Description
ExpressApplication
is an alias type to the Express.Application interface. It use the util registerFactory()
and let you to inject Express.Application created by the Server.
import {ExpressApplication, Service, Inject} from "@tsed/common";
@Service()
export default class OtherService {
constructor(@ExpressApplication expressApplication: Express.Application) {}
}
1
2
3
4
5
6
2
3
4
5
6
Note: TypeScript transform and store
ExpressApplication
asFunction
type in the metadata. So to inject a factory, you must use the@Inject(type)
decorator.
- Session & cookies
- Passport.js
- TypeORM
- Mongoose
- GraphQL
- Socket.io
- Swagger
- AJV
- Multer
- Serve static files
- Templating
- Throw HTTP Exceptions
- Customize 404
- AWS
- Jest
- Seq
- Controllers
- Providers
- Model
- Converters
- Middlewares
- Pipes
- Interceptors
- Authentication
- Hooks
- Injection scopes
- Custom providers
- Custom endpoint decorator
- Testing