all repos — litestore @ f1832f40b40c48fbb17efe6d15a44c5cf03d6228

A minimalist nosql document store.

src/litestorepkg/examples/middleware/log.js

 1
 2
 3
 4
 5
 6
 7
 8
 9
 10
(function(){
    var doc = {
        sub: $req.jwt.claims && $req.jwt.claims.sub || null,
        agent: $req.headers['user-agent'],
        language: $req.headers['accept-language'] && $req.headers['accept-language'].replace(/,.+$/, ''),
        path: $req.path,
        timestamp: Date.now()
    }
    $store.post('docs', 'logs', JSON.stringify(doc), 'application/json');
}())