mongodb-labs / full-stack-fastapi-mongodb Goto Github PK
View Code? Open in Web Editor NEWFull stack, modern web application generator. Using FastAPI, MongoDB as database, Docker, automatic HTTPS and more.
License: MIT License
Full stack, modern web application generator. Using FastAPI, MongoDB as database, Docker, automatic HTTPS and more.
License: MIT License
Hello,
I want to test the example stack, but cannot login with the [email protected]
and changethis
password.
Am I missing something?
Hi there. I've noticed that AgnosticDatabase is included in several method signatures, but it doesn't seem to be used within the methods themselves. The application appears to be functioning on AIOEngine. In my project cases, I have already removed AgnosticDatabase. If it is needed in the future, I can create a pull request to reintroduce it. Could you kindly clarify if there are plans to utilize AgnosticDatabase in the future or if it will be removed from the method signatures? Thank you.
TypeError: CRUDUser.is_active() missing 1 required positional argument: 'user'
The Error occurs when you try to login with the /oauth route using either the admin credentials or normal user credentials, The static method to check user Active status fails with missing positional argument user.
production
is not defined by project configfailed to solve: process "/bin/sh -c python -m pip install --no-cache-dir --upgrade pip "pipx==$PIPX_VERSION"\r\npipx install "hatch==$HATCH_VERSION"\r\nhatch env prune && hatch env create production\r\nchmod +x /app/worker-start.sh\r\n" did not complete successfully: exit code: 1"
Am I doing something wrong here? I definitely can be making a dumb config mistake. Default configuration to localhost.
In the /backend/app/app/schemas/base_schema.py
I found what is likely to be an error in the as_db_dict
property of BaseSchema
class. In the set literal {"identifier, id"}
the correct syntax should probably use two separate strings in the set: {"identifier", "id"}
. I did local tests and it seems not to affect the properties end result because the key "identifier"
is overwritten anyway in this case. But model_dump()
outputs a different result when using two separated string, ie: excluding the key "identifier"
from the dumped model.
class BaseSchema(BaseModel):
@property
def as_db_dict(self):
to_db = self.model_dump(
exclude_defaults=True, exclude_none=True, exclude={"identifier, id"}
)
for key in ["id", "identifier"]:
if key in self.model_dump().keys():
to_db[key] = self.model_dump()[key].hex
return to_db
Seems like this is still using the old implementation of Config
for pydantic. For example:
class RefreshToken(RefreshTokenUpdate):
class Config:
from_attributes = True
Should now be re-written as:
from pydantic import ConfigDict
class RefreshToken(RefreshTokenUpdate):
model_config = ConfigDict(from_attributes=True)
I believe you should be able to use Bump Pydantic to get a lot of these things fixed with minimal work
When attempting to log into a generated app, there are times where the frontend react state believes it has logged in, however, there is no auth token, nor profile data for a logged in user. The incorrect state leaves functionality "clickable" yet fails.
The believed issue stems from the auth.ts
file not having completed error handling on cases where the response payload from the backend fails. Adding in errorhandleres on every function in those should resolve this problem.
I'm receiving the following error during the static page generation for /, reset-password, and login when running 'docker compose build':
28.83 Generating static pages (0/16) ...
29.55
29.55 ⨯ useSearchParams() should be wrapped in a suspense boundary at page "/reset-password". Read more: https://nextjs.org/docs/messages/missing-suspense-with-csr-bailout
29.55
29.55 Error occurred prerendering page "/reset-password". Read more: https://nextjs.org/docs/messages/prerender-error
29.55
29.56 ⨯ useSearchParams() should be wrapped in a suspense boundary at page "/". Read more: https://nextjs.org/docs/messages/missing-suspense-with-csr-bailout
29.56
29.56 Error occurred prerendering page "/". Read more: https://nextjs.org/docs/messages/prerender-error
29.56
29.56
Generating static pages (4/16)
Generating static pages (8/16)
29.70
29.70 ⨯ useSearchParams() should be wrapped in a suspense boundary at page "/login". Read more: https://nextjs.org/docs/messages/missing-suspense-with-csr-bailout
29.70
29.70 Error occurred prerendering page "/login". Read more: https://nextjs.org/docs/messages/prerender-error
29.70
Generating static pages (12/16)
✓ Generating static pages (16/16)
30.28
30.28 > Export encountered errors on following paths:
30.28 /login/page: /login
30.28 /page: /
30.28 /reset-password/page: /reset-password
------
failed to solve: process "/bin/sh -c npm run build" did not complete successfully: exit code: 1
The frontend
container does not support "hot reload" for local development within the container. This is because our Dockerfile
does not have functionality for running a dev build. The solution would be to update the frontend/Dockerfile
to have both dev and prod builds that would change based on the context it is being run from.
npm install && npm run dev
or yarn install && yarn dev
pydantic.errors.PydanticUserError: model_config
cannot be used as a model field name. Use model_config
for model configuration.
Followed alI the steps for local development but containers backend
and celeryworker
didn't spin up outputting the same pydantic error.
I'm on a Mac M1 Sonoma 14.4.1
Hi! When I follow Quickstart instructions, the backend exits with the following error. I realized this after login didn't work so #34 might also be related.
2024-04-24 12:52:35 INFO:__main__:Initializing service
2024-04-24 12:52:35 INFO:__main__:Starting call to '__main__.init', this is the 1st time calling it.
2024-04-24 12:52:35 INFO:__main__:Service finished initializing
2024-04-24 12:52:40 Traceback (most recent call last):
2024-04-24 12:52:40 File "/app/app/initial_data.py", line 4, in <module>
2024-04-24 12:52:40 from app.db.init_db import init_db
2024-04-24 12:52:40 File "/app/app/db/init_db.py", line 3, in <module>
2024-04-24 12:52:40 from app import crud, schemas
2024-04-24 12:52:40 File "/app/app/crud/__init__.py", line 1, in <module>
2024-04-24 12:52:40 from .crud_user import user
2024-04-24 12:52:40 File "/app/app/crud/crud_user.py", line 7, in <module>
2024-04-24 12:52:40 from app.models.user import User
2024-04-24 12:52:40 File "/app/app/models/__init__.py", line 1, in <module>
2024-04-24 12:52:40 from .user import User
2024-04-24 12:52:40 File "/app/app/models/user.py", line 17, in <module>
2024-04-24 12:52:40 class User(Base):
2024-04-24 12:52:40 File "/app/.venv/lib/python3.11/site-packages/odmantic/model.py", line 487, in __new__
2024-04-24 12:52:40 return super().__new__(mcs, name, bases, namespace, **kwargs)
2024-04-24 12:52:40 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-04-24 12:52:40 File "/app/.venv/lib/python3.11/site-packages/odmantic/model.py", line 405, in __new__
2024-04-24 12:52:40 cls = super().__new__(mcs, name, bases, namespace, **kwargs)
2024-04-24 12:52:40 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-04-24 12:52:40 File "/app/.venv/lib/python3.11/site-packages/pydantic/_internal/_model_construction.py", line 178, in __new__
2024-04-24 12:52:40 set_model_fields(cls, bases, config_wrapper, types_namespace)
2024-04-24 12:52:40 File "/app/.venv/lib/python3.11/site-packages/pydantic/_internal/_model_construction.py", line 452, in set_model_fields
2024-04-24 12:52:40 fields, class_vars = collect_model_fields(cls, bases, config_wrapper, types_namespace, typevars_map=typevars_map)
2024-04-24 12:52:40 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-04-24 12:52:40 File "/app/.venv/lib/python3.11/site-packages/pydantic/_internal/_fields.py", line 122, in collect_model_fields
2024-04-24 12:52:40 type_hints = get_cls_type_hints_lenient(cls, types_namespace)
2024-04-24 12:52:40 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-04-24 12:52:40 File "/app/.venv/lib/python3.11/site-packages/pydantic/_internal/_typing_extra.py", line 212, in get_cls_type_hints_lenient
2024-04-24 12:52:40 hints[name] = eval_type_lenient(value, globalns, localns)
2024-04-24 12:52:40 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-04-24 12:52:40 File "/app/.venv/lib/python3.11/site-packages/pydantic/_internal/_typing_extra.py", line 224, in eval_type_lenient
2024-04-24 12:52:40 return eval_type_backport(value, globalns, localns)
2024-04-24 12:52:40 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-04-24 12:52:40 File "/app/.venv/lib/python3.11/site-packages/pydantic/_internal/_typing_extra.py", line 240, in eval_type_backport
2024-04-24 12:52:40 return typing._eval_type( # type: ignore
2024-04-24 12:52:40 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-04-24 12:52:40 File "/usr/local/lib/python3.11/typing.py", line 382, in _eval_type
2024-04-24 12:52:40 t = t.__origin__[args]
2024-04-24 12:52:40 ~~~~~~~~~~~~^^^^^^
2024-04-24 12:52:40 TypeError: type 'types.UnionType' is not subscriptable
2024-04-24 12:52:40 Traceback (most recent call last):
2024-04-24 12:52:40 File "<frozen runpy>", line 198, in _run_module_as_main
2024-04-24 12:52:40 File "<frozen runpy>", line 88, in _run_code
2024-04-24 12:52:40 File "/app/inboard/start.py", line 134, in <module>
2024-04-24 12:52:40 run_pre_start_script(logger=logger)
2024-04-24 12:52:40 File "/app/inboard/start.py", line 30, in run_pre_start_script
2024-04-24 12:52:40 subprocess.run([process, pre_start_path], check=True)
2024-04-24 12:52:40 File "/usr/local/lib/python3.11/subprocess.py", line 571, in run
2024-04-24 12:52:40 raise CalledProcessError(retcode, process.args,
2024-04-24 12:52:40 subprocess.CalledProcessError: Command '['sh', '/app/prestart.sh']' returned non-zero exit status 1.
2024-04-24 13:04:24 INFO:__main__:Initializing service
2024-04-24 13:04:24 INFO:__main__:Starting call to '__main__.init', this is the 1st time calling it.
2024-04-24 13:04:24 INFO:__main__:Service finished initializing
2024-04-24 13:04:26 Traceback (most recent call last):
2024-04-24 13:04:26 File "/app/app/initial_data.py", line 4, in <module>
2024-04-24 13:04:26 from app.db.init_db import init_db
2024-04-24 13:04:26 File "/app/app/db/init_db.py", line 3, in <module>
2024-04-24 13:04:26 from app import crud, schemas
2024-04-24 13:04:26 File "/app/app/crud/__init__.py", line 1, in <module>
2024-04-24 13:04:26 from .crud_user import user
2024-04-24 13:04:26 File "/app/app/crud/crud_user.py", line 7, in <module>
2024-04-24 13:04:26 from app.models.user import User
2024-04-24 13:04:26 File "/app/app/models/__init__.py", line 1, in <module>
2024-04-24 13:04:26 from .user import User
2024-04-24 13:04:26 File "/app/app/models/user.py", line 17, in <module>
2024-04-24 13:04:26 class User(Base):
2024-04-24 13:04:26 File "/app/.venv/lib/python3.11/site-packages/odmantic/model.py", line 487, in __new__
2024-04-24 13:04:26 return super().__new__(mcs, name, bases, namespace, **kwargs)
2024-04-24 13:04:26 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-04-24 13:04:26 File "/app/.venv/lib/python3.11/site-packages/odmantic/model.py", line 405, in __new__
2024-04-24 13:04:26 cls = super().__new__(mcs, name, bases, namespace, **kwargs)
2024-04-24 13:04:26 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-04-24 13:04:26 File "/app/.venv/lib/python3.11/site-packages/pydantic/_internal/_model_construction.py", line 178, in __new__
2024-04-24 13:04:26 set_model_fields(cls, bases, config_wrapper, types_namespace)
2024-04-24 13:04:26 File "/app/.venv/lib/python3.11/site-packages/pydantic/_internal/_model_construction.py", line 452, in set_model_fields
2024-04-24 13:04:26 fields, class_vars = collect_model_fields(cls, bases, config_wrapper, types_namespace, typevars_map=typevars_map)
2024-04-24 13:04:26 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-04-24 13:04:26 File "/app/.venv/lib/python3.11/site-packages/pydantic/_internal/_fields.py", line 122, in collect_model_fields
2024-04-24 13:04:26 type_hints = get_cls_type_hints_lenient(cls, types_namespace)
2024-04-24 13:04:26 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-04-24 13:04:26 File "/app/.venv/lib/python3.11/site-packages/pydantic/_internal/_typing_extra.py", line 212, in get_cls_type_hints_lenient
2024-04-24 13:04:26 hints[name] = eval_type_lenient(value, globalns, localns)
2024-04-24 13:04:26 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-04-24 13:04:26 File "/app/.venv/lib/python3.11/site-packages/pydantic/_internal/_typing_extra.py", line 224, in eval_type_lenient
2024-04-24 13:04:26 return eval_type_backport(value, globalns, localns)
2024-04-24 13:04:26 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-04-24 13:04:26 File "/app/.venv/lib/python3.11/site-packages/pydantic/_internal/_typing_extra.py", line 240, in eval_type_backport
2024-04-24 13:04:26 return typing._eval_type( # type: ignore
2024-04-24 13:04:26 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-04-24 13:04:26 File "/usr/local/lib/python3.11/typing.py", line 382, in _eval_type
2024-04-24 13:04:26 t = t.__origin__[args]
2024-04-24 13:04:26 ~~~~~~~~~~~~^^^^^^
2024-04-24 13:04:26 TypeError: type 'types.UnionType' is not subscriptable
2024-04-24 13:04:26 Traceback (most recent call last):
2024-04-24 13:04:26 File "<frozen runpy>", line 198, in _run_module_as_main
2024-04-24 13:04:26 File "<frozen runpy>", line 88, in _run_code
2024-04-24 13:04:26 File "/app/inboard/start.py", line 134, in <module>
2024-04-24 13:04:26 run_pre_start_script(logger=logger)
2024-04-24 13:04:26 File "/app/inboard/start.py", line 30, in run_pre_start_script
2024-04-24 13:04:26 subprocess.run([process, pre_start_path], check=True)
2024-04-24 13:04:26 File "/usr/local/lib/python3.11/subprocess.py", line 571, in run
2024-04-24 13:04:26 raise CalledProcessError(retcode, process.args,
2024-04-24 13:04:26 subprocess.CalledProcessError: Command '['sh', '/app/prestart.sh']' returned non-zero exit status 1.
To avoid logging tokens or passwords accidentally pydantic provides a nice SecretStr
model as a way to reduce these issues.
Can change instances like:
class Token(BaseModel):
access_token: str
refresh_token: Optional[str] = None
token_type: str
to
from pydantic import SecretStr
class Token(BaseModel):
access_token: SecretStr
refresh_token: Optional[SecretStr] = None
token_type: str
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.