Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
vunb committed Aug 1, 2019
1 parent 4b62443 commit d88d03f
Showing 1 changed file with 5 additions and 51 deletions.
56 changes: 5 additions & 51 deletions packages/rest/rest.extension.ts
Original file line number Diff line number Diff line change
@@ -1,54 +1,13 @@

import * as express from 'express';

import { Injectable } from '@kites/common';
import { Container, ExtensionOptions, IKites, KitesExtension } from '@kites/core';
import { OutgoingHttpHeaders } from 'http';
import { PARAMETER_TYPE, TYPE } from './constants';
import { Controller, Get } from './decorators';
import { IController, Middleware, ParameterMetadata } from './interfaces';
import { HttpResponseMessage } from './results/http-response-message';
import { GetControllerMetadata, GetControllerMethodMetadata, GetControllerParameterMetadata, GetControllersFromContainer, GetControllersFromMetadata } from './utils';

@Injectable()
class SimpleService {
public test(): string {
return 'Hello Service!!!';
}
}

@Controller('/api1')
class TestController {

constructor(public svSimple: SimpleService) {

}

@Get('/') test() {
return this.svSimple.test();
}
}

@Controller('/api2')
class Test2Controller {

constructor(public svSimple: SimpleService) {

}

@Get('/') test() {
return this.svSimple.test();
}

@Get('/path2') test2() {
return this.svSimple.test();
}

@Get('/path2') test3() {
return this.svSimple.test();
}
}

/**
* Main Extension
*/
Expand All @@ -58,12 +17,8 @@ class RestExtension implements KitesExtension {
constructor(private kites: IKites, options: ExtensionOptions) {
this.name = 'Rest';

// register system service(s)
// TODO: Support HttpContext
kites.container
.addProvider({
provide: SimpleService,
useClass: SimpleService
})
.addProvider({
provide: TYPE.HttpContext,
useValue: {}
Expand All @@ -82,13 +37,12 @@ class RestExtension implements KitesExtension {

}

/**
* Load more works at this entry!
*/
init(kites: IKites, options: ExtensionOptions) {

const service = kites.container.inject(SimpleService);
console.log('Name: ', this.name, service.test());

const testController = kites.container.inject(TestController);
console.log('Controller: ', testController.test());
kites.logger.debug('Initializing extension rest ...');
}

private registerControllers(container: Container): express.Router {
Expand Down

0 comments on commit d88d03f

Please sign in to comment.