Skip to content

Commit 5e42c0e

Browse files
committed
fix example projects
1 parent 8b482f8 commit 5e42c0e

File tree

10 files changed

+61
-19
lines changed

10 files changed

+61
-19
lines changed

examples/01-carapp/README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@ evolves to become better.
66
## Installation
77
having setup up your virtual environment,
88
```shell
9-
$(venv) pip install ellar-cli
9+
$(venv) poetry
10+
```
11+
## Project Setup
12+
```shell
13+
$(venv) poetry install
1014
```
1115

1216
## Start Development Server

examples/01-carapp/carapp/apps/car/controllers.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,16 @@ def index(self):
1919
post,
2020
render,
2121
)
22+
from ellar.openapi import ApiTags
2223

2324
from .schemas import CarListFilter, CreateCarSerializer
2425
from .services import CarRepository
2526

2627

27-
@Controller(
28-
"/car",
28+
@Controller("/car")
29+
@ApiTags(
2930
description="Example of Car Resource with <strong>Controller</strong>",
30-
tag="Controller",
31+
name="CarController",
3132
)
3233
class CarController(ControllerBase):
3334
def __init__(self, repo: CarRepository):

examples/01-carapp/carapp/apps/car/routers.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,16 @@ def index(request: Request):
2020
render,
2121
render_template,
2222
)
23+
from ellar.openapi import ApiTags
2324

2425
from .services import CarRepository
2526

26-
router = ModuleRouter(
27-
"/car-as-router",
28-
tag="Router",
27+
router = ModuleRouter("/car-as-router")
28+
tag = ApiTags(
29+
name="Router",
2930
description="Example of car Resource from a <strong>ModuleRouter</strong>",
3031
)
32+
tag(router.get_control_type())
3133

3234

3335
@dataclass

examples/01-carapp/carapp/commands.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
from ellar.common import EllarTyper, command
1+
from ellar.common import command
2+
from ellar.common.commands import EllarTyper
23

34
db = EllarTyper(name="db")
45

examples/01-carapp/carapp/root_module.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
1-
from ellar.common import (
2-
IExecutionContext,
3-
JSONResponse,
4-
Module,
5-
Response,
6-
exception_handler,
7-
)
1+
from ellar.common import IExecutionContext, Module, exception_handler
2+
from ellar.common.responses import JSONResponse, Response
83
from ellar.core import ModuleBase
94
from ellar.samples.modules import HomeModule
105

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import os
22

3-
from ellar.constants import ELLAR_CONFIG_MODULE
3+
from ellar.common.constants import ELLAR_CONFIG_MODULE
44

55
os.environ.setdefault(ELLAR_CONFIG_MODULE, "carapp.config:TestingConfig")

examples/01-carapp/pyproject.toml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1+
[tool.poetry]
2+
name = "01-carapp"
3+
version = "0.1.0"
4+
description = "A Quick Ellar Project"
5+
authors = ["Ezeudoh Tochukwu <[email protected]>"]
6+
license = "MIT"
7+
readme = "README.md"
8+
packages = [{include = "03_socketio_app"}]
9+
10+
[tool.poetry.dependencies]
11+
python = "^3.8"
12+
ellar-cli = "^0.1.8"
13+
14+
15+
[build-system]
16+
requires = ["poetry-core"]
17+
build-backend = "poetry.core.masonry.api"
18+
119
[ellar]
220
default = "carapp"
321
[ellar.projects.carapp]

examples/02-socketio-app/README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,11 @@ A quick example of how to use ellar Websocket Gateway with python-socketio libra
33

44
## Requirements
55
Python >= 3.7
6-
Starlette
7-
Injector
6+
Poetry
87

98
## Project setup
109
```
11-
pip install -r requirements.txt
10+
poetry install
1211
```
1312

1413
### Development Server

examples/02-socketio-app/pyproject.toml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1+
[tool.poetry]
2+
name = "03-socketio-app"
3+
version = "0.1.0"
4+
description = "Example of ellar with socket io"
5+
authors = ["Ezeudoh Tochukwu <[email protected]>"]
6+
license = "MIT"
7+
readme = "README.md"
8+
packages = [{include = "03_socketio_app"}]
9+
10+
[tool.poetry.dependencies]
11+
python = "^3.8"
12+
ellar-cli = "^0.1.8"
13+
14+
15+
[build-system]
16+
requires = ["poetry-core"]
17+
build-backend = "poetry.core.masonry.api"
18+
119
[ellar]
220
default = "socketio_app"
321
[ellar.projects.socketio_app]

examples/02-socketio-app/socketio_app/apps/events/templates/events/index.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@
1919
$('#log').append('<br>Received: ' + msg.data);
2020
});
2121

22+
socket.on('error', function(msg) {
23+
console.error("Error from server", {...msg})
24+
});
25+
2226
// event handler for server sent data
2327
// the data is displayed in the "Received" section of the page
2428
// handlers for the different forms in the page

0 commit comments

Comments
 (0)