@@ -29,12 +29,14 @@ pip install ellar
2929## Create a project
3030To create an ellar project, you need to have a ` pyproject.toml ` available on your root directory.
3131This is necessary for ellar to store some ` metadata ` about your project.
32+
3233### Step 1
3334For Pip Users, you need to create ` pyproject.toml ` file
3435``` shell
3536touch pyproject.toml
3637```
3738If you are using ` Poetry ` , you are ready to go
39+
3840### Step 2
3941Run the ellar create project cli command,
4042``` shell
@@ -51,6 +53,7 @@ ellar runserver --reload
5153Now go to [ http://127.0.0.1:8000 ] ( http://127.0.0.1:8000 )
5254![ Swagger UI] ( img/ellar_framework.png )
5355
56+
5457## Create a project module
5558A project module is a project app defining a group of controllers or services including templates and static files.
5659So, now we have a project created, lets add an app to the project.
@@ -59,7 +62,7 @@ ellar create-module car
5962```
6063
6164## Add Schema
62- In ` car. schema.py ` , lets add some serializer for car input and output data
65+ In ` car/ schema.py ` , lets add some serializer for car input and output data
6366``` python
6467from ellar.serializer import Serializer
6568
@@ -74,7 +77,7 @@ class RetrieveCarSerializer(CarSerializer):
7477```
7578
7679## Add Services
77- In ` car. services.py ` , lets create a dummy repository ` CarDummyDB ` to manage our car data.
80+ In ` car/ services.py ` , lets create a dummy repository ` CarDummyDB ` to manage our car data.
7881``` python
7982import typing as t
8083import uuid
@@ -127,7 +130,7 @@ class CarDummyDB:
127130 return self ._data.pop(idx)
128131```
129132## Add Controller
130- In ` car. controllers.py ` , lets create ` CarController `
133+ In ` car/ controllers.py ` , lets create ` CarController `
131134
132135``` python
133136import typing as t
@@ -175,7 +178,7 @@ class CarController(ControllerBase):
175178
176179```
177180## Register Service and Controller
178- In ` car. module.py ` , lets register ` CarController ` and ` CarDummyDB `
181+ In ` car/ module.py ` , lets register ` CarController ` and ` CarDummyDB `
179182
180183``` python
181184from ellar.common import Module
@@ -198,9 +201,27 @@ class CarModule(ModuleBase):
198201 pass
199202```
200203
204+ ## Registering Module
205+ Ellar is not aware of ` CarModule ` yet, so we need to add it to the ` modules ` list of ` ApplicationModule ` at the ` carsite/root_module.py ` .
206+ ``` python
207+ from ellar.common import Module, exception_handler
208+ from ellar.core import ModuleBase
209+ from ellar.core.connection import Request
210+ from ellar.core.response import JSONResponse, Response
201211
202- ## Enabling OpenAPI
203- To start up openapi, we need to go back to project folder in the ` carsite.server.py `
212+ from ellar.samples.modules import HomeModule
213+ from .apps.car.module import CarModule
214+
215+
216+ @Module (modules = [HomeModule, CarModule])
217+ class ApplicationModule (ModuleBase ):
218+ @exception_handler (404 )
219+ def exception_404_handler (cls , request : Request, exc : Exception ) -> Response:
220+ return JSONResponse(dict (detail = " Resource not found." ))
221+
222+ ```
223+ ## Enabling OpenAPI Docs
224+ To start up openapi, we need to go back to project folder in the ` server.py `
204225then add the following below.
205226``` python
206227import os
0 commit comments