added support for sqs sample ripper when creating new products (#167)
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
import {
|
||||
SQSClient,
|
||||
SendMessageCommand,
|
||||
SendMessageCommandOutput,
|
||||
SendMessageCommandInput,
|
||||
} from '@aws-sdk/client-sqs';
|
||||
|
||||
export async function sendMessage(
|
||||
body: string,
|
||||
queueUrl: string,
|
||||
): Promise<SendMessageCommandOutput | undefined> {
|
||||
const client = new SQSClient({ region: 'eu-west-1' });
|
||||
|
||||
const params: SendMessageCommandInput = {
|
||||
MessageBody: body,
|
||||
QueueUrl: queueUrl,
|
||||
};
|
||||
const sendMessageCommand = new SendMessageCommand(params);
|
||||
|
||||
return client.send(sendMessageCommand);
|
||||
}
|
||||
+1
-21
@@ -1,9 +1,4 @@
|
||||
import {
|
||||
SQSClient,
|
||||
SendMessageCommand,
|
||||
SendMessageCommandOutput,
|
||||
SendMessageCommandInput,
|
||||
} from '@aws-sdk/client-sqs';
|
||||
import { sendMessage } from '../aws/sqs';
|
||||
|
||||
export async function sendPathChangedCmd(
|
||||
oldPath: string,
|
||||
@@ -20,18 +15,3 @@ export async function sendPathChangedCmd(
|
||||
};
|
||||
await sendMessage(JSON.stringify(msg), process.env.BERNARD_QUEUE_URL);
|
||||
}
|
||||
|
||||
export async function sendMessage(
|
||||
body: string,
|
||||
queueUrl: string,
|
||||
): Promise<SendMessageCommandOutput | undefined> {
|
||||
const client = new SQSClient({ region: 'eu-west-1' });
|
||||
|
||||
const params: SendMessageCommandInput = {
|
||||
MessageBody: body,
|
||||
QueueUrl: queueUrl,
|
||||
};
|
||||
const sendMessageCommand = new SendMessageCommand(params);
|
||||
|
||||
return client.send(sendMessageCommand);
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ import { PrintProductDefaultsAPI } from '../datasources/printproduct-defaults-ap
|
||||
import { PrintProductDefaults } from '../types/printproduct-defaults-types';
|
||||
import { GraphQLError } from 'graphql';
|
||||
import { getOrientationString, isRepeatingPattern } from '../datasources/utils';
|
||||
import { sendMessage } from '../aws/sqs';
|
||||
|
||||
const ProductBlacklist = {
|
||||
async market(parent, _args, { dataSources }) {
|
||||
@@ -223,7 +224,16 @@ export const productMutationTypeDefs = {
|
||||
batch,
|
||||
designerId,
|
||||
);
|
||||
return (<ProductAPI>dataSources.productApi).getProduct(id);
|
||||
|
||||
const product = await (<ProductAPI>dataSources.productApi).getProduct(id);
|
||||
|
||||
// Send sqs message to trigger sample ripper
|
||||
await sendMessage(
|
||||
JSON.stringify({ productId: id, artNo: product.fields.artNo }),
|
||||
process.env.SAMPLE_SQS_QUEUE_URL,
|
||||
);
|
||||
|
||||
return product;
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user