@curveball/core
Advanced tools
Comparing version 0.5.0 to 0.6.0
@@ -0,1 +1,9 @@ | ||
0.6.0 (2018-09-05) | ||
================== | ||
* Request and Response object are now generic. `Response<T>` implies the body | ||
property has type `T`. | ||
* `ctx.status` is now writable. | ||
0.5.0 (2018-08-31) | ||
@@ -2,0 +10,0 @@ ================== |
@@ -10,11 +10,11 @@ import { Middleware } from './application'; | ||
*/ | ||
export default class Context { | ||
export default class Context<ReqT = any, ResT = any> { | ||
/** | ||
* HTTP Request | ||
*/ | ||
request: Request; | ||
request: Request<ReqT>; | ||
/** | ||
* HTTP Response | ||
*/ | ||
response: Response; | ||
response: Response<ResT>; | ||
/** | ||
@@ -73,4 +73,9 @@ * State information. | ||
*/ | ||
readonly status: number; | ||
/** | ||
* Sets the HTTP response status code. | ||
* | ||
* This is a shortcut for response.status. | ||
*/ | ||
status: number; | ||
/** | ||
* Sends an informational (1xx status code) response. | ||
@@ -77,0 +82,0 @@ * |
@@ -64,2 +64,10 @@ "use strict"; | ||
/** | ||
* Sets the HTTP response status code. | ||
* | ||
* This is a shortcut for response.status. | ||
*/ | ||
set status(value) { | ||
this.response.status = value; | ||
} | ||
/** | ||
* Sends an informational (1xx status code) response. | ||
@@ -66,0 +74,0 @@ * |
/// <reference types="node" /> | ||
import { HeadersInterface, HeadersObject } from './headers'; | ||
import Request from './request'; | ||
export declare class MemoryRequest implements Request { | ||
export declare class MemoryRequest<T> implements Request<T> { | ||
/** | ||
@@ -13,3 +13,3 @@ * List of HTTP Headers | ||
*/ | ||
body: any; | ||
body: T; | ||
constructor(method?: string, requestTarget?: string, headers?: HeadersInterface | HeadersObject, body?: any); | ||
@@ -16,0 +16,0 @@ /** |
import { Middleware } from './application'; | ||
import { Headers, HeadersInterface, HeadersObject } from './headers'; | ||
import Response from './response'; | ||
export declare class MemoryResponse implements Response { | ||
export declare class MemoryResponse<T> implements Response<T> { | ||
constructor(); | ||
@@ -17,3 +17,3 @@ /** | ||
*/ | ||
body: null | object | string; | ||
body: T; | ||
/** | ||
@@ -20,0 +20,0 @@ * Returns the value of the Content-Type header, with any additional |
@@ -5,3 +5,3 @@ /// <reference types="node" /> | ||
import { NodeHttpRequest } from './http-utils'; | ||
export declare class NodeRequest implements Request { | ||
export declare class NodeRequest<T> implements Request<T> { | ||
/** | ||
@@ -15,3 +15,3 @@ * List of HTTP Headers | ||
*/ | ||
body: any; | ||
body: T; | ||
/** | ||
@@ -18,0 +18,0 @@ * Node.js Request object |
@@ -42,3 +42,3 @@ import { Middleware } from '../application'; | ||
} | ||
export declare class NodeResponse implements Response { | ||
export declare class NodeResponse<T> implements Response<T> { | ||
private inner; | ||
@@ -65,3 +65,3 @@ private bodyValue; | ||
*/ | ||
body: null | object | string; | ||
body: T; | ||
/** | ||
@@ -68,0 +68,0 @@ * Returns the value of the Content-Type header, with any additional |
@@ -6,3 +6,3 @@ /// <reference types="node" /> | ||
*/ | ||
export interface Request { | ||
export interface Request<T = any> { | ||
/** | ||
@@ -52,3 +52,3 @@ * List of HTTP Headers | ||
*/ | ||
body: any; | ||
body: T; | ||
/** | ||
@@ -55,0 +55,0 @@ * This function returns the request body. |
@@ -6,3 +6,3 @@ import { Middleware } from './application'; | ||
*/ | ||
export interface Response { | ||
export interface Response<T = any> { | ||
/** | ||
@@ -19,3 +19,3 @@ * List of HTTP Headers. | ||
*/ | ||
body: any; | ||
body: T; | ||
/** | ||
@@ -22,0 +22,0 @@ * Returns the value of the Content-Type header, with any additional |
{ | ||
"name": "@curveball/core", | ||
"version": "0.5.0", | ||
"version": "0.6.0", | ||
"description": "Curveball is a framework writting in Typescript for Node.js", | ||
@@ -61,3 +61,5 @@ "main": "dist/index.js", | ||
}, | ||
"engines" : { "node" : ">=9.4" } | ||
"engines": { | ||
"node": ">=9.4" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
79654
1566