Content-Length: 285098 | pFad | http://github.com/restyjs-graveyard/jwt

EB GitHub - restyjs-graveyard/jwt: JWT middleware for resty.js.
Skip to content
This repository was archived by the owner on Dec 19, 2021. It is now read-only.

restyjs-graveyard/jwt

Repository files navigation

@restyjs/jwt

JWT middleware for resty.js.

import resty, { Controller, Get, Inject, Context } from "@restyjs/core";
import { JWTConfiguration, JWTProvider, ValidateJWT } from "@restyjs/jwt";


@Controller("/")
class HelloController {
  @Inject() jwtProvider!: JWTProvider;

  @Get("/generate")
  async generate() {
    const token = await this.jwtProvider.generate({
      id: 1,
      email: "foo@bar.com",
    });

    return {
      token,
    };
  }

  @Get("/validate", [ValidateJWT])
  validate(ctx: Context) {
    return {
      token: ctx.req.token,
    };
  }
}

const app = resty({
  controllers: [HelloController],
  providers: [JWTConfiguration("secret")],
});

app.listen(8080);

Packages

 
 
 

Contributors 3

  •  
  •  
  •  








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/restyjs-graveyard/jwt

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy