Added rudimentary API documentation to README.

This commit is contained in:
DebaucheryLibrarian 2020-10-17 22:54:00 +02:00
parent e6c52002f0
commit ca22aedaaa
3 changed files with 20 additions and 4 deletions

View File

@ -87,6 +87,22 @@ To generate thumbnails for new logos and tag photos, install ImageMagick and run
* `--no-save`: Do not store retrieved information in local database, forcing re-fetch. * `--no-save`: Do not store retrieved information in local database, forcing re-fetch.
* `--level`: Change log level to `silly`, `verbose`, `info`, `warn` or `error`. * `--level`: Change log level to `silly`, `verbose`, `info`, `warn` or `error`.
### API
A GraphQL API is available at `/graphql`, and a REST API is available at the following endpoints:
* `/api/scenes`: Fetch the latest releases. Supports search with `query` or `q` parameter;
* `/api/scenes/{ID}`: Fetch scene by ID.
* `/api/actors`: Fetch actors. Search `query` or `q` parameter required.
* `/api/actors/{ID|slug}`: Fetch detailed actor by ID or slug.
* `/api/entities`: Fetch networks and channels. Use the `type` parameter to filter for either `channel`s or `network`s.
* `/api/entities/{ID|slug}`: Fetch detailed network or channel by ID. To fetch by slug, the `type` parameter must specify either `channel` or `network`.
* `/api/channels`: Fetch channel entities. Supports the `q` or `query` parameter for searching.
* `/api/channels/{ID|slug}`: Fetch detailed channel by ID or slug.
* `/api/networks`: Fetch networks. Supports a `q` or `query` parameter for searching.
* `/api/networks/{ID|slug}`: Fetch detailed network by ID or slug.
* `/api/tags`: Fetch tags.
* `/api/tags/{ID|slug|name}`: Fetch detailed tag by ID, slug or name.
## Supported networks & sites ## Supported networks & sites
896 channels on 64 networks, continuously expanding! 896 channels on 64 networks, continuously expanding!

View File

@ -166,7 +166,7 @@ async function fetchEntities(type, limit) {
} }
async function searchEntities(query, type, limit) { async function searchEntities(query, type, limit) {
const entities = await knex const entities = knex
.select(knex.raw(` .select(knex.raw(`
entities.*, entities.*,
COALESCE(json_agg(tags) FILTER (WHERE tags.id IS NOT NULL), '[]') as tags, COALESCE(json_agg(tags) FILTER (WHERE tags.id IS NOT NULL), '[]') as tags,
@ -184,9 +184,10 @@ async function searchEntities(query, type, limit) {
.groupBy('entities.id', 'parents.id') .groupBy('entities.id', 'parents.id')
.limit(limit || 100); .limit(limit || 100);
return curateEntities(entities); console.log(entities.toString());
}
return curateEntities(await entities);
}
module.exports = { module.exports = {
curateEntity, curateEntity,

View File

@ -19,7 +19,6 @@ async function fetchTagsApi(req, res) {
res.send({ tags }); res.send({ tags });
} }
module.exports = { module.exports = {
fetchTag: fetchTagApi, fetchTag: fetchTagApi,
fetchTags: fetchTagsApi, fetchTags: fetchTagsApi,