Project

General

Profile

Repository API » History » Version 1

jahoti, 07/24/2021 12:50 AM

1 1 jahoti
# Repository API
2
3
{{toc}}
4
5
## Under current schema
6
7
### Fetching script info
8
9
`hydrilla.example.com/script?n=helloscript` returns:
10
```
11
{
12
    "name": "helloscript",
13
    "location": "somedirectory/hello.js",
14
    "sha256":   "e4dbe4dba40e8bd159fb987b0f0cf2c243d7e6b9b9dc792e58dedf1fae38b0a1"
15
}
16
```
17
or 404 Not Found in case "helloscript" script does not exist. `hydrilla.example.com/content/somedirecotry/hello.js` holds the actual script source.
18
19
### Fetching bag info
20
21
`hydrilla.example.com/bag?n=hellobag` returns:
22
```
23
{
24
    "name": "hellobag",
25
    "components":   [["s", "helloscript"], ["s", "someotherscript"], ["b", "somebag"]]
26
}
27
```
28
or 404 Not Found in case "hellobag" bag does not exist.
29
30
### Fetching pattern info
31
32
`hydrilla.example.com/pattern?n=https://example.org/a/*` returns:
33
```
34
{
35
    "pattern":  "https://example.org/a/*",
36
    "payload":  ["b", "hellobag"]
37
}
38
```
39
or 404 Not Found in case requested pattern does not exist.
40
41
### Querying patterns that match given URL
42
43
Finally, `hydrilla.example.com/query?n=https://example.org/a/b` returns:
44
```
45
[{
46
        "pattern":  "https://example.org/a/*",
47
        "payload":  ["b", "hellobag"]
48
    }, {
49
        "pattern":  "https://example.org/a/b",
50
        "payload":  ["b", "fix_by_mrcooldev"]
51
    }, {
52
        "pattern":  "https://example.org/a/b",
53
        "payload":  ["b", "mod_by_missgreatskill"]
54
    }]
55
```
56
or in case no patterns match the requested URL, it returns just:
57
```
58
[]
59
```
60
or in case the URL is of wrong format it returns some HTTP error.
61
62
## Under the upcoming schema
63
64
Also, once we get to do the redesign discussed in the <https://hachettebugs.koszko.org/boards/1/topics/56>, the JSON will look more like the following.
65
66
### Fetching bag info
67
```
68
{
69
    "name": "hellobag",
70
    "dependencies": ["someotherbag", "yetanotherone"],
71
    "scripts": [{
72
            "location": "somedirectory/hello.js",
73
            "sha256":   "e4dbe4dba40e8bd159fb987b0f0cf2c243d7e6b9b9dc792e58dedf1fae38b0a1"
74
        }, {
75
            "location": "somedirectory/bye.js",
76
            "sha256":   "5099d27284c2257d2983450585cbd4bede6475519755508047e213d985cbc7c9"
77
        }]
78
}
79
```
80
81
### Fetching resource info
82
83
`hydrilla.example.com/resource?n=example_org_minimal` returns:
84
```
85
{
86
    "name": "example_org_minimal",
87
    "description": "suckless something something",
88
    "mappings": [{
89
            "pattern":  "https://example.org/a/*",
90
            "payload":  "some_KISS_bag"
91
        }, {
92
            "pattern":  "https://example.org/t/*",
93
            "payload":  "another_KISS_bag"
94
        }]
95
}
96
```
97
or 404 Not Found in case "example_org_minimal" resource does not exist.
98
99
### Querying patterns that match given url
100
101
`hydrilla.example.com/query?n=https://example.org/a/b` returns:
102
```
103
[{
104
    "name": "example_org_minimal",
105
    "description": "suckless something something",
106
    "mappings": [{
107
            "pattern":  "https://example.org/a/*",
108
            "payload":  "some_KISS_bag"
109
        }, {
110
            "pattern":  "https://example.org/t/*",
111
            "payload":  "another_KISS_bag"
112
        }]
113
}, {
114
    "name": "example_org_experimantal",
115
    "description": "[...]\npatches are WANTED!",
116
    "mappings": [{
117
            "pattern":  "https://example.org/**",
118
            "payload":  "quick_and_dirty_bag"
119
        }]
120
}]
121
```