oly-security
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

oly security

Secure a REST API.

oly security is an extension of oly api.

import { inject, Kernel } from "oly";
import { ApiProvider, get } from "oly-api";
import { auth, JwtAuth, Auth } from "oly-security";
 
class Api {
  @inject auth: Auth;
 
  @get("/token") token() {
    return this.auth.createToken({id: "0", roles: ["ADMIN"]});
  }
 
  @auth("ADMIN")
  @get("/secret") secret() {
    return {ok: true, id: this.auth.token.id};
  }
}
 
Kernel
  .create()
  .with({provide: Auth, use: JwtAuth})
  .with(Api, ApiProvider)
  .start()
  .catch(console.error);

Installation

$ npm install oly oly-api

Dependencies

JSON Web Token jsonwebtoken
Hashing bcryptjs

Readme

Keywords

Package Sidebar

Install

npm i oly-security

Weekly Downloads

1

Version

1.0.0

License

MIT

Unpacked Size

56.9 kB

Total Files

78

Last publish

Collaborators

  • nolyme