@tsed/platform-fastify
Version:
Fastify package for Ts.ED framework
34 lines (33 loc) • 793 B
JavaScript
import "@fastify/accepts";
import { PlatformRequest } from "@tsed/platform-http";
/**
* @platform
* @fastify
*/
export class PlatformFastifyRequest extends PlatformRequest {
get host() {
return this.raw.hostname;
}
get secure() {
return this.protocol === "https";
}
/**
* Returns the HTTP request header specified by field. The match is case-insensitive.
*
* ```typescript
* request.get('Content-Type') // => "text/plain"
* ```
*
* @param name
*/
get(name) {
return this.raw.raw.headers[name.toLowerCase()];
}
getReq() {
return this.raw.raw;
}
accepts(mime) {
const accepts = this.raw.accepts().type([].concat(mime));
return (accepts ? accepts : false);
}
}