feat: validate app input in createFlow
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
import App from '../../models/app';
|
||||||
import Step from '../../models/step';
|
import Step from '../../models/step';
|
||||||
import Context from '../../types/express/context';
|
import Context from '../../types/express/context';
|
||||||
|
|
||||||
@@ -16,15 +17,20 @@ const createFlow = async (
|
|||||||
const connectionId = params?.input?.connectionId;
|
const connectionId = params?.input?.connectionId;
|
||||||
const appKey = params?.input?.triggerAppKey;
|
const appKey = params?.input?.triggerAppKey;
|
||||||
|
|
||||||
|
await App.findOneByKey(appKey);
|
||||||
|
|
||||||
const flow = await context.currentUser.$relatedQuery('flows').insert({
|
const flow = await context.currentUser.$relatedQuery('flows').insert({
|
||||||
name: 'Name your flow',
|
name: 'Name your flow',
|
||||||
});
|
});
|
||||||
|
|
||||||
if (connectionId) {
|
if (connectionId) {
|
||||||
await context.currentUser
|
const hasConnection = await context.currentUser
|
||||||
.$relatedQuery('connections')
|
.$relatedQuery('connections')
|
||||||
.findById(connectionId)
|
.findById(connectionId);
|
||||||
.throwIfNotFound();
|
|
||||||
|
if (!hasConnection) {
|
||||||
|
throw new Error('The connection does not exist!');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
await Step.query().insert({
|
await Step.query().insert({
|
||||||
|
Reference in New Issue
Block a user