0.3.1 • Published 5 years ago

wild-fig v0.3.1

Weekly downloads
3
License
MIT
Repository
github
Last release
5 years ago

Wild Fig

Wild Fig resolves dependency trees declared using a flat specification.

Usage

import { Dependency, resolve } from 'wild-fig';

export const dependencies: Dependency[] = [ {
  id: 'env',
  factory: async () => process.env,
}, {
  id: 'myService',
  dependsOn: [ 'env', 'myProvider' ],
  factory: async ({ env, myProvider }) => {
    return await myService.create({
      host: env.ES_HOST,
      port: Number(env.ES_PORT),
      credentials: myProvider.getCredentials(),
    });
  },
}, {
  id: 'myProvider',
  dependsOn: [ 'env' ],
  factory: async ({ env }) => new MyProvider(env),
} ];

const resolvedDependencies = await resolve(dependencies);

console.log(dependencies.env);
console.log(dependencies.myService);
console.log(dependencies.myProvider);
0.3.1

5 years ago

0.3.0

5 years ago

0.2.0

5 years ago

0.1.0

5 years ago

0.0.4

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago