📚 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
|
||||
// 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.
|
||||
transporter: null, // "NATS"
|
||||
transporter: "NATS", // "NATS"
|
||||
|
||||
// Define a cacher.
|
||||
// More info: https://moleculer.services/docs/0.14/caching.html
|
||||
|
||||
@@ -12,7 +12,7 @@ export default class ComicVineService extends Service {
|
||||
this.parseServiceSchema({
|
||||
name: "comicvine",
|
||||
actions: {
|
||||
fetchSeries: {
|
||||
fetchResource: {
|
||||
rest: "/fetchresource",
|
||||
params: {
|
||||
format: { type: "string", optional: false },
|
||||
@@ -48,12 +48,13 @@ export default class ComicVineService extends Service {
|
||||
"?api_key=" +
|
||||
CV_API_KEY,
|
||||
params: ctx.params,
|
||||
transformResponse: r => {
|
||||
transformResponse: (r) => {
|
||||
const matches = JSON.parse(r);
|
||||
return matchScorer(
|
||||
matches.results,
|
||||
ctx.params.scorerConfiguration.searchQuery,
|
||||
ctx.params.scorerConfiguration.rawFileDetails
|
||||
ctx.params.scorerConfiguration
|
||||
.rawFileDetails
|
||||
);
|
||||
},
|
||||
headers: { Accept: "application/json" },
|
||||
@@ -65,15 +66,17 @@ export default class ComicVineService extends Service {
|
||||
search: {
|
||||
rest: "/search",
|
||||
params: {},
|
||||
handler: async (ctx: Context<{
|
||||
format: string;
|
||||
sort: string;
|
||||
query: string;
|
||||
fieldList: string;
|
||||
limit: string;
|
||||
offset: string;
|
||||
resources: string;
|
||||
}>) => {
|
||||
handler: async (
|
||||
ctx: Context<{
|
||||
format: string;
|
||||
sort: string;
|
||||
query: string;
|
||||
fieldList: string;
|
||||
limit: string;
|
||||
offset: string;
|
||||
resources: string;
|
||||
}>
|
||||
) => {
|
||||
const response = await axios.request({
|
||||
url:
|
||||
CV_BASE_URL +
|
||||
@@ -87,6 +90,25 @@ export default class ComicVineService extends Service {
|
||||
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