Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit e1e33b1

Browse filesBrowse files
committed
Add pagination to freenit endpoint
1 parent 186143c commit e1e33b1
Copy full SHA for e1e33b1

File tree

Expand file treeCollapse file tree

1 file changed

+7
-6
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+7
-6
lines changed

‎python.json

Copy file name to clipboardExpand all lines: python.json
+7-6Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,10 @@
22
"api": {
33
"prefix": "freenitapi",
44
"body": [
5-
"from typing import List",
6-
"",
7-
"import ormar",
85
"import ormar.exceptions",
9-
"from fastapi import HTTPException",
6+
"from fastapi import Header, HTTPException",
107
"from freenit.api.router import route",
8+
"from freenit.models.pagination import Page, paginate",
119
"",
1210
"from ..models.${1} import ${1/(.*)/${1:/capitalize}/}, ${1/(.*)/${1:/capitalize}/}Optional",
1311
"",
@@ -17,8 +15,11 @@
1715
"@route(\"/${1}s\", tags=tags)",
1816
"class ${1/(.*)/${1:/capitalize}/}ListAPI:",
1917
" @staticmethod",
20-
" async def get() -> List[${1/(.*)/${1:/capitalize}/}]:",
21-
" return await ${1/(.*)/${1:/capitalize}/}.objects.all()",
18+
" async def get(",
19+
" page: int = Header(default=1),",
20+
" perpage: int = Header(default=10),",
21+
" ) -> Page[${1/(.*)/${1:/capitalize}/}]:",
22+
" return await paginate(${1/(.*)/${1:/capitalize}/}.objects, page, perpage)",
2223
"",
2324
" @staticmethod",
2425
" async def post(${1}: ${1/(.*)/${1:/capitalize}/}) -> ${1/(.*)/${1:/capitalize}/}:",

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.