New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

restlog

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

restlog

auto manage web app log working with restful api

latest
Source
npmnpm
Version
0.0.9
Version published
Maintainers
1
Created
Source

RestLog

Build status

auto manage web app log working with restful api

中文

Data struct

{
  userId: '',
  resource: '',
  operation: '',        // operation type. default use HTTP methods get / post / put / delete
  status: 1,            // operation result. 1 - succeed, -1 - fail, 0 - unknown
  createdAt: '',
  originRequest: {      // original request data
    url: '',
    method: '',
    ip: '',
    userAgent: '',
    body: {}
  },
  originResponse: {     // original response data
    statusCode: 200,
    body: {}
  }
}

Usage


import Koa from 'koa'
import RestLog from 'restlog'

const koa = new Koa()

// create restLog instance
const restLog = new RestLog({
  dbSaver: {                            // MongoDB config
    dbClient: MongoDBInstance,
    collectionName: 'demo'
  },
  getUserId: async (ctx)=> {           // get now user id
    return 'test-user'
  },
  getResource async (ctx)=> {          // get now resource (operation object) id
    return 'test-resource'
  },
  filter: (url)=> {                    // url filter, return false when this url do not need log
    return true
  },
  localPath: 'path/to/save/logs/temporary',   // local path for saving log
  uploadCondition: {                   // upload logs condition
    filesLimit: 2,                     //
    fileSizeLimit: 10,                 // KB
    fileExpireTime: 3 * 60,            // Second
    intervalTime: 60,                  // Second
  }
})

// add koa middleware
app.use(restLog.getMiddleware())


/**
 * pull log info
 * restLog.search({startAt, endAt, userId, resource, operation, page, pageSize})
 */

app.listen()

Keywords

koa

FAQs

Package last updated on 19 Jan 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts