Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import basicStreamer from './streamer/basic-streamer';
import ffmpegStreamer from './streamer/ffmpeg-streamer';
import ffmpegHlsStreamer from './streamer/ffmpeg-hls-streamer';
import ffmpeDashStreamer from './streamer/ffmpeg-dash-streamer';
import hlsPresetDecision from './streamer/hls/hls-preset-decision';
import M3u8Generator from './streamer/m3u8-generator';
import fsExtra from 'fs-extra';
import path from 'path';
import throttledQueue from 'throttled-queue';
/**
* Using Awilix, the following files and folders (glob patterns)
* will be loaded.
*/
const modulesToLoad = [
['services/*.js', Lifetime.SCOPED],
['lib/extended-info-providers/*-provider.js', Lifetime.SINGLETON],
['stores/*.js', Lifetime.SINGLETON]
];
/**
* Configures a new container.
*
* @return {Object} The container.
*/
export async function configureContainer() {
const opts = {
resolutionMode: ResolutionMode.CLASSIC
};
// @todo create a bootstrap sequence
const dataFolder = process.env.DATA_FOLDER || path.join(process.env.HOME, '.media_speed');
import { createContainer, Lifetime, InjectionMode, asValue } from 'awilix'
import { logger } from './logger'
/**
* Using Awilix, the following files and folders (glob patterns)
* will be loaded.
*/
const modulesToLoad = [
// Services should be scoped to the request.
// This means that each request gets a separate instance
// of a service.
['services/*.js', Lifetime.SCOPED],
// Stores will be singleton (1 instance per process).
// This is just for demo purposes, you can do whatever you want.
['stores/*.js', Lifetime.SINGLETON]
]
/**
* Configures a new container.
*
* @return {Object} The container.
*/
export function configureContainer() {
const opts = {
// Classic means Awilix will look at function parameter
// names rather than passing a Proxy.
injectionMode: InjectionMode.CLASSIC
}
import { createContainer, Lifetime, InjectionMode, asValue } from 'awilix'
import { logger } from './logger'
/**
* Configures a new container 配置容器
*
* @return {Object} The container.
*/
const modulesToLoad = [
['services/*.js', Lifetime.SCOPED],
['stores/*.js', Lifetime.SINGLETON]
]
export function configureContainer() {
const opts = {
injectionMode: InjectionMode.CLASSIC
}
return createContainer(opts)
// load modules and registers 加载,注册模块 e.g. import userService from `services/user-service.js`
.loadModules(modulesToLoad, {
cwd: `${__dirname}/..`,
formatName: 'camelCase'
})
.register({
// construct logger
logger: asValue(logger)
private injectPlugins(): void {
this.registerModule([
[`${__dirname}/plugins/**/*.js`, { lifetime: Lifetime.SCOPED }]
]);
}