feat: Implement admin create template API endpoint

This commit is contained in:
Faruk AYDIN
2025-02-21 17:49:15 +01:00
parent c573205a56
commit 72436f7d3b
5 changed files with 102 additions and 0 deletions

View File

@@ -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;