@indepthwebsolutions/session-control
v1.0.7
Published
Control express.js sessions
Downloads
46
Maintainers
Readme
Control Node Sessions
Usage
This package is designed for Indepth Solutions LTD. for managing node sessions with a high level abstraction of express. It can be used for other purposes too.
Installation
NPM
npm i @indepthwebsolutions/session-control
YARN
yarn add @indepthwebsolutions/session-control
On your server add this env variable:
.env
INDEPTH_AUTH_KEY=put_your_key_here
In your request body, you must include this security token:
headers: {
'Authorization': 'Indepth-Auth-Key put_your_key_here',
}
Usage
import Session from '@indepthwebsolutions/session-control';
const session = new Session({ req, requiredParams: [ 'text', 'source_lang', 'target_lang' ] });
if(!session.isAuthorized()) return res.status(400).json({ error: "named error" });
if (!session.hasRequiredParams()) return res.status(400).json({ error: "named error" });