mirror of
https://github.com/farcasclaudiu/Flowise.git
synced 2026-06-29 03:01:10 +03:00
Merge branch 'bugfix/LogPath' into bugfix/VM2-Security
# Conflicts: # README.md # packages/server/README.md
This commit is contained in:
@@ -135,9 +135,9 @@ Flowise support different environment variables to configure your instance. You
|
|||||||
| PORT | The HTTP port Flowise runs on | Number | 3000 |
|
| PORT | The HTTP port Flowise runs on | Number | 3000 |
|
||||||
| FLOWISE_USERNAME | Username to login | String |
|
| FLOWISE_USERNAME | Username to login | String |
|
||||||
| FLOWISE_PASSWORD | Password to login | String |
|
| FLOWISE_PASSWORD | Password to login | String |
|
||||||
| DEBUG | Print logs from components | Boolean |
|
| DEBUG | Print logs onto terminal/console | Boolean |
|
||||||
| LOG_PATH | Location where log files are stored | String | `your-path/Flowise/logs` |
|
| LOG_PATH | Location where log files are stored | String | `your-path/Flowise/packages/server` |
|
||||||
| LOG_LEVEL | Different levels of logs | Enum String: `error`, `info`, `verbose`, `debug` | `info` |
|
| LOG_LEVEL | Different log levels for loggers to be saved | Enum String: `error`, `info`, `verbose`, `debug` | `info` |
|
||||||
| DATABASE_PATH | Location where database is saved | String | `your-home-dir/.flowise` |
|
| DATABASE_PATH | Location where database is saved | String | `your-home-dir/.flowise` |
|
||||||
| APIKEY_PATH | Location where api keys are saved | String | `your-path/Flowise/packages/server` |
|
| APIKEY_PATH | Location where api keys are saved | String | `your-path/Flowise/packages/server` |
|
||||||
| EXECUTION_MODE | Whether predictions run in their own process or the main process | Enum String: `child`, `main` | `main` |
|
| EXECUTION_MODE | Whether predictions run in their own process or the main process | Enum String: `child`, `main` | `main` |
|
||||||
|
|||||||
@@ -38,9 +38,9 @@ Flowise support different environment variables to configure your instance. You
|
|||||||
| PORT | The HTTP port Flowise runs on | Number | 3000 |
|
| PORT | The HTTP port Flowise runs on | Number | 3000 |
|
||||||
| FLOWISE_USERNAME | Username to login | String |
|
| FLOWISE_USERNAME | Username to login | String |
|
||||||
| FLOWISE_PASSWORD | Password to login | String |
|
| FLOWISE_PASSWORD | Password to login | String |
|
||||||
| DEBUG | Print logs from components | Boolean |
|
| DEBUG | Print logs onto terminal/console | Boolean |
|
||||||
| LOG_PATH | Location where log files are stored | String | `your-path/Flowise/logs` |
|
| LOG_PATH | Location where log files are stored | String | `your-path/Flowise/packages/server` |
|
||||||
| LOG_LEVEL | Different levels of logs | Enum String: `error`, `info`, `verbose`, `debug` | `info` |
|
| LOG_LEVEL | Different log levels for loggers to be saved | Enum String: `error`, `info`, `verbose`, `debug` | `info` |
|
||||||
| DATABASE_PATH | Location where database is saved | String | `your-home-dir/.flowise` |
|
| DATABASE_PATH | Location where database is saved | String | `your-home-dir/.flowise` |
|
||||||
| APIKEY_PATH | Location where api keys are saved | String | `your-path/Flowise/packages/server` |
|
| APIKEY_PATH | Location where api keys are saved | String | `your-path/Flowise/packages/server` |
|
||||||
| EXECUTION_MODE | Whether predictions run in their own process or the main process | Enum String: `child`, `main` | `main` |
|
| EXECUTION_MODE | Whether predictions run in their own process or the main process | Enum String: `child`, `main` | `main` |
|
||||||
|
|||||||
@@ -59,9 +59,6 @@ export class App {
|
|||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
this.app = express()
|
this.app = express()
|
||||||
|
|
||||||
// Add the expressRequestLogger middleware to log all requests
|
|
||||||
this.app.use(expressRequestLogger)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async initDatabase() {
|
async initDatabase() {
|
||||||
@@ -92,6 +89,9 @@ export class App {
|
|||||||
// Allow access from *
|
// Allow access from *
|
||||||
this.app.use(cors())
|
this.app.use(cors())
|
||||||
|
|
||||||
|
// Add the expressRequestLogger middleware to log all requests
|
||||||
|
this.app.use(expressRequestLogger)
|
||||||
|
|
||||||
if (process.env.FLOWISE_USERNAME && process.env.FLOWISE_PASSWORD) {
|
if (process.env.FLOWISE_USERNAME && process.env.FLOWISE_PASSWORD) {
|
||||||
const username = process.env.FLOWISE_USERNAME
|
const username = process.env.FLOWISE_USERNAME
|
||||||
const password = process.env.FLOWISE_PASSWORD
|
const password = process.env.FLOWISE_PASSWORD
|
||||||
@@ -306,8 +306,13 @@ export class App {
|
|||||||
|
|
||||||
// Get all chatmessages from chatflowid
|
// Get all chatmessages from chatflowid
|
||||||
this.app.get('/api/v1/chatmessage/:id', async (req: Request, res: Response) => {
|
this.app.get('/api/v1/chatmessage/:id', async (req: Request, res: Response) => {
|
||||||
const chatmessages = await this.AppDataSource.getRepository(ChatMessage).findBy({
|
const chatmessages = await this.AppDataSource.getRepository(ChatMessage).find({
|
||||||
chatflowid: req.params.id
|
where: {
|
||||||
|
chatflowid: req.params.id
|
||||||
|
},
|
||||||
|
order: {
|
||||||
|
createdDate: 'ASC'
|
||||||
|
}
|
||||||
})
|
})
|
||||||
return res.json(chatmessages)
|
return res.json(chatmessages)
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ dotenv.config({ path: path.join(__dirname, '..', '..', '.env'), override: true }
|
|||||||
|
|
||||||
// default config
|
// default config
|
||||||
const loggingConfig = {
|
const loggingConfig = {
|
||||||
dir: process.env.LOG_PATH ?? path.join(__dirname, '..', '..', '..', '..', 'logs'),
|
dir: process.env.LOG_PATH ?? path.join(__dirname, '..', '..', 'logs'),
|
||||||
server: {
|
server: {
|
||||||
level: process.env.LOG_LEVEL ?? 'info',
|
level: process.env.LOG_LEVEL ?? 'info',
|
||||||
filename: 'server.log',
|
filename: 'server.log',
|
||||||
|
|||||||
@@ -57,43 +57,46 @@ const logger = createLogger({
|
|||||||
* this.app.use(expressRequestLogger)
|
* this.app.use(expressRequestLogger)
|
||||||
*/
|
*/
|
||||||
export function expressRequestLogger(req: Request, res: Response, next: NextFunction): void {
|
export function expressRequestLogger(req: Request, res: Response, next: NextFunction): void {
|
||||||
const fileLogger = createLogger({
|
const unwantedLogURLs = ['/api/v1/node-icon/']
|
||||||
format: combine(timestamp({ format: 'YYYY-MM-DD HH:mm:ss' }), format.json(), errors({ stack: true })),
|
if (req.url.includes('/api/v1/') && !unwantedLogURLs.some((url) => req.url.includes(url))) {
|
||||||
defaultMeta: {
|
const fileLogger = createLogger({
|
||||||
package: 'server',
|
format: combine(timestamp({ format: 'YYYY-MM-DD HH:mm:ss' }), format.json(), errors({ stack: true })),
|
||||||
request: {
|
defaultMeta: {
|
||||||
method: req.method,
|
package: 'server',
|
||||||
url: req.url,
|
request: {
|
||||||
body: req.body,
|
method: req.method,
|
||||||
query: req.query,
|
url: req.url,
|
||||||
params: req.params,
|
body: req.body,
|
||||||
headers: req.headers
|
query: req.query,
|
||||||
}
|
params: req.params,
|
||||||
},
|
headers: req.headers
|
||||||
transports: [
|
}
|
||||||
new transports.File({
|
},
|
||||||
filename: path.join(logDir, config.logging.express.filename ?? 'server-requests.log.jsonl'),
|
transports: [
|
||||||
level: config.logging.express.level ?? 'debug'
|
new transports.File({
|
||||||
})
|
filename: path.join(logDir, config.logging.express.filename ?? 'server-requests.log.jsonl'),
|
||||||
]
|
level: config.logging.express.level ?? 'debug'
|
||||||
})
|
})
|
||||||
|
]
|
||||||
|
})
|
||||||
|
|
||||||
const getRequestEmoji = (method: string) => {
|
const getRequestEmoji = (method: string) => {
|
||||||
const requetsEmojis: Record<string, string> = {
|
const requetsEmojis: Record<string, string> = {
|
||||||
GET: '⬇️',
|
GET: '⬇️',
|
||||||
POST: '⬆️',
|
POST: '⬆️',
|
||||||
PUT: '🖊',
|
PUT: '🖊',
|
||||||
DELETE: '❌'
|
DELETE: '❌'
|
||||||
|
}
|
||||||
|
|
||||||
|
return requetsEmojis[method] || '?'
|
||||||
}
|
}
|
||||||
|
|
||||||
return requetsEmojis[method] || '?'
|
if (req.method !== 'GET') {
|
||||||
}
|
fileLogger.info(`${getRequestEmoji(req.method)} ${req.method} ${req.url}`)
|
||||||
|
logger.info(`${getRequestEmoji(req.method)} ${req.method} ${req.url}`)
|
||||||
if (req.method !== 'GET') {
|
} else {
|
||||||
fileLogger.info(`${getRequestEmoji(req.method)} ${req.method} ${req.url}`)
|
fileLogger.http(`${getRequestEmoji(req.method)} ${req.method} ${req.url}`)
|
||||||
logger.info(`${getRequestEmoji(req.method)} ${req.method} ${req.url}`)
|
}
|
||||||
} else {
|
|
||||||
fileLogger.http(`${getRequestEmoji(req.method)} ${req.method} ${req.url}`)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
next()
|
next()
|
||||||
|
|||||||
Reference in New Issue
Block a user