npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

egg-config-validator

v0.2.2

Published

A plugin to validate the config of egg as your start the egg app

Downloads

21

Readme

egg-config-validator

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

A plugin to check the config when the app started. If it found the config could not fit the requirement. It will throw error.

It check the config based on a json schema. You can provide a schema or a json which we will transfer into a schema.

Install

$ npm i egg-config-validator --save

Usage

// {app_root}/config/plugin.js
exports.configValidator = {
  enable: true,
  package: 'egg-config-validator',
};

Configuration

// {app_root}/config/config.default.js
exports.configValidator = {
  standard: Object | string,
  type: 'json' | 'jsonschema',
  showStandard: boolean,
};

see config/config.default.js for more detail.

| property | type | meaning | default | limitation | | -------------------- | ----------------- | ---------------------------------------- | ---------- | ----------------------------- | | standard | Object | string | The standard of the config, it can be an Object or a path string pointing to the standard. | {} | | | type | String | We only support jsonschema and json currently. As they are totally the same, you should declare it. | jsonschema | | | showStandard | Boolean | We will output the json schema in console.log to help you to debug. | false | | | target | Object | string | We use app.config as target object. But you can also customize your config. You can pass in an Object or a path string pointing to the target file | app.config | | | requiredProperties | Boolean | We will set every properties in standard as required properties if this is true. | true | Only work when type is JSON | | additionalProperties | Boolean | Object | The additionalProperties keyword is used to control the handling of extra stuff, that is, properties whose names are not listed in the properties keyword. By default any additional properties are allowed. The additionalProperties keyword may be either a boolean or an object. If additionalProperties is a boolean and set to false, no additional properties will be allowed. If additionalProperties is an object, that object is a schema that will be used to validate any additional properties not listed in properties. | true | Only work when type is JSON |

Example

standard can be a json.

exports.configValidator = {
  standard: {
    person: {
      firstName: 'hello ',
      lastName: 'world!',
      age: 33,
    },
  },
  type: 'json',
};

standard can be a json schema.

exports.configValidator = {
  standard: {
    title: 'config',
    type: 'object',
    properties: {
      person: {
        title: 'person',
        type: 'object',
        properties: {
          firstName: {
            type: 'string',
          },
          lastName: {
            type: 'string',
          },
          age: {
            description: 'Age in years',
            type: 'integer',
            minimum: 0,
          },
        },
        required: [ 'firstName', 'lastName' ],
      },
    },
    required: [ 'person' ],
  },
  type: 'jsonschema',
};

standard can be stored in file.

exports.configValidator = {
  standard: path.resolve(__dirname, './config.standard.js'),
  type: 'json',
};

Questions & Suggestions

Please open an issue here.

License

MIT