Skip to content
This repository has been archived by the owner on May 8, 2020. It is now read-only.

Commit

Permalink
feat(typescript): Upgrad to typescript 2.0, extract execeptions to co…
Browse files Browse the repository at this point in the history
…mmon to stop browser linking server modules, remove typings, remove

BREAKING CHANGE:
You typescript 2.0 lands with this release, with it comes a total refactor on how tsconfig is used. To see the recommended implementation, review the changes in ubiquits/quickstart#22
  • Loading branch information
zakhenry committed Jul 19, 2016
1 parent 3da128a commit 4aa3446
Show file tree
Hide file tree
Showing 36 changed files with 98 additions and 99 deletions.
1 change: 0 additions & 1 deletion browser.d.ts

This file was deleted.

5 changes: 0 additions & 5 deletions browser.js

This file was deleted.

1 change: 0 additions & 1 deletion browser.ts

This file was deleted.

1 change: 0 additions & 1 deletion common.d.ts

This file was deleted.

5 changes: 0 additions & 5 deletions common.js

This file was deleted.

1 change: 0 additions & 1 deletion common.ts

This file was deleted.

Empty file removed index.d.ts
Empty file.
Empty file removed index.js
Empty file.
Empty file removed index.ts
Empty file.
22 changes: 16 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
"test": "u test -s",
"coveralls": "u coveralls",
"build": "u build",
"postinstall": "typings install",
"postpublish": "u deploy docs"
},
"repository": {
Expand Down Expand Up @@ -53,13 +52,24 @@
"timestamp": "0.0.1",
"typeorm": "0.0.2-alpha.43",
"vantage": "^1.7.0",
"zone.js": "^0.6.12"
},
"devDependencies": {
"@ubiquits/toolchain": "^0.1.42",
"zone.js": "^0.6.12",
"@types/chalk": "^0.4.28",
"@types/chance": "^0.7.28",
"@types/dotenv": "^2.0.17",
"@types/express": "^4.0.29",
"@types/express-serve-static-core": "^4.0.29",
"@types/hapi": "^13.0.28",
"@types/jasmine": "^2.2.29",
"@types/lodash": "0.0.27",
"@types/moment": "^2.11.28",
"@types/node": "^4.0.29",
"@types/proxyquire": "^1.3.26",
"@types/socket.io": "^1.4.26",
"@types/validator": "^4.5.26",
"@ubiquits/toolchain": "^0.2.0",
"proxyquire": "^1.7.10"
},
"directories": {
"doc": "docs"
}
}
}
1 change: 0 additions & 1 deletion server.d.ts

This file was deleted.

5 changes: 0 additions & 5 deletions server.js

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* @module server
* @module common
*/
/** End Typedoc Module Declaration */
import { ValidationError } from 'class-validator';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* @module server
* @module common
*/
/** End Typedoc Module Declaration */
export * from './exceptions';
1 change: 1 addition & 0 deletions src/common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ export * from './stores';
export * from './validation';
export * from './services';
export * from './registry';
export * from './exeptions';
10 changes: 0 additions & 10 deletions src/common/models/model.spec.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,5 @@
import { UUID, AbstractModel } from './model';
import { Primary } from './types/primary.decorator';
import Moment = moment.Moment;

class ChildModel extends AbstractModel {

@Primary()
public id: string;//UUID;

public name: string;

}

class BasicModel extends AbstractModel {

Expand Down
5 changes: 4 additions & 1 deletion src/common/models/relations/hand.model.fixture.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import Moment = moment.Moment;
/**
* @module common
*/
/** End Typedoc Module Declaration */
import { HasOne } from './hasOne.decorator';
import { AbstractModel } from '../model';
import { Primary } from '../types/primary.decorator';
Expand Down
5 changes: 4 additions & 1 deletion src/common/models/relations/relations.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import Moment = moment.Moment;
import { ThumbModel } from './thumb.model.fixture';
import { HandModel } from './hand.model.fixture';

Expand Down Expand Up @@ -27,6 +26,10 @@ describe('Model Relations', () => {
.get('hand').foreign)
.toEqual(HandModel);

expect(relations.get('belongsTo')
.get('hand').viaProperty(new HandModel({handId:1})))
.toEqual(1);

});

});
5 changes: 4 additions & 1 deletion src/common/models/relations/thumb.model.fixture.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import Moment = moment.Moment;
/**
* @module common
*/
/** End Typedoc Module Declaration */
import { AbstractModel } from '../model';
import { Primary } from '../types/primary.decorator';
import { BelongsTo } from './belongsTo.decorator';
Expand Down
1 change: 0 additions & 1 deletion src/common/services/logger.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
/** End Typedoc Module Declaration */
import { Injectable } from '@angular/core';
import { AbstractService } from './service';
import { InternalServerErrorException } from '../../server/exeptions/exceptions';

