1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-01-25 00:07:47 +01:00

fix: Clean up exported types even more

This commit is contained in:
Ivar Conradi Østhus 2021-08-13 19:22:15 +02:00
parent 0e526d4283
commit 721baa7657
No known key found for this signature in database
GPG Key ID: 31AC596886B0BD09
4 changed files with 36 additions and 19 deletions

View File

@ -1,8 +1,6 @@
import EventEmitter from 'events';
import stoppable, { StoppableServer } from 'stoppable';
import { promisify } from 'util';
import { IUnleash } from './types/core';
import { IUnleashConfig, IUnleashOptions } from './types/option';
import version from './util/version';
import migrator from '../migrator';
import getApp from './app';
@ -10,17 +8,21 @@ import { createMetricsMonitor } from './metrics';
import { createStores } from './db';
import { createServices } from './services';
import { createConfig } from './create-config';
import User from './types/user';
import { Logger } from './logger';
import * as permissions from './types/permissions';
import AuthenticationRequired from './types/authentication-required';
import Controller from './routes/controller';
import * as eventType from './types/events';
import { addEventHook } from './event-hook';
import registerGracefulShutdown from './util/graceful-shutdown';
import { createDb } from './db/db-pool';
import sessionDb from './middleware/session-db';
// Types
import { IUnleash } from './types/core';
import { IUnleashConfig, IUnleashOptions } from './types/option';
import { IUnleashServices } from './types/services';
import User, { IUser } from './types/user';
import { Logger, LogLevel } from './logger';
import AuthenticationRequired from './types/authentication-required';
import Controller from './routes/controller';
import { IAuthRequest } from './routes/unleash-types';
import * as permissions from './types/permissions';
import * as eventType from './types/events';
async function createApp(
config: IUnleashConfig,
@ -142,14 +144,30 @@ async function create(opts: IUnleashOptions): Promise<IUnleash> {
}
return createApp(config, false);
}
const serverImpl = {
// Module exports
export {
start,
create,
User,
AuthenticationRequired,
Controller,
permissions,
eventType,
Controller,
AuthenticationRequired,
User,
LogLevel,
};
export default {
start,
create,
};
export type {
Logger,
IUnleash,
IUnleashOptions,
IUnleashConfig,
IUser,
IUnleashServices,
IAuthRequest,
};
export default serverImpl;
module.exports = serverImpl;

View File

@ -75,7 +75,6 @@ export default class User implements IUser {
this.seenAt = seenAt;
this.loginAttempts = loginAttempts;
this.createdAt = createdAt;
this.imageUrl = this.generateImageUrl();
}
generateImageUrl(): string {

View File

@ -1,10 +1,10 @@
import unleash from './lib/server-impl';
import { start } from './lib/server-impl';
import { createConfig } from './lib/create-config';
import { LogLevel } from './lib/logger';
process.nextTick(async () => {
try {
await unleash.start(
await start(
createConfig({
db: {
user: 'unleash_user',

View File

@ -1,3 +1,3 @@
import unleash from './lib/server-impl';
import * as unleash from './lib/server-impl';
unleash.start();