0.0.3 • Published 8 years ago

papercraft v0.0.3

Weekly downloads
2
License
MIT
Repository
github
Last release
8 years ago

papercraft

papercraft is a Web Framework using TypeScript. Modern coding, high query coding.

How To Use

Create project

$ npm i papercraft -g
$ papercraft new test
$ cd test

Run

$ npm install
$ npm start

Reference

Router

Router is API Interface.

/routes/Message.ts

import {Route, Params} from 'papercraft/core';

// Request params Interface
export interface RequestParams {
  id: number
}

// Response Interface
export interface ResponseParam extends Object {
  message: string
}

export const MessageRoute = {
  // routeName : config
  createArticle: Route(
    {
      url: '/hoge',
      method: 'GET',
      params: Params<RequestParams>(),
      response: Params<ResponseParam>()
    }
  )
};

Controller

Controller action have annotated method.Api annotation makes async API.

/controllers/MessageController.ts

"use strict";

import {Api} from 'papercraft/core';

import {MessageRoute, RequestParams} from '../routes/Message';

class MessageController {

  // Controller Action should have `Api` annotation.
  @Api({
    route: MessageRoute.createArticle
  })
  async huga(params: RequestParams) {
    const number = await this.test();

    return {message: `Async API Called, ${number}`};
  }

  private test(): Promise<number> {
    return Promise.resolve(10);
  }
}

Test

$ npm test

License

MIT

0.0.3

8 years ago

0.0.2

8 years ago

0.0.1

8 years ago