How to use the typedi.Container.set function in typedi

To help you get started, we’ve selected a few typedi examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github vaultage-pm / vaultage / packages / vaultage / src / main.ts View on Github external
async function boot(port: number, addr: string) {
    // Tell routing-controller to use our dependency injection container
    useContainer(Container);

    // Wires all dependencies
    const vaultPath = storagePath(VAULT_FILENAME, program.data);
    Container.set('cipherLocation', vaultPath);

    await loadConfig(true);

    Container.set(DatabaseWithAuth, Container.get(JSONDatabaseWithAuth));

    // Create an express server which is preconfigured to serve the API
    const server = createVaultageAPIServer();

    // Bind static content to server
    const pathToWebCliGUI = path.dirname(require.resolve('vaultage-ui-webcli'));
    const staticDirToServer = path.join(pathToWebCliGUI, 'public');
    server.use(express.static(staticDirToServer));

    // run application on port port
    server.listen(port, addr, () => {
        console.log(`Server is listening on port ${port}`);
github vaultage-pm / vaultage / packages / vaultage / src / main.ts View on Github external
async function boot(port: number, addr: string) {
    // Tell routing-controller to use our dependency injection container
    useContainer(Container);

    // Wires all dependencies
    const vaultPath = storagePath(VAULT_FILENAME, program.data);
    Container.set('cipherLocation', vaultPath);

    await loadConfig(true);

    Container.set(DatabaseWithAuth, Container.get(JSONDatabaseWithAuth));

    // Create an express server which is preconfigured to serve the API
    const server = createVaultageAPIServer();

    // Bind static content to server
    const pathToWebCliGUI = path.dirname(require.resolve('vaultage-ui-webcli'));
    const staticDirToServer = path.join(pathToWebCliGUI, 'public');
    server.use(express.static(staticDirToServer));

    // run application on port port
    server.listen(port, addr, () => {
        console.log(`Server is listening on port ${port}`);
    });
}
github vaultage-pm / vaultage / packages / vaultage / src / VaultageServer.ts View on Github external
public static bindToServer(expressApp: Application, initialConfig?: VaultageConfig ) {
        if (initialConfig) {
            Container.set('config', initialConfig);
        }
        // registers our routes (present in Cipher/ConfigController) on this express server
        useExpressServer(expressApp, {
            controllers: [
                CipherController,
                ConfigController
            ]
        });
    }
}
github wemaintain / auto-relay / packages / core / src / decorators / relayed-query.decorator.spec.ts View on Github external
it('With Through and options', (cb) => {
      const Model = () => Object
      const Through = () => Object
      const options = { name: "TestTest" }
  
      const mock = new RelayedQueryService()
      Container.set(RelayedQueryService, mock)
  
      RelayedQuery(Model, Through, options)(TestClass.prototype, 'test', {} as any)
      process.nextTick(() => {
        const makeMethodRelayed = mock.makeMethodRelayedQuery as jest.Mock
        expect(makeMethodRelayed).toHaveBeenCalledTimes(1)
        expect(makeMethodRelayed.mock.calls).toContainAllValues([
          [
            TestClass.prototype,
            'test',
            {},
            Model,
            Through,
            options
          ]
        ])
        cb()
github vaheqelyan / tygit / src / fn / preRun.ts View on Github external
export default function preFn(gitPath: string, { terminal }: ICliOptions) {
	if (existsSync(gitPath)) {
		const dirArray = readdirSync(gitPath);
		if (dirArray.indexOf(".git") !== -1) {
			const getTerm = terminal ? terminal : null;

			if (typeof getTerm === "boolean") {
				console.log("Please set the type of terminal encoding");
			} else {
				Container.set("terminal", getTerm);
				Container.set("git-path", gitPath);
				Container.set("terminal-size", { width: process.stdout.columns, height: process.stdout.rows });
				const sc = Container.get(Screen);
				sc.initStateAndRender();
			}
		} else {
			console.log("This is not a git repository");
		}
	} else {
		console.log("Wrong path");
	}
}
github wemaintain / auto-relay / packages / core / src / services / auto-relay-config.service.ts View on Github external
if ((config as AutoRelayConfigArgsExistingModel).objects) {
      this._declareExistingObjects(config as AutoRelayConfigArgsExistingModel)
    } else {
      const configNoModel: AutoRelayConfigArgsNoModel = config;

      configNoModel.microserviceName = configNoModel.microserviceName ? String(configNoModel.microserviceName) : ''
      if ( configNoModel.microserviceName) {
        configNoModel.microserviceName =  configNoModel.microserviceName![0].toUpperCase() +  configNoModel.microserviceName!.substring(1)
      }

      AutoRelayConfig.generateObjects(config, true)
      Container.set(PREFIX, configNoModel.microserviceName)
      if (configNoModel.extends && configNoModel.extends.connection) {
        Container.set(CONNECTION_BASE_OBJECT, configNoModel.extends.connection)
      } else {
        Container.set(CONNECTION_BASE_OBJECT, () => Object)
      }
    }

    AutoRelayConfig._config = config
  }
github patrickmichalina / fusing-angular-v1-archived / src / server / rest-api / index.ts View on Github external
useContainer(Container)

export type Auth0Config = AuthOptions
export type SendGridAPIKey = string
export type Auth0Cert = string
export const AUTH0_MANAGEMENT_CLIENT_CONFIG = new Token()
export const SENDGRID_API_KEY = new Token()
export const AUTH0_CERT = new Token()

Container.set(
  AUTH0_CERT,
  process.env.AUTH0_CERT && process.env.AUTH0_CERT.replace(/\\n/g, '\n')
)
Container.set(SENDGRID_API_KEY, process.env.SENDGRID_API_KEY)
Container.set(AUTH0_MANAGEMENT_CLIENT_CONFIG, {
  domain: process.env.AUTH0_DOMAIN || '',
  clientID: process.env.AUTH0_CLIENT_ID || ''
} as AuthOptions)

export const useApi = (app: express.Application) => {
  const swaggerSpec = swaggerJSDoc({
    swaggerDefinition: {
      info: {
        title: 'fusing-angular',
        description: '',
        termsOfService: '',
        contact: {
          name: 'Patrick Michalina',
          url: 'https://github.com/patrickmichalina/fusing-angular/issues',
          email: 'patrickmichalina@mac.com'
        },
github santiq / bulletproof-nodejs / src / loaders / dependencyInjector.ts View on Github external
models.forEach(m => {
      Container.set(m.name, m.model);
    });
github wemaintain / auto-relay / packages / core / src / services / auto-relay-config.service.ts View on Github external
protected _declareExistingObjects(config: AutoRelayConfigArgsExistingModel): void {
    Container.set(PAGINATION_OBJECT, config.objects.pageInfo)
    Container.set(CONNECTIONARGS_OBJECT, config.objects.connectionArgs)
  }