-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
1,031 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
node_modules/ | ||
dist/ | ||
npm-debug.log | ||
coverage/ | ||
.DS_Storage | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/// <reference types="chai" /> | ||
import * as Koa from 'koa'; | ||
import Cookie from './cookie'; | ||
interface Context extends Koa.Context { | ||
cookie?: Cookie; | ||
params?: Object; | ||
requestBody?: any; | ||
} | ||
export default Context; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
"use strict"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
declare abstract class Controller { | ||
} | ||
export default Controller; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
"use strict"; | ||
class Controller { | ||
} | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.default = Controller; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
declare class Cookie { | ||
content: string; | ||
path: string; | ||
secure: boolean; | ||
httpOnly: boolean; | ||
private _expires; | ||
private _maxAge; | ||
constructor(); | ||
expires: Date; | ||
maxAge: number; | ||
toString(): string; | ||
} | ||
export default Cookie; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
"use strict"; | ||
class Cookie { | ||
constructor() { | ||
this.content = ''; | ||
this.path = '/'; | ||
this.secure = true; | ||
this.httpOnly = true; | ||
this._expires = new Date(); | ||
this._maxAge = 0; | ||
} | ||
get expires() { | ||
return this._expires; | ||
} | ||
set expires(date) { | ||
this._maxAge += (Math.floor(date.getTime() / 1000) - Math.floor(this._expires.getTime() / 1000)); | ||
this._expires = date; | ||
} | ||
get maxAge() { | ||
return this._maxAge; | ||
} | ||
set maxAge(date) { | ||
this._expires = new Date(this._expires.getTime() + (date - this.maxAge) * 1000); | ||
this._maxAge = date; | ||
} | ||
toString() { | ||
let ret = this.content; | ||
ret += '; Path=' + this.path; | ||
ret += '; Expires=' + this.expires.toUTCString(); | ||
if (this.secure) | ||
ret += '; Secure'; | ||
if (this.httpOnly) | ||
ret += '; HttpOnly'; | ||
return ret; | ||
} | ||
} | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.default = Cookie; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import Controller from './controller'; | ||
import { MediaType } from './util'; | ||
import 'reflect-metadata'; | ||
export declare function Before(target: Controller, key: string): void; | ||
export declare function After(target: Controller, key: string): void; | ||
export declare function GET(target: Controller, key: string): void; | ||
export declare function POST(target: Controller, key: string): void; | ||
export declare function PUT(target: Controller, key: string): void; | ||
export declare function DELETE(target: Controller, key: string): void; | ||
export declare function Inject(func: Function): (target: Controller, key: string) => void; | ||
export declare function Path(path: string): (target: Controller | (new () => Controller), key?: string) => void; | ||
export declare function Produce(type: MediaType): (target: Controller, key: string) => void; | ||
export declare function Consume(type: MediaType): (target: Controller, key: string) => void; | ||
export declare function QueryParam(param: string): (target: Controller, key: string, index?: number) => void; | ||
export declare function PathParam(param: string): (target: Controller, key: string, index?: number) => void; | ||
export declare function BodyParam(param: string): (target: Controller, key: string, index?: number) => void; | ||
export declare function HeaderParam(param: string): (target: Controller, key: string, index?: number) => void; | ||
export declare function Query(target: Controller, key: string, index?: number): void; | ||
export declare function Params(target: Controller, key: string, index?: number): void; | ||
export declare function Body(target: Controller, key: string, index?: number): void; | ||
export declare function Headers(target: Controller, key: string, index?: number): void; | ||
export declare function AppContext(target: Controller, key: string, index?: number): void; | ||
export declare function HttpContext(target: Controller, key: string, index?: number): void; | ||
export declare function RouteResponse(target: Controller, key: string, index: number): void; |
Oops, something went wrong.