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

egg-parameters

Package Overview
Dependencies
Maintainers
13
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

egg-parameters

Merge ctx.params, ctx.request.query, ctx.request.body into ctx.params"

latest
Source
npmnpm
Version
1.1.2
Version published
Weekly downloads
127
69.33%
Maintainers
13
Weekly downloads
 
Created
Source

egg-parameters

NPM version build status Test coverage David deps Known Vulnerabilities npm download

Merge all parameters (ctx.params, ctx.request.query, ctx.request.body) into ctx.params like Rails application.

Configuration

config/plugin.js

exports.parameters = {
  enable: true,
  package: 'egg-parameters',
};

config/config.default.js

exports.parameters = {
  logParameters: true,
  // param names that you want filter in log.
  filterParameters: ['password'],
};

Usage

When you add egg-parameters into your package.json this will enabled by default.

// app/controller/posts.js
module.exports = class {
  /**
   * POST /posts?title=jason&foo=1&user_id=123
   */
  async create() {
    const { ctx } = this;
    const postParam = ctx.params.permit('title', 'body')

    // postParam => { title: '', body: '' }
    // postParam.isPermitted() => true
    // :foo, :user_id will be filted

    // Now you can use safely for egg-sequelize create param
    const post = await ctx.model.Post.create(postParam);
    ctx.body = post;
  }
};

FAQs

Package last updated on 18 Oct 2019

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