52-Nodejs Course 2023: Events: Http Events
Tags: node, typescript, mongodb, fastify
Published: 2022-11-09 13:14:09

---
title: 52-Nodejs Course 2023: Events: Http Events
published: true
description: 
series: Nodejs Course 2023
tags: nodejs, typescript, mongodb, fastify
cover_image: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mpz2xshwvemdevp5515c.png
# Use a ratio of 100:42 for best results.
---

So we saw in our previous article how to use the events in the database. Now we will see how to use the events in the request.

## Request Events

Requests will have many events actually, let's see it.

* `validation`: Validation has also multiple events, let's see them:
  * `validation.validating`: This event is fired when the validation is started.
  * `validation.pass`: This event is fired when the validation is successful.
  * `validation.failed`: This event is fired when the validation is failed.
  * `validation.done`: This event is fired when the validation is done either successful or failed.
* `request`: Requests events list
  * `request.executingMiddleware`: This event is fired before executing all the middlewares.
  * `request.executedMiddleware`: This event is fired after executing all the middlewares.
  * `request.executingAction`: This event is fired before the action is executed.
  * `request.executedAction`: This event is fired after the action is executed and before the response is sent.
* `response`: Response events list
  * `response.sending`: Fired when the response is about to be sent.
  * `response.sent`: Fired when the response has been sent.
  * `response.success`: Fired when the response has been sent and the status code is `2xx`.
  * `response.successCreate`: Fired when the response has been sent and the status code is `201`.
  * `response.badRequest`: Fired when the response has been sent and the status code is `400`.
  * `response.unauthorized`: Fired when the response has been sent and the status code is `401`.
  * `response.throttled`: Fired when the response has been sent and the status code is `429`, which means the request has been throttled.
  * `response.forbidden`: Fired when the response has been sent and the status code is `403`.
  * `response.notFound`: Fired when the response has been sent and the status code is `404`.
  * `response.serverError`: Fired when the response has been sent and the status code is `500`.
  * `response.error`: Fired when the response has been sent and the status code is `4xx` or `5xx`.

Too Many Events? Yes, but it's very useful. Let's see how to use them.

So we have here mainly three types of events:

* `validation`: This series of events is by the `Validator` class.
* `request`: This series of events is by the `Request` class.
* `response`: This series of events is by the `Response` class.

Each one of them has a different set of events, based on the situation of the event we'll start handle the event trigger.

## 🎨 Conclusion

We just introduced our Http Events types that will be used in our project, in our next article we'll start implementing first the `validation` events.

## 🚀 Project Repository

You can find the latest updates of this project on [Github](https://github.com/hassanzohdy/nodejs-2023)

## 😍 Join our community

Join our community on [Discord](https://discord.gg/pb2vmdfhGf) to get help and support (Node Js 2023 Channel).

## 🎞️ Video Course (Arabic Voice)

If you want to learn this course in video format, you can find it on [Youtube](https://www.youtube.com/playlist?list=PLGO8ntvxgiZMJc7RN2lIq9WmMOlWZGzmz), the course is in Arabic language.

## 💰 Bonus Content 💰

You may have a look at these articles, it will definitely boost your knowledge and productivity.

General Topics

* [Event Driven Architecture: A Practical Guide in Javascript](https://dev.to/hassanzohdy/event-driven-architecture-the-best-paradigm-that-i-love-to-work-with-in-javascript-and-node-js-1gnk)
* [Best Practices For Case Styles: Camel, Pascal, Snake, and Kebab Case In Node And Javascript](https://dev.to/hassanzohdy/best-practices-for-case-styles-camel-pascal-snake-and-kebab-case-in-node-and-javascript-55oi)
* [After 6 years of practicing MongoDB, Here are my thoughts on MongoDB vs MySQL
](https://dev.to/hassanzohdy/after-6-years-of-practicing-mongodb-here-are-my-thoughts-on-mongodb-vs-mysql-574b)

Packages & Libraries

* [Collections: Your ultimate Javascript Arrays Manager](https://dev.to/hassanzohdy/collections-your-ultimate-javascript-array-handler-3o15)
* [Supportive Is: an elegant utility to check types of values in JavaScript](https://dev.to/hassanzohdy/supportive-is-an-elegant-utility-to-check-types-of-values-in-javascript-1b3e)
* [Localization: An agnostic i18n package to manage localization in your project](https://dev.to/hassanzohdy/mongez-localization-the-simplest-way-to-translate-your-website-regardless-your-favorite-framework-4gi3)

 React Js Packages

* [useFetcher: easiest way to fetch data in React Js](https://dev.to/hassanzohdy/usefetcher-the-easiest-way-to-fetch-data-in-react-45o9)

Courses (Articles)

* [React Js: Let"s Create File Manager With React Js and Node Js](https://dev.to/hassanzohdy/lets-create-a-file-manager-from-scratch-with-react-and-typescript-chapter-i-a-good-way-to-expand-your-experience-5g4k)