|
|
@ -24,6 +24,7 @@ import mapDefaultPrimaryValue from '../helpers/mapDefaultPrimaryValue'; |
|
|
|
import { extractAndGenerateManyToManyRelations } from './metaDiffApis'; |
|
|
|
import { extractAndGenerateManyToManyRelations } from './metaDiffApis'; |
|
|
|
import { metaApiMetrics } from '../helpers/apiMetrics'; |
|
|
|
import { metaApiMetrics } from '../helpers/apiMetrics'; |
|
|
|
import { extractPropsAndSanitize } from '../helpers/extractProps'; |
|
|
|
import { extractPropsAndSanitize } from '../helpers/extractProps'; |
|
|
|
|
|
|
|
import NcConfigFactory from '../../utils/NcConfigFactory'; |
|
|
|
|
|
|
|
|
|
|
|
const nanoid = customAlphabet('1234567890abcdefghijklmnopqrstuvwxyz_', 4); |
|
|
|
const nanoid = customAlphabet('1234567890abcdefghijklmnopqrstuvwxyz_', 4); |
|
|
|
|
|
|
|
|
|
|
@ -107,6 +108,35 @@ async function projectCreate(req: Request<any, any>, res) { |
|
|
|
const ranId = nanoid(); |
|
|
|
const ranId = nanoid(); |
|
|
|
projectBody.prefix = `nc_${ranId}__`; |
|
|
|
projectBody.prefix = `nc_${ranId}__`; |
|
|
|
projectBody.is_meta = true; |
|
|
|
projectBody.is_meta = true; |
|
|
|
|
|
|
|
if (process.env.NC_MINIMAL_DBS) { |
|
|
|
|
|
|
|
const fs = require('fs'); |
|
|
|
|
|
|
|
const toolDir = NcConfigFactory.getToolDir(); |
|
|
|
|
|
|
|
const nanoidv2 = customAlphabet('1234567890abcdefghijklmnopqrstuvwxyz', 14); |
|
|
|
|
|
|
|
if (!fs.existsSync(`${toolDir}/nc_minimal_dbs`)) { |
|
|
|
|
|
|
|
fs.mkdirSync(`${toolDir}/nc_minimal_dbs`); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
const dbId = nanoidv2(); |
|
|
|
|
|
|
|
const projectTitle = DOMPurify.sanitize(projectBody.title); |
|
|
|
|
|
|
|
projectBody.prefix = ''; |
|
|
|
|
|
|
|
projectBody.bases = [ |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
type: "sqlite3", |
|
|
|
|
|
|
|
config: { |
|
|
|
|
|
|
|
client: "sqlite3", |
|
|
|
|
|
|
|
connection: { |
|
|
|
|
|
|
|
client: "sqlite3", |
|
|
|
|
|
|
|
database: projectTitle, |
|
|
|
|
|
|
|
connection: { |
|
|
|
|
|
|
|
filename: `${toolDir}/nc_minimal_dbs/${projectTitle}_${dbId}.sql`, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
useNullAsDefault: true, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
inflection_column: "camelize", |
|
|
|
|
|
|
|
inflection_table: "camelize", |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
]; |
|
|
|
|
|
|
|
} else { |
|
|
|
const db = Noco.getConfig().meta?.db; |
|
|
|
const db = Noco.getConfig().meta?.db; |
|
|
|
projectBody.bases = [ |
|
|
|
projectBody.bases = [ |
|
|
|
{ |
|
|
|
{ |
|
|
@ -117,6 +147,7 @@ async function projectCreate(req: Request<any, any>, res) { |
|
|
|
inflection_table: 'camelize', |
|
|
|
inflection_table: 'camelize', |
|
|
|
}, |
|
|
|
}, |
|
|
|
]; |
|
|
|
]; |
|
|
|
|
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
if (process.env.NC_CONNECT_TO_EXTERNAL_DB_DISABLED) { |
|
|
|
if (process.env.NC_CONNECT_TO_EXTERNAL_DB_DISABLED) { |
|
|
|
NcError.badRequest('Connecting to external db is disabled'); |
|
|
|
NcError.badRequest('Connecting to external db is disabled'); |
|
|
|