📚 Added an endpoint for fetching volume metadata

This commit is contained in:
2021-09-21 13:06:09 -07:00
parent 14a16ead50
commit e54bbb5c5c
2 changed files with 35 additions and 13 deletions

View File

@@ -64,7 +64,7 @@ const brokerConfig: BrokerOptions = {
// More info: https://moleculer.services/docs/0.14/networking.html // More info: https://moleculer.services/docs/0.14/networking.html
// Note: During the development, you don't need to define it because all services will be loaded locally. // Note: During the development, you don't need to define it because all services will be loaded locally.
// In production you can set it via `TRANSPORTER=nats://localhost:4222` environment variable. // In production you can set it via `TRANSPORTER=nats://localhost:4222` environment variable.
transporter: null, // "NATS" transporter: "NATS", // "NATS"
// Define a cacher. // Define a cacher.
// More info: https://moleculer.services/docs/0.14/caching.html // More info: https://moleculer.services/docs/0.14/caching.html

View File

@@ -12,7 +12,7 @@ export default class ComicVineService extends Service {
this.parseServiceSchema({ this.parseServiceSchema({
name: "comicvine", name: "comicvine",
actions: { actions: {
fetchSeries: { fetchResource: {
rest: "/fetchresource", rest: "/fetchresource",
params: { params: {
format: { type: "string", optional: false }, format: { type: "string", optional: false },
@@ -48,12 +48,13 @@ export default class ComicVineService extends Service {
"?api_key=" + "?api_key=" +
CV_API_KEY, CV_API_KEY,
params: ctx.params, params: ctx.params,
transformResponse: r => { transformResponse: (r) => {
const matches = JSON.parse(r); const matches = JSON.parse(r);
return matchScorer( return matchScorer(
matches.results, matches.results,
ctx.params.scorerConfiguration.searchQuery, ctx.params.scorerConfiguration.searchQuery,
ctx.params.scorerConfiguration.rawFileDetails ctx.params.scorerConfiguration
.rawFileDetails
); );
}, },
headers: { Accept: "application/json" }, headers: { Accept: "application/json" },
@@ -65,15 +66,17 @@ export default class ComicVineService extends Service {
search: { search: {
rest: "/search", rest: "/search",
params: {}, params: {},
handler: async (ctx: Context<{ handler: async (
format: string; ctx: Context<{
sort: string; format: string;
query: string; sort: string;
fieldList: string; query: string;
limit: string; fieldList: string;
offset: string; limit: string;
resources: string; offset: string;
}>) => { resources: string;
}>
) => {
const response = await axios.request({ const response = await axios.request({
url: url:
CV_BASE_URL + CV_BASE_URL +
@@ -87,6 +90,25 @@ export default class ComicVineService extends Service {
return data; return data;
}, },
}, },
getVolumes: {
rest: "POST /getVolumes",
params: {},
handler: async (
ctx: Context<{
volumeURI: string;
data: {};
}>
) => {
const response = await axios.request({
url:
ctx.params.volumeURI + "?api_key=" + CV_API_KEY,
params: ctx.params.data,
headers: { Accept: "application/json" },
});
const { data } = response;
return data;
},
},
}, },
}); });
} }