Add Safe value API and start OAuth2Server
This commit is contained in:
@@ -1,11 +1,12 @@
|
||||
import {Injectable, ScopedContainer, Container} from '../../di'
|
||||
import {infer, UniversalPath} from '../../util'
|
||||
import {Container, Injectable, ScopedContainer} from '../../di'
|
||||
import {HTTPStatus, infer, Pipeline, Safe, UniversalPath} from '../../util'
|
||||
import {IncomingMessage, ServerResponse} from 'http'
|
||||
import {HTTPCookieJar} from '../kernel/HTTPCookieJar'
|
||||
import {TLSSocket} from 'tls'
|
||||
import * as url from 'url'
|
||||
import {Response} from './Response'
|
||||
import * as Negotiator from 'negotiator'
|
||||
import {HTTPError} from '../HTTPError'
|
||||
|
||||
/**
|
||||
* Enumeration of different HTTP verbs.
|
||||
@@ -193,6 +194,19 @@ export class Request extends ScopedContainer implements DataContainer {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Look up a field from the request and wrap it in a safe-value accessor.
|
||||
* @param key
|
||||
*/
|
||||
public safe(key?: string): Safe {
|
||||
return Pipeline.id()
|
||||
.tap(val => new Safe(val))
|
||||
.tap(safe => safe.onError(message => {
|
||||
throw new HTTPError(HTTPStatus.BAD_REQUEST, `Invalid field (${key}): ${message}`)
|
||||
}))
|
||||
.apply(this.input(key))
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the UniversalPath instance for a file uploaded in the given field on the request.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user