Skip to content

Commit ba539eb

Browse files
authored
Merge pull request #7 from uriafranko/feature/mongo_support
init mongo support
2 parents 4fe3a1a + 719ee63 commit ba539eb

File tree

29 files changed

+702
-137
lines changed

29 files changed

+702
-137
lines changed
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: Release Package
2+
3+
on:
4+
workflow_dispatch:
5+
permissions:
6+
users:
7+
- ItayTheDar
8+
inputs:
9+
increment_version:
10+
description: 'Create a new beta release, deploy to TestPyPI, and install the package'
11+
12+
env:
13+
VERSION_FILE_PATH: nest/__init__.py
14+
CHANGELOG_FILE_PATH: CHANGELOG.md
15+
16+
jobs:
17+
run-tests:
18+
uses: ./.github/workflows/tests.yaml
19+
20+
release-package:
21+
runs-on: ubuntu-latest
22+
needs: run-tests
23+
permissions:
24+
contents: write
25+
26+
steps:
27+
- name: Checkout repository
28+
uses: actions/checkout@v3
29+
with:
30+
token: ${{ secrets.RELEASE_GIT_TOKEN }}
31+
32+
- name: Install python
33+
uses: actions/setup-python@v4
34+
with:
35+
python-version: "3.10"
36+
37+
- name: Install python dependencies
38+
run: |
39+
pip install --upgrade pip
40+
pip install -r requirements-release.txt
41+
42+
- name: Build package
43+
run: python -m build
44+
45+
- name: Publish package to TestPyPI
46+
run: |
47+
python -m twine upload dist/* -r testpypi -u ${{ secrets.TEST_PYPI_API_USER }} -p ${{ secrets.TEST_PYPI_API_TOKEN }}
48+
49+
- name: Install test package
50+
run: |
51+
pip install --index-url https://test.pypi.org/simple/ --no-deps pynest-api
52+
53+
# import to check if package is installed correctly
54+
python -c "import nest"
55+
56+
- name: Copy pip url
57+
run: |
58+
echo "pip install --index-url https://test.pypi.org/simple/ --no-deps pynest-api"
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# PyNest service
2+
3+
This is a template for a PyNest service.
4+
5+
## Start Service
6+
7+
## Step 1 - Create environment
8+
9+
- install requirements:
10+
11+
```bash
12+
pip install -r requirements
13+
```
14+
15+
## Step 2 - start service local
16+
17+
1. Run service with main method
18+
19+
```bash
20+
python main.py
21+
```
22+
2. Run service using uvicorn
23+
24+
```bash
25+
uvicorn "app:app" --host "0.0.0.0" --port "80" --reload
26+
```
27+
28+
## Step 3 - Send requests
29+
30+
Go to the fastapi docs and use your api endpoints - http://127.0.0.1/docs

examples/nest_mongo_products/__init__.py

Whitespace-only changes.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
from orm_config import config
2+
from nest.core.app import App
3+
from src.examples.examples_module import ExamplesModule
4+
5+
app = App(
6+
description="PyNest service",
7+
modules=[
8+
ExamplesModule,
9+
]
10+
)
11+
12+
13+
@app.on_event("startup")
14+
async def startup():
15+
await config.create_all()
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import uvicorn
2+
3+
if __name__ == '__main__':
4+
uvicorn.run(
5+
'app:app',
6+
host="0.0.0.0",
7+
port=8890,
8+
reload=True
9+
)
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
from nest.core.database.base_odm import OdmService
2+
from src.examples.examples_entity import Examples
3+
import os
4+
from dotenv import load_dotenv
5+
6+
load_dotenv()
7+
8+
9+
config = OdmService(
10+
db_type="mongodb",
11+
config_params={
12+
"db_name": os.getenv("DB_NAME"),
13+
"host": os.getenv("DB_HOST"),
14+
"port": os.getenv("DB_PORT"),
15+
},
16+
document_models=[Examples]
17+
)
18+
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
anyio==3.6.2
2+
click==8.1.3
3+
fastapi==0.95.1
4+
fastapi-utils==0.2.1
5+
greenlet==2.0.2
6+
h11==0.14.0
7+
idna==3.4
8+
pydantic==1.10.7
9+
python-dotenv==1.0.0
10+
sniffio==1.3.0
11+
SQLAlchemy==1.4.48
12+
starlette==0.26.1
13+
typing_extensions==4.5.0
14+
uvicorn==0.22.0
15+
pynest-api==0.0.3
16+

examples/nest_mongo_products/src/__init__.py

Whitespace-only changes.

examples/nest_mongo_products/src/examples/__init__.py

Whitespace-only changes.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
from nest.core import Controller, Get, Post, Depends
2+
3+
from src.examples.examples_service import ExamplesService
4+
from src.examples.examples_model import Examples
5+
6+
7+
@Controller("examples")
8+
class ExamplesController:
9+
10+
service: ExamplesService = Depends(ExamplesService)
11+
12+
@Get("/get_examples")
13+
async def get_examples(self):
14+
return await self.service.get_examples()
15+
16+
@Post("/add_examples")
17+
async def add_examples(self, examples: Examples):
18+
return await self.service.add_examples(examples)
19+

0 commit comments

Comments
 (0)