mirror of https://github.com/nocodb/nocodb
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
1.1 KiB
42 lines
1.1 KiB
2 years ago
|
|
||
2 years ago
|
import express from 'express';
|
||
2 years ago
|
import { Noco } from '../../../src/lib';
|
||
2 years ago
|
import cleanupMeta from './cleanupMeta';
|
||
2 years ago
|
import {cleanUpSakila, resetAndSeedSakila} from './cleanupSakila';
|
||
2 years ago
|
import { createUser } from '../factory/user';
|
||
2 years ago
|
|
||
2 years ago
|
let server;
|
||
2 years ago
|
|
||
|
const serverInit = async () => {
|
||
2 years ago
|
const serverInstance = express();
|
||
|
serverInstance.enable('trust proxy');
|
||
|
serverInstance.use(await Noco.init());
|
||
2 years ago
|
serverInstance.use(function(req, res, next){
|
||
|
// 50 sec timeout
|
||
|
req.setTimeout(500000, function(){
|
||
|
console.log('Request has timed out.');
|
||
|
res.send(408);
|
||
|
});
|
||
|
next();
|
||
|
});
|
||
2 years ago
|
return serverInstance;
|
||
2 years ago
|
};
|
||
|
|
||
2 years ago
|
const isFirstTimeRun = () => !server
|
||
2 years ago
|
|
||
2 years ago
|
export default async function () {
|
||
|
const {default: TestDbMngr} = await import('../TestDbMngr');
|
||
|
|
||
2 years ago
|
if (isFirstTimeRun()) {
|
||
2 years ago
|
await resetAndSeedSakila();
|
||
2 years ago
|
server = await serverInit();
|
||
|
}
|
||
2 years ago
|
|
||
2 years ago
|
await cleanUpSakila();
|
||
|
await cleanupMeta();
|
||
2 years ago
|
|
||
|
const { token } = await createUser({ app: server }, { roles: 'editor' });
|
||
|
|
||
2 years ago
|
return { app: server, token, dbConfig: TestDbMngr.dbConfig, sakilaDbConfig: TestDbMngr.getSakilaDbConfig() };
|
||
2 years ago
|
}
|