sc

session-check

Express middleware to check if session is available

Showing:

Popularity

Downloads/wk

0

GitHub Stars

1

Maintenance

Last Commit

5yrs ago

Contributors

0

Package

Dependencies

0

License

Apache-2.0

Type Definitions

Tree-Shakeable

No?

Categories

Readme

session-check

Express middleware to check if session is available

This middleware check if session is available or not. This is very simple and unnecessary operation unless you use some session storage strategy that for example use MongoDB, Redis or other storage system to serialize and deserialize the session. Using one of these strategies give us a more effiecient handling of the session but if we restart the express server we need some extra time to get the session available so we cannot handle some request. To avoid possible error you can use sessio-check.

Installation

If you want use session-check you have to install it. There are two methods for that: In your package.json add the following item:

"sessione-check": "version"

then digit

npm install

Example:

"session-check": "*" for the latest version
"session-check": "1.0.0" for the version 1.0.0

OR

launch this command:

npm install session-check --save

Use

const sessionCheck = require('session-check');

//Import some other required modules
const express = require('express');
const app = express();
//Some other configuration for the express app and session

app.use(sessionCheck()); 

In this example session-check dispatch an Error with message ("Session is not yet ready.") to Express error handler.

You could set a custom error message as reported below:

app.use(sessionCheck("My personal message error about session")); 

In the end is also possible pass an error objet to session-check middleware that provide to dispatch it to Express error handler.

You could set a custom error object as reported below:

app.use(sessionCheck(new MyError("My personal message error onject session")); 

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100
No reviews found
Be the first to rate

Alternatives

No alternatives found

Tutorials

No tutorials found
Add a tutorial