Skip to content

Commit

Permalink
Reland "refactor: proxy GitHub webhook to apiland" (#340)
Browse files Browse the repository at this point in the history
  • Loading branch information
crowlKats committed Jun 14, 2023
1 parent 8815f05 commit 3edce11
Show file tree
Hide file tree
Showing 27 changed files with 26 additions and 5,907 deletions.
222 changes: 4 additions & 218 deletions API.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## POST /webhook/gh/:module

This API endpoint recieves webhooks from GitHub. The `module` parameter in the
This API endpoint receives webhooks from GitHub. The `module` parameter in the
URL is the name of the module. Both `application/json` and
`application/x-www-url-formencoded` content types are accepted.

Expand Down Expand Up @@ -71,221 +71,7 @@ OR
}
```

## GET /modules
## Other endpoints

This API endpoint can be used to get a list of all the modules in the registry.

### Request

There are some query parameters that change the request:

- `limit` is the amount of results to display per page of the response
(default 20)
- `page` is the page to display (default 1)
- `query` is a query to use for filtering the list (not set by default)
- `sort` orders the results in a specific order. The accepted values are
`oldest`, `newest`, `stars` and `random`. If a query is present in the
request, this parameter is ignored and defaults to the strongest match. The
`random` option invalidates the `query` and a `page` parameters.
- `simple` toggles the result payload to a simpler output. Invalidates all other
parameters.

### Response

#### Headers

`content-type`: `application/json`

#### Body

##### 200 OK

```json
{
"success": true,
"data": {
"total_count": 763,
"results": [
{
"name": "oak",
"description": "A middleware framework for Deno's http server, including a router middleware.",
"star_count": 400
},
{
"name": "oak_middleware",
"description": "A collection of middleware for the oak middleware framework.",
"star_count": 30
}
]
}
}
```

##### 200 OK -- simple

```json
["amq","atenas","atenas_cli","auto_bind", ...]
```

##### 400 Bad Request

```json
{
"success": false,
"info": "internal server error"
}
```

## GET /modules/:name

This API endpoint can be used to get a specific module by name.

### Request

The `name` parameter in the URL is the name of the module.

### Response

#### Headers

`content-type`: `application/json`

#### Body

##### 200 OK

```json
{
"success": true,
"data": {
"name": "oak",
"description": "A middleware framework for Deno's http server, including a router middleware.",
"star_count": 400
}
}
```

##### 400 Bad Request

```json
{
"success": false,
"error": "no module name specified"
}
```

##### 404 Not Found

```json
{
"success": false,
"error": "module not found"
}
```

## GET /builds/:id

This API endpoint can be used to get the status for a module build status. You
can find the build ID in the `status_url` from the webhook execution response.

### Request

The `id` parameter URL is the build id in the database generate after the
webhook is successfully executed.

### Response

#### Headers

`content-type`: `application/json`

#### Body

##### 200 OK

```json
{
"success": true,
"data": {
"build": {
"id": "5f7e25960063be5000264881",
"created_at": "2020-10-07T20:31:18.986Z",
"options": {
"type": "github",
"moduleName": "wperron_test",
"repository": "wperron-rand/testing",
"ref": "v0.6.0",
"version": "v0.6.0"
},
"status": "success",
"message": "Published module.",
"stats": {
"total_files": 2,
"skipped_due_to_size": [],
"total_size": 300
}
}
}
}
```

##### 400 Bad Request

```json
{
"success": false,
"error": "no build id provided"
}
```

##### 404 Not Found

```json
{
"success": false,
"error": "build not found"
}
```

## GET /stats

This API endpoint can be used to get the general stats from the registry.

### Request

### Response

#### Headers

`content-type`: `application/json`

#### Body

##### 200 OK

```json
{
"success": true,
"data": {
"total_count": 1226,
"total_versions": 8359,
"recently_added_modules": [
{
"name": "postcss_import",
"description": "postcss-import plugin for Deno",
"star_count": 0,
"created_at": "2020-11-06T14:39:50.187Z"
},
...
],
"recently_uploaded_versions": [
{
"name": "nkeys",
"version": "v1.0.0-8",
"created_at": "2020-11-06T16:24:08.619Z"
},
...
]
}
}
```
For any other endpoints, please reference the
[documentation for apiland.deno.dev](https://redocly.github.io/redoc/?url=https://apiland.deno.dev/~/spec)
2 changes: 1 addition & 1 deletion api/async/publish.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export async function handler(

// send a webhook request to apiland to do further indexing of the module
// this is temporary until apiland subsumes the functionality of registry2
const res = await fetch(apilandURL, {
const res = await fetch(apilandURL + "/publish", {
method: "POST",
body: JSON.stringify({
event: "create",
Expand Down
Loading

0 comments on commit 3edce11

Please sign in to comment.