JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 3
  • Score
    100M100P100Q37123F
  • License MIT

JWT-checking decorator for typescript-rest

Package Exports

  • typescript-rest-jwt-guard

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (typescript-rest-jwt-guard) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

JwtGuard for typescript-rest

Installation

Using npm:

$ npm i typescript-rest-jwt-guard

Or using yarn:

$ yarn add typescript-rest-jwt-guard

Usage

First, you must provide cookie parser:

app.use(cookieParser());

Now you can use the decorator in your methods:

import { Path, GET, Context, ServiceContext } from 'typescript-rest';
import { Inject } from 'typescript-ioc';
import JwtGuard from 'typescript-rest-jwt-guard';

@Path('/health')
export default class HealthController {

  // Simple method.
  @GET
  public getHealthStatus() {
    return { message: 'Ok' };
  }

  // Method requiring JWT.
  @JwtGuard
  @Path('/secured')
  @GET
  public getHealthStatusSecured(@Context _context: ServiceContext) {
    return { message: 'Ok' };
  }
}