1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-02-04 00:18:01 +01:00

fix: convert files to typescript

This commit is contained in:
Ivar Conradi Østhus 2021-09-14 19:30:11 +02:00
parent d3b9bcb7be
commit 436f295dc5
No known key found for this signature in database
GPG Key ID: 31AC596886B0BD09
5 changed files with 17 additions and 24 deletions

View File

@ -1,7 +1,5 @@
'use strict';
const express = require('express');
const { createTestConfig } = require('../test/config/test-config');
import express from 'express';
import { createTestConfig } from '../test/config/test-config';
jest.mock(
'./routes',

View File

@ -1,12 +0,0 @@
'use strict';
const parseDbUrl = require('parse-database-url');
module.exports = {
getDb: () => {
const url =
process.env.TEST_DATABASE_URL ||
'postgres://unleash_user:passord@localhost:5432/unleash_test';
return parseDbUrl(url);
},
};

View File

@ -0,0 +1,8 @@
import parseDbUrl from 'parse-database-url';
export const getDbConfig = (): object => {
const url =
process.env.TEST_DATABASE_URL ||
'postgres://unleash_user:passord@localhost:5432/unleash_test';
return parseDbUrl(url);
};

View File

@ -2,7 +2,7 @@ import { EventEmitter } from 'events';
import { migrateDb } from '../../../migrator';
import { createStores } from '../../../lib/db';
import { createDb } from '../../../lib/db/db-pool';
import dbConfig from './database-config';
import { getDbConfig } from './database-config';
import { createTestConfig } from '../../config/test-config';
import dbState from './database.json';
import { LogProvider } from '../../../lib/logger';
@ -77,12 +77,12 @@ export interface ITestDb {
}
export default async function init(
databaseSchema: String = 'test',
databaseSchema: string = 'test',
getLogger: LogProvider = noLoggerProvider,
): Promise<ITestDb> {
const config = createTestConfig({
db: {
...dbConfig.getDb(),
...getDbConfig(),
pool: { min: 2, max: 8 },
schema: databaseSchema,
ssl: false,

View File

@ -1,7 +1,4 @@
'use strict';
module.exports = () => {
const _perms = ['ADMIN'];
const adminUser = (): { hook: (app: any) => void } => {
return {
hook(app) {
app.use((req, res, next) => {
@ -9,10 +6,12 @@ module.exports = () => {
isAPI: true,
id: 1,
email: 'unknown',
permissions: _perms,
permissions: ['ADMIN'],
};
next();
});
},
};
};
export default adminUser;