1.0.2 • Published 7 years ago

viewcount v1.0.2

Weekly downloads
1
License
ISC
Repository
-
Last release
7 years ago

viewcount


This package is used to count the view counts.

It store the value with the redis, so it doesn't matter restart your webserver.

When a client come to view the website first, this middware will set the cookie, and when it come next time, the middware will find that it has come here before by the cookie.

1.install

to use the package, your should do follows:

npm install viewcount

and you should install the redis and cookie-parser before to use this.

2.how to use

you can use it like this:

var cookieParser = require('cookie-parser');
var viewcount = require('viewcount');
var app = express();
app.use(cookieParser());
app.use('/',viewcount());
..//some other routes

3.get the viewcount

you can get the viewcount like this in your page before render it to client:

<%= viewCount %>