Added basic release and actor API.

This commit is contained in:
ThePendulum 2020-05-20 01:11:32 +02:00
parent 6973d39cbd
commit 057362d011
18 changed files with 347 additions and 39 deletions

View File

@ -210,7 +210,7 @@
v-if="actor.hasTattoos"
class="bio-item tattoos hideable"
>
<dfn class="bio-label"><Icon icon="flower" />Tattoos</dfn>
<dfn class="bio-label"><Icon icon="lotus" />Tattoos</dfn>
<span
v-if="actor.tattoos"
@ -285,6 +285,8 @@
</div>
<div class="actor-content">
<Releases :releases="actor.releases" />
<div
v-if="actor.avatar || (actor.photos && actor.photos.length > 0)"
class="photos-container"
@ -297,8 +299,6 @@
class="compact"
/>
</div>
<Releases :releases="actor.releases" />
</div>
</div>
</div>
@ -595,15 +595,16 @@ export default {
.description {
margin: 0;
padding: 0 2rem 0 0;
padding: 0 1rem;
border-left: solid 3px var(--lighten-hint);
line-height: 1.5;
font-size: .9rem;
}
.description-logo {
display: block;
width: 15rem;
max-height: 2rem;
width: 12rem;
max-height: 1.5rem;
margin: .5rem 0 1.5rem 0;
object-fit: contain;
object-position: 0 50%;
@ -623,9 +624,9 @@ export default {
.photos-container {
min-width: 15rem;
box-sizing: border-box;
border-right: solid 1px $shadow-hint;
padding: 1rem 1.5rem 1rem 1rem;
margin: 0 .5rem 0 0;
border-left: solid 1px $shadow-hint;
padding: 1rem 1rem 1rem 1.5rem;
margin: 0 0 0 .5rem;
}
.photos.compact {

View File

@ -0,0 +1,5 @@
<!-- Generated by IcoMoon.io -->
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16">
<title>anchor</title>
<path d="M14 9v2.066c-1.258 1.285-3.016 2.526-5 2.852v-5.917h3v-1l-3-1.171c1.165-0.412 2-1.523 2-2.829 0-1.657-1.343-3-3-3s-3 1.343-3 3c0 1.306 0.835 2.417 2 2.829v0l-3 1.171v1h3v5.917c-1.984-0.326-3.742-1.567-5-2.852v-2.066h-2v1c0 2 4 6 8 6s8-4 8-6v-1h-2zM9 3c0 0.552-0.448 1-1 1s-1-0.448-1-1 0.448-1 1-1c0.552 0 1 0.448 1 1z"></path>
</svg>

After

Width:  |  Height:  |  Size: 496 B

77
assets/img/icons/lotus.svg Executable file
View File

@ -0,0 +1,77 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
inkscape:version="1.0 (4035a4fb49, 2020-05-01)"
sodipodi:docname="lotus.svg"
version="1.1"
width="511.99899"
viewBox="0 0 511.99899 352.44528"
height="352.44528"
enable-background="new 0 0 512 512"
id="Capa_1">
<metadata
id="metadata21">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<defs
id="defs19" />
<sodipodi:namedview
inkscape:current-layer="Capa_1"
inkscape:window-maximized="1"
inkscape:window-y="0"
inkscape:window-x="0"
inkscape:cy="-7.8790919"
inkscape:cx="-20.29681"
inkscape:zoom="0.59178761"
fit-margin-bottom="0"
fit-margin-right="0"
fit-margin-left="0"
fit-margin-top="0"
showgrid="false"
id="namedview17"
inkscape:window-height="876"
inkscape:window-width="1440"
inkscape:pageshadow="2"
inkscape:pageopacity="0"
guidetolerance="10"
gridtolerance="10"
objecttolerance="10"
borderopacity="1"
bordercolor="#666666"
pagecolor="#ffffff" />
<path
id="path2"
d="m 413.761,95.375 c 0.125,-9.669 -0.562,-19.474 -2.15,-29.341 l -2.439,-15.159 -16.571,2.667 c -17.418,2.803 -34.006,8.172 -49.35,15.834 5.924,14.643 10.326,29.905 13.114,45.597 17.817,-9.153 37.101,-15.829 57.396,-19.598 z" />
<path
id="path4"
d="M 50.6,259.48 C 35.702,266.695 21.928,276.384 9.791,288.348 L 0,297.999 l 8.742,8.869 c 43.526,44.155 107.489,56.213 162.182,35.983 C 121.544,330.216 79.1,300.083 50.6,259.48 Z" />
<path
id="path6"
d="m 157.007,115.069 c 2.844,-15.572 7.268,-30.719 13.205,-45.248 -15.589,-7.898 -32.476,-13.424 -50.226,-16.28 l -16.571,-2.667 -2.439,15.159 c -1.581,9.828 -2.278,19.597 -2.162,29.228 20.59,3.761 40.145,10.514 58.193,19.808 z" />
<path
id="path8"
d="m 470.768,138.745 v -16.989 h -18.496 c -33.781,0 -65.417,9.33 -92.492,25.531 0.1,2.798 0.167,5.602 0.167,8.416 0,61.432 -23.923,119.187 -67.362,162.626 l -1.114,1.115 c 98.996,-0.768 179.297,-81.527 179.297,-180.699 z" />
<path
id="path10"
d="m 502.209,288.348 c -11.899,-11.729 -25.371,-21.272 -39.934,-28.439 -28.66,40.618 -71.307,70.687 -120.875,83.149 17.06,6.28 35.293,9.505 54.03,9.384 40.853,-0.294 79.147,-16.479 107.827,-45.574 l 8.742,-8.869 z" />
<path
id="path12"
d="M 271.417,14.245 257.172,0 241.755,15.416 c -37.784,37.785 -58.594,88.022 -58.594,141.458 0,53.435 20.809,103.672 58.594,141.457 L 256,312.577 271.417,297.161 C 309.201,259.376 330.011,209.139 330.011,155.704 330.01,102.267 309.201,52.03 271.417,14.245 Z" />
<path
id="path14"
d="M 153.434,147.305 C 126.35,131.091 94.697,121.756 60.9,121.756 H 42.404 v 16.989 c 0,98.777 79.662,179.284 178.112,180.684 -43.394,-43.431 -67.292,-101.156 -67.292,-162.554 0,-3.201 0.08,-6.39 0.21,-9.57 z" />
</svg>

After

Width:  |  Height:  |  Size: 3.3 KiB

View File

@ -0,0 +1,21 @@
<svg width="25.279" height="15.242" version="1.1" viewBox="0 0 25.279 15.242" xmlns="http://www.w3.org/2000/svg">
<title>heart7</title>
<g transform="translate(-.80849 .5)" shape-rendering="auto">
<path d="m16.641 0c-1.624 0-3.034 0.911-3.75 2.249-0.716-1.338-2.126-2.249-3.75-2.249-2.347 0-4.25 1.903-4.25 4.25 0 5.75 8 9.75 8 9.75s8-4 8-9.75c0-2.347-1.903-4.25-4.25-4.25z" color="#000000" color-rendering="auto" dominant-baseline="auto" image-rendering="auto" solid-color="#000000" stop-color="#000000" style="font-feature-settings:normal;font-variant-alternates:normal;font-variant-caps:normal;font-variant-east-asian:normal;font-variant-ligatures:normal;font-variant-numeric:normal;font-variant-position:normal;font-variation-settings:normal;inline-size:0;isolation:auto;mix-blend-mode:normal;shape-margin:0;shape-padding:0;text-decoration-color:#000000;text-decoration-line:none;text-decoration-style:solid;text-indent:0;text-orientation:mixed;text-transform:none;white-space:normal"/>
<path d="m9.1406-0.5c-2.6173 0-4.75 2.1327-4.75 4.75 0 3.1069 2.1216 5.6465 4.1738 7.4102 2.0523 1.7637 4.1016 2.7871 4.1016 2.7871l0.22461 0.11133 0.22266-0.11133s2.0513-1.0234 4.1035-2.7871c2.0523-1.7637 4.1738-4.3033 4.1738-7.4102 0-2.6173-2.1327-4.75-4.75-4.75-1.5784 0-2.8859 0.85823-3.75 2.0469-0.8641-1.1886-2.1716-2.0469-3.75-2.0469zm0 1c1.437 0 2.6769 0.8039 3.3086 1.9844l0.44141 0.82422 0.44141-0.82422c0.6317-1.1805 1.8716-1.9844 3.3086-1.9844 2.0767 0 3.75 1.6733 3.75 3.75 0 2.6431-1.8784 4.9785-3.8262 6.6523-1.8356 1.5775-3.4683 2.3929-3.6738 2.498-0.20446-0.10459-1.8376-0.92003-3.6738-2.498-1.9477-1.6738-3.8262-4.0092-3.8262-6.6523 0-2.0767 1.6733-3.75 3.75-3.75z" color="#000000" color-rendering="auto" dominant-baseline="auto" image-rendering="auto" solid-color="#000000" stop-color="#000000" style="font-feature-settings:normal;font-variant-alternates:normal;font-variant-caps:normal;font-variant-east-asian:normal;font-variant-ligatures:normal;font-variant-numeric:normal;font-variant-position:normal;font-variation-settings:normal;inline-size:0;isolation:auto;mix-blend-mode:normal;shape-margin:0;shape-padding:0;text-decoration-color:#000000;text-decoration-line:none;text-decoration-style:solid;text-indent:0;text-orientation:mixed;text-transform:none;white-space:normal"/>
</g>
<g transform="translate(-1 1.5605)" fill-rule="evenodd">
<path d="m23.143 1.0605-10 5 0.93945 1.8789 10-5z" color="#000000" color-rendering="auto" dominant-baseline="auto" image-rendering="auto" shape-rendering="auto" solid-color="#000000" stop-color="#000000" style="font-feature-settings:normal;font-variant-alternates:normal;font-variant-caps:normal;font-variant-east-asian:normal;font-variant-ligatures:normal;font-variant-numeric:normal;font-variant-position:normal;font-variation-settings:normal;inline-size:0;isolation:auto;mix-blend-mode:normal;shape-margin:0;shape-padding:0;text-decoration-color:#000000;text-decoration-line:none;text-decoration-style:solid;text-indent:0;text-orientation:mixed;text-transform:none;white-space:normal"/>
<g fill-rule="evenodd" shape-rendering="auto">
<path d="m25.78 0.91622-2.3103 3.503-1.8783-3.7566z" color="#000000" color-rendering="auto" dominant-baseline="auto" image-rendering="auto" solid-color="#000000" stop-color="#000000" style="font-feature-settings:normal;font-variant-alternates:normal;font-variant-caps:normal;font-variant-east-asian:normal;font-variant-ligatures:normal;font-variant-numeric:normal;font-variant-position:normal;font-variation-settings:normal;inline-size:0;isolation:auto;mix-blend-mode:normal;shape-margin:0;shape-padding:0;text-decoration-color:#000000;text-decoration-line:none;text-decoration-style:solid;text-indent:0;text-orientation:mixed;text-transform:none;white-space:normal"/>
<path d="m21.123 0.35352 2.3125 4.625 2.8438-4.3125-0.48242-0.029297zm0.93555 0.61719 3.2227 0.19531-1.7773 2.6953z" color="#000000" color-rendering="auto" dominant-baseline="auto" image-rendering="auto" solid-color="#000000" stop-color="#000000" style="font-feature-settings:normal;font-variant-alternates:normal;font-variant-caps:normal;font-variant-east-asian:normal;font-variant-ligatures:normal;font-variant-numeric:normal;font-variant-position:normal;font-variation-settings:normal;inline-size:0;isolation:auto;mix-blend-mode:normal;shape-margin:0;shape-padding:0;text-decoration-color:#000000;text-decoration-line:none;text-decoration-style:solid;text-indent:0;text-orientation:mixed;text-transform:none;white-space:normal"/>
</g>
</g>
<g transform="translate(0 .046875)" fill-rule="evenodd">
<path d="m9.4434 7.6523-4 2 0.89453 1.7891 4-2z" color="#000000" color-rendering="auto" dominant-baseline="auto" image-rendering="auto" shape-rendering="auto" solid-color="#000000" stop-color="#000000" style="font-feature-settings:normal;font-variant-alternates:normal;font-variant-caps:normal;font-variant-east-asian:normal;font-variant-ligatures:normal;font-variant-numeric:normal;font-variant-position:normal;font-variation-settings:normal;inline-size:0;isolation:auto;mix-blend-mode:normal;shape-margin:0;shape-padding:0;text-decoration-color:#000000;text-decoration-line:none;text-decoration-style:solid;text-indent:0;text-orientation:mixed;text-transform:none;white-space:normal"/>
<g fill-rule="evenodd" shape-rendering="auto">
<path d="m3.7439 11.621-0.89443 2.6833 5.3666-4.9193-7.1554 1.3416z" color="#000000" color-rendering="auto" dominant-baseline="auto" image-rendering="auto" solid-color="#000000" stop-color="#000000" style="font-feature-settings:normal;font-variant-alternates:normal;font-variant-caps:normal;font-variant-east-asian:normal;font-variant-ligatures:normal;font-variant-numeric:normal;font-variant-position:normal;font-variation-settings:normal;inline-size:0;isolation:auto;mix-blend-mode:normal;shape-margin:0;shape-padding:0;text-decoration-color:#000000;text-decoration-line:none;text-decoration-style:solid;text-indent:0;text-orientation:mixed;text-transform:none;white-space:normal"/>
<path d="m9.084 8.9512-9.084 1.7031 3.4062 1.1348-1.1348 3.4062zm-1.7363 0.86719-3.9199 3.5937 0.6543-1.959-0.25391-0.085937-1.707-0.56836z" color="#000000" color-rendering="auto" dominant-baseline="auto" image-rendering="auto" solid-color="#000000" stop-color="#000000" style="font-feature-settings:normal;font-variant-alternates:normal;font-variant-caps:normal;font-variant-east-asian:normal;font-variant-ligatures:normal;font-variant-numeric:normal;font-variant-position:normal;font-variation-settings:normal;inline-size:0;isolation:auto;mix-blend-mode:normal;shape-margin:0;shape-padding:0;text-decoration-color:#000000;text-decoration-line:none;text-decoration-style:solid;text-indent:0;text-orientation:mixed;text-transform:none;white-space:normal"/>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 6.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.1 KiB

After

Width:  |  Height:  |  Size: 9.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.4 KiB

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.8 KiB

After

Width:  |  Height:  |  Size: 9.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.4 KiB

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 18 KiB

View File

@ -130,6 +130,73 @@ function toBaseActors(actorsOrNames, release) {
});
}
function curateActor(actor) {
if (!actor) {
return null;
}
const curatedActor = {
id: actor.id,
name: actor.name,
slug: actor.slug,
gender: actor.gender,
alias: actor.alias && {
id: actor.alias.id,
name: actor.alias.name,
gender: actor.alias.gender,
},
network: actor.network && {
id: actor.network.id,
name: actor.network.name,
slug: actor.network.slug,
},
dateOfBirth: actor.date_of_birth,
dateOfDeath: actor.date_of_death,
cup: actor.cup,
bust: actor.bust,
waist: actor.waist,
hip: actor.hip,
naturalBoobs: actor.natural_boobs,
height: actor.height,
weight: actor.weight,
eyes: actor.eyes,
hair: actor.hair,
hasTattoos: actor.has_tattoos,
hasPiercings: actor.has_piercings,
tattoos: actor.tattoos,
piercings: actor.piercings,
description: actor.description,
origin: actor.birth_country && {
country: {
alpha2: actor.birth_country.alpha2,
name: actor.birth_country.name,
alias: actor.birth_country.alias,
},
state: actor.birth_state,
city: actor.birth_city,
},
residence: actor.residence_country && {
country: {
alpha2: actor.residence_country.alpha2,
name: actor.residence_country.name,
alias: actor.residence_country.alias,
},
state: actor.residence_state,
city: actor.residence_city,
},
avatar: actor.avatar && {
id: actor.avatar.id,
path: actor.avatar.path,
width: actor.avatar.width,
height: actor.avatar.height,
size: actor.avatar.size,
source: actor.avatar.source,
},
};
return curatedActor;
}
function curateActorEntry(baseActor, batchId) {
return {
name: baseActor.name,
@ -196,7 +263,7 @@ async function curateProfile(profile) {
update: profile.update,
};
curatedProfile.description = domPurify.sanitize(profile.description.replace(/\s+/g, ' '), { ALLOWED_TAGS: [] }).trim() || null;
curatedProfile.description = domPurify.sanitize(profile.description?.replace(/\s+/g, ' '), { ALLOWED_TAGS: [] }).trim() || null;
const hasher = curatedProfile.description && blake2
.createHash('blake2b')
@ -632,7 +699,36 @@ async function associateActors(releases, batchId) {
return actors;
}
async function fetchActor(actorId) {
const actor = await knex('actors')
.select(knex.raw(`
actors.*,
row_to_json(networks) as network,
row_to_json(actor_alias) as alias,
row_to_json(birth_country) as birth_country,
row_to_json(residence_country) as residence_country,
row_to_json(media) as avatar
`))
.modify((queryBuilder) => {
if (Number.isNaN(Number(actorId))) {
queryBuilder.where('actors.slug', actorId);
return;
}
queryBuilder.where('actors.id', actorId);
})
.leftJoin('actors as actor_alias', 'actor_alias.id', 'actors.alias_for')
.leftJoin('networks', 'networks.id', 'actors.network_id')
.leftJoin('countries as birth_country', 'birth_country.alpha2', 'actors.birth_country_alpha2')
.leftJoin('countries as residence_country', 'residence_country.alpha2', 'actors.residence_country_alpha2')
.leftJoin('media', 'media.id', 'actors.avatar_media_id')
.first();
return curateActor(actor);
}
module.exports = {
associateActors,
fetchActor,
scrapeActors,
};

View File

@ -24,6 +24,7 @@ async function init() {
if (argv.actorScenes) {
const actorReleases = actors.map(actor => actor.releases).flat().filter(Boolean);
console.log(actors, actorReleases);
await storeReleases(actorReleases);
}

View File

@ -2,19 +2,121 @@
const knex = require('./knex');
async function fetchReleases(limit = 100) {
const releases = await knex('releases').limit(limit);
function curateRelease(release, withMedia = false) {
if (!release) {
return null;
}
return releases;
const network = release.site_network || release.network;
return {
id: release.id,
entryId: release.entry_id,
shootId: release.shoot_id,
title: release.title,
url: release.url,
date: release.date,
description: release.description,
duration: release.duration,
site: release.site && {
id: release.site.id,
name: release.site.name,
slug: release.site.slug,
},
network: network && {
id: network.id,
name: network.name,
slug: network.slug,
},
actors: (release.actors || []).map(actor => ({
id: actor.id,
name: actor.name,
gender: actor.gender,
})),
...(withMedia && {
poster: release.poster ? {
id: release.poster.id,
path: release.poster.path,
width: release.poster.width,
height: release.poster.height,
size: release.poster.size,
source: release.poster.source,
} : null,
photos: (release.photos || []).map(photo => ({
id: photo.id,
path: photo.path,
width: photo.width,
height: photo.height,
size: photo.size,
source: photo.source,
})),
}),
createdAt: release.created_at,
};
}
function withRelations(queryBuilder, withMedia = false) {
queryBuilder
.select(knex.raw(`
releases.id, releases.entry_id, releases.shoot_id, releases.title, releases.url, releases.date, releases.description, releases.duration, releases.created_at,
row_to_json(sites) as site,
row_to_json(networks) as network,
row_to_json(site_networks) as site_network,
json_agg(DISTINCT actors) as actors
`))
.leftJoin('sites', 'sites.id', 'releases.site_id')
.leftJoin('networks', 'networks.id', 'releases.network_id')
.leftJoin('networks as site_networks', 'site_networks.id', 'sites.network_id')
.leftJoin('releases_actors', 'releases_actors.release_id', 'releases.id')
.leftJoin('actors', 'actors.id', 'releases_actors.actor_id')
.groupBy(knex.raw(`
releases.id, releases.entry_id, releases.shoot_id, releases.title, releases.url, releases.date, releases.description, releases.duration, releases.created_at,
sites.id, networks.id, site_networks.id
`));
if (withMedia) {
queryBuilder
.select(knex.raw(`
row_to_json(posters) as poster,
json_agg(DISTINCT photos) as photos
`))
.leftJoin('releases_posters', 'releases_posters.release_id', 'releases.id')
.leftJoin('media as posters', 'posters.id', 'releases_posters.media_id')
.leftJoin('releases_photos', 'releases_photos.release_id', 'releases.id')
.leftJoin('media as photos', 'photos.id', 'releases_photos.media_id')
.groupBy('posters.id');
}
}
async function fetchRelease(releaseId) {
const release = await knex('releases')
.where('releases.id', releaseId)
.modify(withRelations, true)
.first();
return curateRelease(release, true);
}
async function fetchReleases(limit = 100) {
const releases = await knex('releases')
.modify(withRelations)
.limit(Math.min(limit, 1000));
return releases.map(release => curateRelease(release));
}
async function searchReleases(query, limit = 100) {
const releases = await knex.raw('SELECT * FROM search_releases(?) LIMIT ?;', [query, limit]);
// const releases = await knex.raw('SELECT * FROM search_releases(?) LIMIT ?;', [query, limit]);
const releases = await knex
.from(knex.raw('search_releases(?) as releases', [query]))
.modify(withRelations)
.limit(Math.min(limit, 1000));
return releases.rows;
return releases.map(release => curateRelease(release));
}
module.exports = {
fetchRelease,
fetchReleases,
searchReleases,
};

View File

@ -7,8 +7,8 @@ function include(argv) {
photos: argv.media && argv.photos,
poster: argv.media && argv.posters,
posters: argv.media && argv.posters,
releases: argv.withReleases,
scenes: argv.withReleases,
releases: argv.withScenes,
scenes: argv.withScenes,
teaser: argv.media && argv.videos && argv.teasers,
teasers: argv.media && argv.videos && argv.teasers,
trailer: argv.media && argv.videos && argv.trailers,

View File

@ -1,31 +1,18 @@
'use strict';
const { fetchActors } = require('../actors');
const { fetchActor } = require('../actors');
async function fetchActorsApi(req, res) {
const actorId = typeof req.params.actorId === 'number' ? req.params.actorId : null;
const actorSlug = typeof req.params.actorId === 'string' ? req.params.actorId : null;
async function fetchActorApi(req, res) {
const actor = await fetchActor(req.params.actorId);
if (actorId || actorSlug) {
const actors = await fetchActors({
id: actorId,
slug: actorSlug,
});
if (actors.length > 0) {
res.send(actors[0]);
return;
}
res.status(404).send();
if (actor) {
res.send({ actor });
return;
}
const actors = await fetchActors(null, req.query.limit);
res.send(actors);
res.status(404).send({ actor: null });
}
module.exports = {
fetchActors: fetchActorsApi,
fetchActor: fetchActorApi,
};

View File

@ -1,6 +1,17 @@
'use strict';
const { fetchReleases, searchReleases } = require('../releases');
const { fetchRelease, fetchReleases, searchReleases } = require('../releases');
async function fetchReleaseApi(req, res) {
const release = await fetchRelease(req.params.releaseId);
if (release) {
res.send({ release });
return;
}
res.status(404).send({ release: null });
}
async function fetchReleasesApi(req, res) {
const query = req.query.query || req.query.q;
@ -9,9 +20,10 @@ async function fetchReleasesApi(req, res) {
? await searchReleases(query, req.query.limit)
: await fetchReleases(req.query.limit);
res.send(releases);
res.send({ releases });
}
module.exports = {
fetchRelease: fetchReleaseApi,
fetchReleases: fetchReleasesApi,
};

View File

@ -15,9 +15,12 @@ const logger = require('../logger')(__filename);
const { ActorPlugins, SitePlugins, ReleasePlugins } = require('./plugins/plugins');
const {
fetchRelease,
fetchReleases,
} = require('./releases');
const { fetchActor } = require('./actors');
function initServer() {
const app = express();
const router = Router();
@ -61,6 +64,9 @@ function initServer() {
router.use(bodyParser.json({ strict: false }));
router.get('/api/releases', fetchReleases);
router.get('/api/releases/:releaseId', fetchRelease);
router.get('/api/actors/:actorId', fetchActor);
router.get('*', (req, res) => {
res.render(path.join(__dirname, '../../assets/index.ejs'), {