Skip to content

Commit 5cf2400

Browse files
authored
feat: add routes support for AppAPI 3.0.0 (#3)
Signed-off-by: Andrey Borysenko <[email protected]>
1 parent 3d076ec commit 5cf2400

File tree

4 files changed

+34
-9
lines changed

4 files changed

+34
-9
lines changed

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,23 +53,23 @@ register28:
5353
docker exec master-stable28-1 sudo -u www-data php occ app_api:app:unregister ui_example --silent --force || true
5454
docker exec master-stable28-1 rm -rf /tmp/ui_example_l10n && docker cp l10n master-stable28-1:/tmp/ui_example_l10n
5555
docker exec master-stable28-1 sudo -u www-data php occ app_api:app:register ui_example manual_install --json-info \
56-
"{\"id\":\"ui_example\",\"name\":\"UI Example\",\"daemon_config_name\":\"manual_install\",\"version\":\"1.0.0\",\"secret\":\"12345\",\"port\":9035,\"scopes\":[\"OCC_COMMAND\", \"NOTIFICATIONS\"],\"system_app\":0, \"translations_folder\":\"\/tmp\/ui_example_l10n\"}" \
56+
"{\"id\":\"ui_example\",\"name\":\"UI Example\",\"daemon_config_name\":\"manual_install\",\"version\":\"1.0.0\",\"secret\":\"12345\",\"port\":9035,\"scopes\":[\"OCC_COMMAND\", \"NOTIFICATIONS\"],\"system_app\":0, \"translations_folder\":\"\/tmp\/ui_example_l10n\", \"routes\": [{\"url\":\"img\\\/.*\",\"verb\":\"GET, POST, PUT, DELETE\",\"access_level\":1,\"headers_to_exclude\":[]},{\"url\":\"js\\\/.*\",\"verb\":\"GET, POST, PUT, DELETE\",\"access_level\":1,\"headers_to_exclude\":[]}, {\"url\":\"css\\\/.*\",\"verb\":\"GET, POST, PUT, DELETE\",\"access_level\":1,\"headers_to_exclude\":[]}, {\"url\":\"api\\\/.*\",\"verb\":\"GET, POST, PUT, DELETE\",\"access_level\":1,\"headers_to_exclude\":[]}]}" \
5757
--force-scopes --wait-finish
5858

5959
.PHONY: register29
6060
register29:
6161
docker exec master-stable29-1 sudo -u www-data php occ app_api:app:unregister ui_example --silent --force || true
6262
docker exec master-stable29-1 rm -rf /tmp/ui_example_l10n && docker cp l10n master-stable29-1:/tmp/ui_example_l10n
6363
docker exec master-stable29-1 sudo -u www-data php occ app_api:app:register ui_example manual_install --json-info \
64-
"{\"id\":\"ui_example\",\"name\":\"UI Example\",\"daemon_config_name\":\"manual_install\",\"version\":\"1.0.0\",\"secret\":\"12345\",\"port\":9035,\"scopes\":[\"OCC_COMMAND\", \"NOTIFICATIONS\"],\"system_app\":0, \"translations_folder\":\"\/tmp\/ui_example_l10n\"}" \
64+
"{\"id\":\"ui_example\",\"name\":\"UI Example\",\"daemon_config_name\":\"manual_install\",\"version\":\"1.0.0\",\"secret\":\"12345\",\"port\":9035,\"scopes\":[\"OCC_COMMAND\", \"NOTIFICATIONS\"], \"translations_folder\":\"\/tmp\/ui_example_l10n\", \"routes\": [{\"url\":\"img\\\/.*\",\"verb\":\"GET, POST, PUT, DELETE\",\"access_level\":1,\"headers_to_exclude\":[]},{\"url\":\"js\\\/.*\",\"verb\":\"GET, POST, PUT, DELETE\",\"access_level\":1,\"headers_to_exclude\":[]}, {\"url\":\"css\\\/.*\",\"verb\":\"GET, POST, PUT, DELETE\",\"access_level\":1,\"headers_to_exclude\":[]}, {\"url\":\"api\\\/.*\",\"verb\":\"GET, POST, PUT, DELETE\",\"access_level\":2,\"headers_to_exclude\":[]}]}" \
6565
--force-scopes --wait-finish
6666

6767
.PHONY: register
6868
register:
6969
docker exec master-nextcloud-1 sudo -u www-data php occ app_api:app:unregister ui_example --silent --force || true
7070
docker exec master-nextcloud-1 rm -rf /tmp/ui_example_l10n && docker cp l10n master-nextcloud-1:/tmp/ui_example_l10n
7171
docker exec master-nextcloud-1 sudo -u www-data php occ app_api:app:register ui_example manual_install --json-info \
72-
"{\"id\":\"ui_example\",\"name\":\"UI Example\",\"daemon_config_name\":\"manual_install\",\"version\":\"1.0.0\",\"secret\":\"12345\",\"port\":9035,\"scopes\":[\"OCC_COMMAND\", \"NOTIFICATIONS\"],\"system_app\":0, \"translations_folder\":\"\/tmp\/ui_example_l10n\"}" \
72+
"{\"id\":\"ui_example\",\"name\":\"UI Example\",\"daemon_config_name\":\"manual_install\",\"version\":\"1.0.0\",\"secret\":\"12345\",\"port\":9035,\"scopes\":[\"OCC_COMMAND\", \"NOTIFICATIONS\"], \"translations_folder\":\"\/tmp\/ui_example_l10n\", \"routes\": [{\"url\":\"img\\\/.*\",\"verb\":\"GET, POST, PUT, DELETE\",\"access_level\":1,\"headers_to_exclude\":[]},{\"url\":\"js\\\/.*\",\"verb\":\"GET, POST, PUT, DELETE\",\"access_level\":1,\"headers_to_exclude\":[]}, {\"url\":\"css\\\/.*\",\"verb\":\"GET, POST, PUT, DELETE\",\"access_level\":1,\"headers_to_exclude\":[]}, {\"url\":\"api\\\/.+\",\"verb\":\"GET, POST, PUT, DELETE\",\"access_level\":1,\"headers_to_exclude\":[]}]}" \
7373
--force-scopes --wait-finish
7474

7575
.PHONY: translation_templates

appinfo/info.xml

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,31 @@
2828
<value>OCC_COMMAND</value>
2929
<value>NOTIFICATIONS</value>
3030
</scopes>
31-
<system>false</system>
31+
<routes>
32+
<route>
33+
<url>img\/.*</url>
34+
<verb>GET</verb>
35+
<access_level>USER</access_level>
36+
<headers_to_exclude>[]</headers_to_exclude>
37+
</route>
38+
<route>
39+
<url>js\/.*</url>
40+
<verb>GET</verb>
41+
<access_level>USER</access_level>
42+
<headers_to_exclude>[]</headers_to_exclude>
43+
</route>
44+
<route>
45+
<url>css\/.*</url>
46+
<verb>GET</verb>
47+
<access_level>USER</access_level>
48+
<headers_to_exclude>[]</headers_to_exclude>
49+
</route>
50+
<route>
51+
<url>api\/.*</url>
52+
<verb>GET,POST,PUT,DELETE</verb>
53+
<access_level>USER</access_level>
54+
<headers_to_exclude>[]</headers_to_exclude>
55+
</route>
56+
</routes>
3257
</external-app>
3358
</info>

lib/main.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ class Button1Format(BaseModel):
254254
initial_value: str
255255

256256

257-
@APP.post("/verify_initial_value")
257+
@APP.post("/api/verify_initial_value")
258258
async def verify_initial_value(
259259
input1: Button1Format,
260260
):
@@ -264,7 +264,7 @@ async def verify_initial_value(
264264
)
265265

266266

267-
@APP.post("/test_menu")
267+
@APP.post("/api/test_menu")
268268
async def test_menu_handler(
269269
file: UiActionFileInfo,
270270
nc: Annotated[NextcloudApp, Depends(nc_app)],
@@ -336,7 +336,7 @@ async def occ_stream(data: OccData):
336336
return StreamingResponse(fake_data_streamer(data), status_code=200, media_type="text/plain")
337337

338338

339-
@APP.post("/nextcloud_file")
339+
@APP.post("/api/nextcloud_file")
340340
async def nextcloud_file(
341341
args: dict,
342342
):

src/store/example.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const getters = {
2020

2121
const actions = {
2222
verifyInitialStateValue(context, value) {
23-
axios.post(generateUrl(`${APP_API_PROXY_URL_PREFIX}/${EX_APP_ID}/verify_initial_value`), {
23+
axios.post(generateUrl(`${APP_API_PROXY_URL_PREFIX}/${EX_APP_ID}/api/verify_initial_value`), {
2424
initial_value: value,
2525
})
2626
.then((res) => {
@@ -38,7 +38,7 @@ const actions = {
3838
},
3939

4040
sendNextcloudFileToExApp(context, fileInfo) {
41-
axios.post(generateUrl(`${APP_API_PROXY_URL_PREFIX}/${EX_APP_ID}/nextcloud_file`), {
41+
axios.post(generateUrl(`${APP_API_PROXY_URL_PREFIX}/${EX_APP_ID}/api/nextcloud_file`), {
4242
file_info: fileInfo,
4343
})
4444
.then(() => {

0 commit comments

Comments
 (0)