()
| 22 | } |
| 23 | |
| 24 | const initTemplates = async () => { |
| 25 | try { |
| 26 | const templates = createTemplateObjects() |
| 27 | if (!templates) { |
| 28 | throw Error('Failed to read template data') |
| 29 | } |
| 30 | // TODO: This will cause horizontal scaling issues. We should use a unique index on the folder field instead. |
| 31 | |
| 32 | await FullTemplateModel.collection.drop().catch((err) => {}) |
| 33 | await FullTemplateModel.create(templates) |
| 34 | } catch (error) { |
| 35 | console.error('Error adding templates:', error) |
| 36 | } |
| 37 | |
| 38 | try { |
| 39 | const macros = createMacroObjects(); |
| 40 | if (!macros) { |
| 41 | throw Error('Failed to read macros data') |
| 42 | } |
| 43 | // TODO: This will cause horizontal scaling issues. We should use a unique index on the folder field instead. |
| 44 | await MacroModel.collection.drop().catch((err) => {}) |
| 45 | await MacroModel.create(macros) |
| 46 | } catch (error) { |
| 47 | console.error('Error adding macros:', error) |
| 48 | } |
| 49 | } |
| 50 | |
| 51 | export const initMongoDB = async () => { |
| 52 | try { |
no test coverage detected