New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

ts-express-authenticated

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ts-express-authenticated

Decorator for handler functions to check is request is authenticated.

latest
Source
npmnpm
Version
1.0.1
Version published
Weekly downloads
5
Maintainers
1
Weekly downloads
 
Created
Source

ts-express-authenticated

ts-express-authenticated is simple TypeScript decorator for express handler functions to validate body before function called. It checks if request is authenticated and call handler function or sends status of 401 with 'Unathorized access.' message.

Installation

Use the package manager npm to install express-body-params decorator.

npm i ts-express-authenticated

Usage

By defaut decorator checks if req.authed param is setted to true:

import { Authenticated } from 'ts-express-authenticated';


@Authenticated()
async getPayments(req: any, res: any): Promise<void> {
	...
}

You can change parameter to check by passing it as parameter:

import { Authenticated } from 'ts-express-authenticated';


@Authenticated('isAuthenticated')
async getPayments(req: any, res: any): Promise<void> {
    ...
}

You can change message for unauthorized case:

import { Authenticated } from 'ts-express-authenticated';


@Authenticated('isAuthenticated', 'You are not authorized for this route.')
async getPayments(req: any, res: any): Promise<void> {
    ...
}

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

Please star me on github. stveljko012

License

MIT

Keywords

node

FAQs

Package last updated on 30 Jan 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts