feat: Implement admin create template API endpoint
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import Base from './base.js';
|
||||
import Flow from './flow.js';
|
||||
|
||||
class Template extends Base {
|
||||
static tableName = 'templates';
|
||||
@@ -15,6 +16,13 @@ class Template extends Base {
|
||||
updatedAt: { type: 'string' },
|
||||
},
|
||||
};
|
||||
|
||||
static async create(name, flowId) {
|
||||
const flow = await Flow.query().findById(flowId).throwIfNotFound();
|
||||
const flowData = await flow.export();
|
||||
|
||||
return this.query().insertAndFetch({ name, flowData });
|
||||
}
|
||||
}
|
||||
|
||||
export default Template;
|
||||
|
||||
Reference in New Issue
Block a user