|
|
@ -4,11 +4,18 @@ import { Request, Response } from 'express'; |
|
|
|
import { packageVersion } from 'nc-help'; |
|
|
|
import { packageVersion } from 'nc-help'; |
|
|
|
import ncMetaAclMw from '../helpers/ncMetaAclMw'; |
|
|
|
import ncMetaAclMw from '../helpers/ncMetaAclMw'; |
|
|
|
import SqlMgrv2 from '../../db/sql-mgr/v2/SqlMgrv2'; |
|
|
|
import SqlMgrv2 from '../../db/sql-mgr/v2/SqlMgrv2'; |
|
|
|
import NcConfigFactory, { defaultConnectionConfig } from '../../utils/NcConfigFactory'; |
|
|
|
import NcConfigFactory, { |
|
|
|
|
|
|
|
defaultConnectionConfig, |
|
|
|
|
|
|
|
} from '../../utils/NcConfigFactory'; |
|
|
|
import User from '../../models/User'; |
|
|
|
import User from '../../models/User'; |
|
|
|
import catchError from '../helpers/catchError'; |
|
|
|
import catchError from '../helpers/catchError'; |
|
|
|
import axios from 'axios'; |
|
|
|
import axios from 'axios'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const versionCache = { |
|
|
|
|
|
|
|
releaseVersion: null, |
|
|
|
|
|
|
|
lastFetched: null, |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
export async function testConnection(req: Request, res: Response) { |
|
|
|
export async function testConnection(req: Request, res: Response) { |
|
|
|
res.json(await SqlMgrv2.testConnection(req.body)); |
|
|
|
res.json(await SqlMgrv2.testConnection(req.body)); |
|
|
|
} |
|
|
|
} |
|
|
@ -46,19 +53,31 @@ export async function appInfo(req: Request, res: Response) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
export async function versionInfo(_req: Request, res: Response) { |
|
|
|
export async function versionInfo(_req: Request, res: Response) { |
|
|
|
const result = await axios |
|
|
|
if ( |
|
|
|
.get('https://github.com/nocodb/nocodb/releases/latest') |
|
|
|
!versionCache.lastFetched || |
|
|
|
.then((response) => { |
|
|
|
(versionCache.lastFetched && |
|
|
|
return { |
|
|
|
versionCache.lastFetched < Date.now() - 1000 * 60 * 60) |
|
|
|
currentVersion: packageVersion, |
|
|
|
) { |
|
|
|
releaseVersion: response.request.res.responseUrl.replace( |
|
|
|
versionCache.releaseVersion = await axios |
|
|
|
|
|
|
|
.get('https://github.com/nocodb/nocodb/releases/latest', { |
|
|
|
|
|
|
|
timeout: 5000, |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
.then((response) => |
|
|
|
|
|
|
|
response.request.res.responseUrl.replace( |
|
|
|
'https://github.com/nocodb/nocodb/releases/tag/', |
|
|
|
'https://github.com/nocodb/nocodb/releases/tag/', |
|
|
|
'' |
|
|
|
'' |
|
|
|
), |
|
|
|
) |
|
|
|
}; |
|
|
|
) |
|
|
|
}); |
|
|
|
.catch(() => null); |
|
|
|
|
|
|
|
versionCache.lastFetched = Date.now(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
res.json(result); |
|
|
|
const response = { |
|
|
|
|
|
|
|
currentVersion: packageVersion, |
|
|
|
|
|
|
|
releaseVersion: versionCache.releaseVersion, |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
res.json(response); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
export async function feedbackFormGet(_req: Request, res: Response) { |
|
|
|
export async function feedbackFormGet(_req: Request, res: Response) { |
|
|
@ -154,7 +173,7 @@ export async function urlToDbConfig(req: Request, res: Response) { |
|
|
|
connectionConfig = NcConfigFactory.extractXcUrlFromJdbc(url, true); |
|
|
|
connectionConfig = NcConfigFactory.extractXcUrlFromJdbc(url, true); |
|
|
|
return res.json(connectionConfig); |
|
|
|
return res.json(connectionConfig); |
|
|
|
} catch (error) { |
|
|
|
} catch (error) { |
|
|
|
return res.sendStatus(500) |
|
|
|
return res.sendStatus(500); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|