0.0.15 • Published 4 years ago

typestack-authorizer v0.0.15

Weekly downloads
61
License
ISC
Repository
-
Last release
4 years ago

��# Typestack Authorizer

Indevelopment

Opinionated authorizer using the power of typescript annotation to annotate ClassType and Methods,

Installation

Authorizer

Allow Access

Deny Access

Type Graphql Middleware

Installation

npm install typestack-authorizer

Authorizer

@Authorizer()
export class PostResolver { }

Allow Access

@Allow()
createPost(){ }

Deny Access

@Deny()
deletePost(){ }

Type Graphql Global Middleware

import { NextFn } from 'type-graphql'
import { Effect, AuthorizerData } from 'typestack-authorizer'


async function authorizer({ authorizer }: AuthorizerData, next: NextFn){
  
  if (authorizer.effect === Effect.ALLOW) {
  
    return await next()
  
  } else if (authorizer.effect === Effect.DENY) {
    
    throw new Error('Unauthorized')
  
  } else {

    // else
  
  }

}

registerTypeGraphqlGlobalMiddleware(authorizer)
0.0.10

4 years ago

0.0.11

4 years ago

0.0.12

4 years ago

0.0.13

4 years ago

0.0.14

4 years ago

0.0.15

4 years ago

0.0.9

4 years ago

0.0.8

4 years ago

0.0.7

4 years ago

0.0.6

4 years ago

0.0.5

4 years ago

0.0.4

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago