Code Monkey home page Code Monkey logo

socket-config-js's Introduction

Socket Config

Socket Badge npm version js-standard-style Types in JS Follow @SocketSecurity

Reader/parser/validator tool for Socket.dev's socket.yml configuration files

Usage

npm install @socketsecurity/config
import { readSocketConfig } from '@socketsecurity/config'

const config = await readSocketConfig('socket.yml')

Exports

readSocketConfig(<path-to-config-file>)

Returns a Promise that resolves to the parsed config file or, if no such file was found, it fails silently and returns undefined.

If the config file can't be read, then the Promise will be rejected with an error.

The read file is parsed using parseSocketConfigand the Promise from there is what is ultimately returned when no rejection or resolve has been made already.

parseSocketConfig(<content-of-config-file>)

Returns a Promise that resolves to the parsed config.

If the config content can't be parsed or it is invalid, then the Promise will be rejected with an error.

Any additional parameters that does not conform to the schema will be silently dropped. Also: Input data will be coerced into its intended shape when possible.

socketYmlSchema

A JSON Schema object typed with JSONSchemaType<SocketYml> from Ajv

SocketValidationError

Error thrown when the parsed data doesn't conform to the JSON Schema definition.

Extends Error and adds these additional properties:

  • data – the data that's found to be invalid
  • schema – the schema used to validate the content
  • validationErrors – an array of Ajv's ErrorObject

Type exports

This module has full type coverage through a types in js where TypeScript validates JSDoc annotated javascript and exports it as standard type definition files.

SocketYml

A TypeScript type representing the shape of the parsed socket.yml config

Used by

See also

socket-config-js's People

Contributors

bcomnes avatar voxpelli avatar dependabot[bot] avatar socket-bot avatar raynos avatar feross avatar

Forkers

renovate-bot

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.