all repos — litestore @ a21ea4c45adf73ff689088392735cb1a97ee94a9

A minimalist nosql document store.

src/litestorepkg/examples/system/middleware/log.js

 1
 2
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
(function(){
    var doc = {
        user: $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,
        existing: !!$ctx.existing,
        method: $req.method,
        timestamp: Date.now()
    }
    $store.post('docs', 'logs', JSON.stringify(doc), 'application/json');
}())