feat: Support create, read, delete variables in Public API (#10241)

This commit is contained in:
Iván Ovejero
2024-07-30 14:58:07 +02:00
committed by GitHub
parent f87854f8db
commit af695ebf93
11 changed files with 345 additions and 1 deletions

View File

@@ -0,0 +1,12 @@
import { VariablesRepository } from '@/databases/repositories/variables.repository';
import { generateNanoId } from '@/databases/utils/generators';
import { randomString } from 'n8n-workflow';
import Container from 'typedi';
export async function createVariable(key = randomString(5), value = randomString(5)) {
return await Container.get(VariablesRepository).save({ id: generateNanoId(), key, value });
}
export async function getVariableOrFail(id: string) {
return await Container.get(VariablesRepository).findOneOrFail({ where: { id } });
}