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 Context from '../../types/express/context';
|
||||
|
||||
@@ -16,15 +17,20 @@ const createFlow = async (
|
||||
const connectionId = params?.input?.connectionId;
|
||||
const appKey = params?.input?.triggerAppKey;
|
||||
|
||||
await App.findOneByKey(appKey);
|
||||
|
||||
const flow = await context.currentUser.$relatedQuery('flows').insert({
|
||||
name: 'Name your flow',
|
||||
});
|
||||
|
||||
if (connectionId) {
|
||||
await context.currentUser
|
||||
const hasConnection = await context.currentUser
|
||||
.$relatedQuery('connections')
|
||||
.findById(connectionId)
|
||||
.throwIfNotFound();
|
||||
.findById(connectionId);
|
||||
|
||||
if (!hasConnection) {
|
||||
throw new Error('The connection does not exist!');
|
||||
}
|
||||
}
|
||||
|
||||
await Step.query().insert({
|
||||
|
Reference in New Issue
Block a user