Skip to content

Commit

Permalink
Refactor Context/Binding into @loopback/ioc (#175)
Browse files Browse the repository at this point in the history
  • Loading branch information
bajtos authored Apr 20, 2017
1 parent 70a0bb1 commit 181ecba
Show file tree
Hide file tree
Showing 21 changed files with 52 additions and 18 deletions.
7 changes: 7 additions & 0 deletions packages/ioc/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// Copyright IBM Corp. 2013,2017. All Rights Reserved.
// Node module: loopback
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT

export {Binding} from './src/binding';
export {Context} from './src/context';
28 changes: 28 additions & 0 deletions packages/ioc/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"name": "@loopback/ioc",
"version": "4.0.0-alpha.1",
"description": "LoopBack's container for Inversion of Control",
"main": "index",
"scripts": {
"acceptance": "mocha --opts ../../test/mocha.opts 'test/acceptance/**/*.ts'",
"integration": "mocha --opts ../../test/mocha.opts 'test/integration/**/*.ts'",
"test": "mocha --opts ../../test/mocha.opts 'test/unit/**/*.ts' 'test/integration/**/*.ts' 'test/acceptance/**/*.ts'",
"unit": "mocha --opts ../../test/mocha.opts 'test/unit/**/*.ts'"
},
"author": "IBM",
"license": "MIT",
"dependencies": {
},
"devDependencies": {
"@loopback/testlab": "^4.0.0-alpha.1",
"mocha": "^3.2.0"
},
"keywords": [
"LoopBack",
"IoC",
"Inversion",
"Control",
"Container",
"Decorators"
]
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// License text available at https://opensource.org/licenses/MIT

import {expect} from 'testlab';
import * as util from 'loopback/test/support/util';
import {Context} from '../..';

describe('Context bindings - Creating and resolving bindings', () => {
let ctx;
Expand Down Expand Up @@ -68,6 +68,6 @@ describe('Context bindings - Creating and resolving bindings', () => {
});

function createContext() {
ctx = util.getContext();
ctx = new Context();
}
});
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// License text available at https://opensource.org/licenses/MIT

import {expect} from 'testlab';
import * as util from 'loopback/test/support/util';
import {Context} from '../..';

describe('Context bindings - Finding bindings', () => {
let ctx;
Expand Down Expand Up @@ -66,7 +66,7 @@ describe('Context bindings - Finding bindings', () => {
});

function createContext() {
ctx = util.getContext();
ctx = new Context();
}
function createBinding(key, value) {
ctx.bind(key).to(value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// License text available at https://opensource.org/licenses/MIT

import {expect} from 'testlab';
import * as util from 'loopback/test/support/util';
import {Context} from '../..';

describe('Context bindings - Locking bindings', () => {
describe('Binding with a duplicate key', () => {
Expand Down Expand Up @@ -45,7 +45,7 @@ describe('Context bindings - Locking bindings', () => {
});

function createContext() {
ctx = util.getContext();
ctx = new Context();
}
function createBinding() {
binding = ctx.bind('foo');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// License text available at https://opensource.org/licenses/MIT

import {expect} from 'testlab';
import * as util from 'loopback/test/support/util';
import {Context} from '../..';

describe('Context bindings - Tagged bindings', () => {
let ctx;
Expand All @@ -27,7 +27,7 @@ describe('Context bindings - Tagged bindings', () => {
});

function createContext() {
ctx = util.getContext();
ctx = new Context();
}
function createBinding() {
binding = ctx.bind('foo').to('bar');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// License text available at https://opensource.org/licenses/MIT

import {expect} from 'testlab';
import * as util from 'loopback/test/support/util';
import {Context} from '../..';

describe(`Context bindings - Unlocking bindings`, () => {
describe('Unlocking a locked binding', () => {
Expand Down Expand Up @@ -43,7 +43,7 @@ describe(`Context bindings - Unlocking bindings`, () => {
});

function createContext() {
ctx = util.getContext();
ctx = new Context();
}
function createLockedBinding() {
binding = ctx.bind('foo').to('bar');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// License text available at https://opensource.org/licenses/MIT

import {expect} from 'testlab';
import {Binding} from 'loopback/lib/context/binding';
import {Binding} from '../..';

const key = 'foo';
const binding = new Binding(key);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
// License text available at https://opensource.org/licenses/MIT

import {expect} from 'testlab';
import {Binding} from 'loopback/lib/context/binding';
import * as util from 'loopback/test/support/util';
import {Context, Binding} from '../..';

describe('Context', () => {
let ctx;
Expand Down Expand Up @@ -43,6 +42,6 @@ describe('Context', () => {
});

function createContext() {
ctx = util.getContext();
ctx = new Context();
}
});
3 changes: 1 addition & 2 deletions packages/loopback/lib/application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT

import {Binding} from './context/binding';
import {Context} from './context';
import {Binding, Context} from '@loopback/ioc';
import * as http from 'http';
import {SwaggerRouter} from './router/SwaggerRouter';
import {getApiSpec} from './router/metadata';
Expand Down
2 changes: 1 addition & 1 deletion packages/loopback/lib/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import http = require('http');
import bluebird = require('bluebird');
import {Context} from './context';
import {Context} from '@loopback/ioc';
import {Application} from '../lib/application';
import {SwaggerRouter} from './router/SwaggerRouter';

Expand Down
1 change: 1 addition & 0 deletions packages/loopback/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"author": "IBM",
"license": "MIT",
"dependencies": {
"@loopback/ioc": "^4.0.0-alpha.1",
"@loopback/juggler": "^4.0.0-alpha.1",
"@loopback/remoting": "^4.0.0-alpha.1",
"body": "^5.1.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/loopback/test/support/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import {Application, Server, ServerConfig} from 'loopback';
import {Client} from './client';
import {Context} from '../../lib/context';
import {Context} from '@loopback/ioc';
import * as bluebird from 'bluebird';
import * as http from 'http';

Expand Down

0 comments on commit 181ecba

Please sign in to comment.