/**
* Syslog Levels
Expand Down
6 changes: 2 additions & 4 deletions src/common/stores/mock.store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ import { Injector } from '@angular/core';
import { Chance } from 'chance';
import * as _ from 'lodash';

export type ChanceInstance = Chance.Chance;

/**
* Provides abstract class to build concrete mock stores which can create new mock instances of
* models.
Expand All @@ -21,7 +19,7 @@ export abstract class MockStore<T extends AbstractModel> extends AbstractStore<T
* Instance of chancejs
* @see http://chancejs.com
*/
protected chanceInstance: ChanceInstance;
protected chanceInstance: Chance.Chance;

protected modelCollection: Collection<T>;

Expand All @@ -45,7 +43,7 @@ export abstract class MockStore<T extends AbstractModel> extends AbstractStore<T
* @param seed
* @returns {ChanceInstance}
*/
protected chance(seed?: any): ChanceInstance {
protected chance(seed?: any): Chance.Chance {
if (!this.chanceInstance || !!seed) {
this.chanceInstance = new Chance(seed);
}
Expand Down
2 changes: 1 addition & 1 deletion src/common/stores/store.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import {
ValidatorConstraint,
ValidatorConstraintInterface
} from '../validation';
import { ValidationException } from '../../server/exeptions/exceptions';
import { Primary } from '../models/types/primary.decorator';
import Spy = jasmine.Spy;
import { Collection } from '../models/collection';
import { ValidationException } from '../exeptions/exceptions';

@Injectable()
class StubService {
Expand Down
2 changes: 1 addition & 1 deletion src/common/stores/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
import { identifier, ModelStatic, AbstractModel } from '../models/model';
import { Injector } from '@angular/core';
import { Collection } from '../models/collection';
import { ValidationException } from '../../server/exeptions/exceptions';
import { ValidatorOptions, ValidationError, getValidator, Validator } from '../validation';
import { ValidationException } from '../exeptions/exceptions';

export interface Query {
}
Expand Down
2 changes: 1 addition & 1 deletion src/server/controllers/abstract.controller.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { Request } from './request';
import { Response } from './response';
import { AbstractController } from './abstract.controller';
import { Route } from './route.decorator';
import { UnavailableForLegalReasonsException } from '../exeptions/exceptions';
import { UnavailableForLegalReasonsException } from '../../common/exeptions/exceptions';

@Injectable()
class TestController extends AbstractController {
Expand Down
2 changes: 1 addition & 1 deletion src/server/controllers/abstract.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import { PromiseFactory } from '../../common/util/serialPromise';
import { Response } from './response';
import { Request } from './request';
import { initializeMiddlewareRegister } from '../middleware/middleware.decorator';
import { HttpException, InternalServerErrorException } from '../exeptions/exceptions';
import { RegistryEntityStatic, RegistryEntity } from '../../common/registry/entityRegistry';
import { ControllerMetadata } from '../../common/metadata/metadata';
import { InternalServerErrorException, HttpException } from '../../common/exeptions/exceptions';

export interface MethodDefinition {
method: HttpMethod;
Expand Down
5 changes: 4 additions & 1 deletion src/server/controllers/request.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import { Request } from '../controllers/request';
import { IncomingMessage } from 'http';
import { EventEmitter } from 'events';
import { PayloadTooLargeException, UnprocessableEntityException } from '../exeptions/exceptions';
import {
UnprocessableEntityException,
PayloadTooLargeException
} from '../../common/exeptions/exceptions';

describe('Request', () => {

Expand Down
5 changes: 4 additions & 1 deletion src/server/controllers/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@
*/
/** End Typedoc Module Declaration */
import { IncomingMessage } from 'http';
import { UnprocessableEntityException, PayloadTooLargeException } from '../exeptions/exceptions';
import EventEmitter = NodeJS.EventEmitter;
import {
PayloadTooLargeException,
UnprocessableEntityException
} from '../../common/exeptions/exceptions';

/**
* Request class that is passed into all middleware and controller methods to extract data from the
Expand Down
2 changes: 1 addition & 1 deletion src/server/controllers/resource.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { Request } from './request';
import { AbstractStore } from '../../common/stores/store';
import { Collection } from '../../common/models/collection';
import { ValidatorOptions } from '../../common/validation';
import { NotFoundException } from '../exeptions/exceptions';
import { NotFoundException } from '../../common/exeptions/exceptions';

/**
* Provides resource controller that all controllers that interact RESTfully with ModelStores
Expand Down
1 change: 0 additions & 1 deletion src/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,3 @@ export * from './seeders';
export * from './migrations';
export * from './stores';
export * from './middleware';
export * from './exeptions';
2 changes: 1 addition & 1 deletion src/server/stores/db.store.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import { DatabaseStore } from './db.store';
import { AbstractModel } from '../../common/models/model';
import { Primary } from '../../common/models/types/primary.decorator';
import { StoredProperty } from '../../common/models/types/storedProperty.decorator';
import { NotFoundException } from '../exeptions/exceptions';
import { Collection } from '../../common/models/collection';
import { DatabaseMock } from '../services/database.service.mock';
import Spy = jasmine.Spy;
import { NotFoundException } from '../../common/exeptions/exceptions';

class TestModel extends AbstractModel {

Expand Down
2 changes: 1 addition & 1 deletion src/server/stores/db.store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import { Database } from '../services/database.service';
import { Logger } from '../../common/services/logger.service';
import { AbstractStore, Query } from '../../common/stores/store';
import { Collection } from '../../common/models/collection';
import { NotFoundException } from '../exeptions/exceptions';
import { Repository, Connection } from 'typeorm';
import { NotFoundException } from '../../common/exeptions/exceptions';

/**
* Database store should be extended with a specific implementation for a model. Interacts with
Expand Down
22 changes: 12 additions & 10 deletions tsconfig.json → tsconfig.all.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,21 @@
"removeComments": false,
"noImplicitAny": true,
"suppressImplicitAnyIndexErrors": true,
"declaration": true
"declaration": true,
"outDir": "lib",
"sourceRoot": "src",
"types": [
"node",
"jasmine",
"socket.io"
]
},
"exclude": [
"node_modules",
"lib",
"dist",
"index.ts",
"index.d.ts",
"server.ts",
"server.d.ts",
"browser.ts",
"browser.d.ts",
"common.ts",
"common.d.ts"
"dist"
],
"include": [
"src/**/*"
]
}
19 changes: 7 additions & 12 deletions tsconfig.browser.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,17 @@
"experimentalDecorators": true,
"removeComments": false,
"noImplicitAny": true,
"suppressImplicitAnyIndexErrors": true
"suppressImplicitAnyIndexErrors": true,
"sourceRoot": "src",
"outDir": "dist/browser",
"types": [
"jasmine"
]
},
"exclude": [
"node_modules",
"lib",
"dist",
"src/server",
"index.ts",
"index.d.ts",
"server.ts",
"server.d.ts",
"browser.ts",
"browser.d.ts",
"common.ts",
"common.d.ts",
"browser.d.ts"

"src/server"
]
}
31 changes: 31 additions & 0 deletions tsconfig.server.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"compilerOptions": {
"target": "es2015",
"module": "commonjs",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": false,
"noImplicitAny": true,
"suppressImplicitAnyIndexErrors": true,
"declaration": false,
"outDir": "dist/server",
"sourceRoot": "src",
"inlineSources": true,
"types": [
"node",
"jasmine",
"socket.io"
]
},
"exclude": [
"node_modules",
"lib",
"dist",
"src/browser"
],
"include": [
"src/**/*"
]
}
21 changes: 0 additions & 21 deletions typings.json

This file was deleted.

0 comments on commit 4aa3446

Please sign in to comment.