-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #133 from mekanix/feature/project
Better project generation
- Loading branch information
Showing
6 changed files
with
59 additions
and
131 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,10 @@ | ||
import pathlib | ||
import subprocess | ||
|
||
from prompt_toolkit import prompt | ||
|
||
|
||
def main(): | ||
path = pathlib.Path(__file__).parent.resolve() | ||
project_name = prompt("Name of the project: ") | ||
subprocess.run(["bin/freenit.sh", "project", project_name]) | ||
subprocess.run([f"{path}/bin/freenit.sh", "project", project_name]) |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
__version__ = "0.0.1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,21 @@ | ||
from contextlib import asynccontextmanager | ||
from fastapi import FastAPI | ||
|
||
import freenit.config | ||
|
||
from .api import api | ||
from .config import getConfig | ||
|
||
config = getConfig() | ||
app = FastAPI() | ||
config = freenit.config.getConfig() | ||
|
||
|
||
@app.on_event("startup") | ||
async def startup() -> None: | ||
@asynccontextmanager | ||
async def lifespan(_: FastAPI): | ||
if not config.database.is_connected: | ||
await config.database.connect() | ||
|
||
|
||
@app.on_event("shutdown") | ||
async def shutdown() -> None: | ||
yield | ||
if config.database.is_connected: | ||
await config.database.disconnect() | ||
|
||
|
||
app.mount("/api/v1", api) | ||
app = FastAPI(lifespan=lifespan) | ||
app.mount(config.api_root, api) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
[build-system] | ||
requires = ["hatchling"] | ||
build-backend = "hatchling.build" | ||
|
||
[project] | ||
name = "NAME" | ||
dynamic = ["version"] | ||
description = "REST API framework based on FastAPI" | ||
readme = "README.md" | ||
license = {file = "LICENSE"} | ||
requires-python = ">=3.8" | ||
dependencies = [ | ||
"freenit[ormar]", | ||
] | ||
authors = [ | ||
{name = "John Doe", email = "[email protected]"}, | ||
] | ||
classifiers = [ | ||
"Development Status :: 4 - Beta", | ||
"Intended Audience :: Developers", | ||
"Topic :: Internet :: WWW/HTTP", | ||
"Environment :: Web Environment", | ||
"Programming Language :: Python" | ||
] | ||
|
||
[project.optional-dependencies] | ||
beanie = ["freenit[beanie]"] | ||
dev = ["freenit[dev]"] | ||
ldap = ["freenit[ldap]"] | ||
ormar = ["freenit[ormar]"] | ||
test = ["freenit[test]"] | ||
|
||
[project.urls] | ||
Homepage = "https://freenit.org" | ||
Repository = "https://github.com/freenit-framework/backend" | ||
|
||
[tool.hatch.version] | ||
path = "PROJECT/__init__.py" |