Nunjucks Powers Mozilla

    bean.ts
    TypeScript icon, indicating that this package has built-in type declarations

    1.0.10 • Public • Published

    bean.ts

    AOP support using a typescript decorator. You can implement the MVC pattern via bean.ts.

    See test code.

    import {
      installer, Controller, Inject, PostConstruct, PreDestroy, RequestMapping
    } from './project-bean';
    
    import {
      MemberService 
    } from './member-service';
    
    @Controller()
    export class MemberController {
      public constructor(@Inject(MemberService) private memberService: MemberService) {
        console.log('MemberController: Constructor');
      }
    
      @PostConstruct()
      protected postConstruct() {
        console.log('MemberController: postConstruct : _memberService=', this.memberService);
      }
    
      @PreDestroy()
      protected preDestroy() {
        console.log('MemberController: preDestroy');
      }
    
      @RequestMapping({
        path: '/member/users',
        method: 'get'
      })
      public getUsers(a: number, b: number) {
        return `called get users, a=${a}, b=${b}`;
      }
    
      @RequestMapping({
        path: '/member/users',
        method: 'post'
      })
      public postUsers(a: number, b: number) {
        return `called post users, a=${a}, b=${b}`;
      }
    }
    
    export default installer;

    License

    Apache-2.0

    Install

    npm i bean.ts

    DownloadsWeekly Downloads

    5

    Version

    1.0.10

    License

    Apache-2.0

    Unpacked Size

    122 kB

    Total Files

    43

    Last publish

    Collaborators

    • jc-lab