📚 Added an endpoint for fetching volume metadata
This commit is contained in:
@@ -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
|
||||||
|
|||||||
@@ -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;
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user