# Hooks
Ts.ED emits different events during its initialization phase (lifecycle). These lifecycle hooks provide visibility into these key life moments and the ability to act when they occur.
This schema resume the order of hooks regard to Server and Providers:

# Examples
Hooks can be used on your Server:
import {BeforeInit, Configuration} from "@tsed/common";
@Configuration({})
class Server implements BeforeInit {
async $beforeInit(): Promise<any> {
}
}
1
2
3
4
5
6
7
8
2
3
4
5
6
7
8
or on your Module or Service :
import {Module, BeforeInit} from "@tsed/common";
@Module()
export class MyModule implements BeforeInit {
async $beforeInit(): Promise<any> {
}
}
1
2
3
4
5
6
7
8
2
3
4
5
6
7
8
Note
Database connection can be performed with Asynchronous Provider since v5.26. See custom providers
Last Updated: 4/12/2021, 7:40:30 AM
Other topics
- Session & cookies
- Passport.js
- Keycloak
- TypeORM
- Mongoose
- GraphQL
- Socket.io
- Swagger
- AJV
- Multer
- Serve static files
- Templating
- AWS
- Seq
- OIDC
- Stripe
- Controllers
- Providers
- Model
- JsonMapper
- Middlewares
- Pipes
- Interceptors
- Authentication
- Hooks
- Exceptions
- Throw HTTP Exceptions
- Cache
- Hooks
- Response Filter
- Injection scopes
- Custom providers
- Custom endpoint decorator
- Testing
- Customize 404