mirror of
https://github.com/farcasclaudiu/Flowise.git
synced 2026-06-28 13:00:56 +03:00
Feature/extract import all (#2796)
* use existing route to get all chatflows * add export all chatflows functionality * add read exported all chatflows json file functionality * add save chatflows functionality in server * chore rename saveChatflows to importChatflows and others * chore rewrite snackbar message * fix import chatflows when no data in chatflows db * add handle when import file array length is 0 * chore update and add meaning comment in importChatflows * update method of storing flowdata for importChatflows function * Refresh/redirect to chatflows when import is successful * fix lint --------- Co-authored-by: Ilango <rajagopalilango@gmail.com>
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
import { Request, Response, NextFunction } from 'express'
|
||||
import chatflowsService from '../../services/chatflows'
|
||||
import { ChatFlow } from '../../database/entities/ChatFlow'
|
||||
import { createRateLimiter } from '../../utils/rateLimit'
|
||||
import { getApiKey } from '../../utils/apiKey'
|
||||
import { InternalFlowiseError } from '../../errors/internalFlowiseError'
|
||||
import { NextFunction, Request, Response } from 'express'
|
||||
import { StatusCodes } from 'http-status-codes'
|
||||
import { ChatFlow } from '../../database/entities/ChatFlow'
|
||||
import { InternalFlowiseError } from '../../errors/internalFlowiseError'
|
||||
import { ChatflowType } from '../../Interface'
|
||||
import chatflowsService from '../../services/chatflows'
|
||||
import { getApiKey } from '../../utils/apiKey'
|
||||
import { createRateLimiter } from '../../utils/rateLimit'
|
||||
|
||||
const checkIfChatflowIsValidForStreaming = async (req: Request, res: Response, next: NextFunction) => {
|
||||
try {
|
||||
@@ -105,6 +105,16 @@ const saveChatflow = async (req: Request, res: Response, next: NextFunction) =>
|
||||
}
|
||||
}
|
||||
|
||||
const importChatflows = async (req: Request, res: Response, next: NextFunction) => {
|
||||
try {
|
||||
const chatflows: Partial<ChatFlow>[] = req.body.Chatflows
|
||||
const apiResponse = await chatflowsService.importChatflows(chatflows)
|
||||
return res.json(apiResponse)
|
||||
} catch (error) {
|
||||
next(error)
|
||||
}
|
||||
}
|
||||
|
||||
const updateChatflow = async (req: Request, res: Response, next: NextFunction) => {
|
||||
try {
|
||||
if (typeof req.params === 'undefined' || !req.params.id) {
|
||||
@@ -167,6 +177,7 @@ export default {
|
||||
getChatflowByApiKey,
|
||||
getChatflowById,
|
||||
saveChatflow,
|
||||
importChatflows,
|
||||
updateChatflow,
|
||||
getSinglePublicChatflow,
|
||||
getSinglePublicChatbotConfig
|
||||
|
||||
Reference in New Issue
Block a user