27 lines
1.4 KiB
Python

```python
from fastapi import APIRouter
from .posts import router as posts_router
from .comments import router as comments_router
from .tags import router as tags_router
from .users import router as users_router
router = APIRouter()
router.include_router(posts_router, prefix="/posts", tags=["posts"])
router.include_router(comments_router, prefix="/comments", tags=["comments"])
router.include_router(tags_router, prefix="/tags", tags=["tags"])
router.include_router(users_router, prefix="/users", tags=["users"])
```
Explanation:
1. We import the `APIRouter` class from the `fastapi` library to create a new router instance.
2. We import the routers for posts, comments, tags, and users from their respective modules (`posts.py`, `comments.py`, `tags.py`, and `users.py`).
3. We create a new `APIRouter` instance called `router`.
4. We include each of the imported routers using the `include_router` method of the main `router` instance.
- The `prefix` parameter sets the URL prefix for each router.
- The `tags` parameter is used for grouping the routes in the Swagger UI documentation.
5. This `__init__.py` file will be imported by the main FastAPI application to include all the routes from the different modules.
Note: Make sure that the `posts.py`, `comments.py`, `tags.py`, and `users.py` modules exist in the same directory (`app/api/v1/routes/`) and contain the respective router instances named `router`.