@honout/http
TypeScript icon, indicating that this package has built-in type declarations

0.0.1 • Public • Published

Honout http

Create endpoint

import { injectable } from '@honout/system';
import { Method, Route, IHttpResponse, JsonResponse } from '@honout/http';

@injectable()
@Method('get')
@Route('/user')
export class UserEndpoint implements IHttpRequestHandler {
    async handle(): Promise<IHttpResponse> {
        return new JsonResponse({ email: 'abc@xyz.com' });
    }
}

Create http server

import { injectable } from '@honout/system';
import { HonoutHttpServer, ServiceIdentifiers } from '@honout/http';

@injectable()
@WithFunctionality({
    functionality: HonoutHttpServer,
    configure: {
        port: 4500,
    },
    extend: [
        {
            identifier: ServiceIdentifiers.REQUEST_HANDLER,
            definitions: [UserEndpoint],
        },
    ],
})
class Application implements IApplication {}

Decorators

@Route

Specify the route of the endpoint

@Route('/user')

@Method()

Specify the route of the endpoint

@Route('get')

Supported types:

  • get
  • post
  • put
  • delete
  • patch
  • all

Response Types

  • JsonResponse
  • StringResponse
  • NotFoundResponse
  • StreamResponse

Package Sidebar

Install

npm i @honout/http

Weekly Downloads

1

Version

0.0.1

License

MIT

Unpacked Size

28.9 kB

Total Files

65

Last publish

Collaborators

  • jonathanrydholm