The HauntedHousesModule Feature Module
In this section, we'll take the first steps in building our haunted houses API by creating a
dedicated feature module: HauntedHousesModule. This module will serve as the container for
all components, services, and artifacts related to haunted houses.
This chapter will focus on the initial setup, creation, and integration of HauntedHousesModule
into the AppModule. As we progress in this course, we'll revisit HauntedHousesModule to enrich
it with additional components and functionalities.
Creating the HauntedHousesModule
Let's start by creating the file haunted_houses/houses/haunted_houses_module.py
A pest feature module is a python class decorated with the
@module decorator.
from pest import module
@module()
class HauntedHousesModule:
passFor now, the module is empty and doesn't do much.
Registering the HauntedHousesModule in the AppModule
Now that we have created the HauntedHousesModule, we need to register it in the AppModule so
that pest can load it.
from pest import module
from .houses.haunted_houses_module import HauntedHousesModule
from .hello.module import HelloModule
@module(
imports=[HelloModule, HauntedHousesModule],
)
class AppModule:
passTo register the HauntedHousesModule in the AppModule, we need to import it and add it to the
imports list of the @module decorator.
Now, HountedHousesModule is registered and will be loaded by pest when the application
starts.