GithubHelp home page GithubHelp logo

vercel / schemas Goto Github PK

View Code? Open in Web Editor NEW
79.0 51.0 27.0 142 KB

All schemas used for validation that are shared between our projects

Home Page: https://npmjs.com/@zeit/schemas

License: MIT License

JavaScript 100.00%
json ajv schemas validation

schemas's Introduction

Vercel Schemas

Schemas used across many Vercel packages to validating config files, requests to APIs, and more.

Why?

  • Keep schemas used across Vercel projects in sync
  • We use .js instead of .json because parsing JSON takes longer

Usage

To get started, pick one of the schemas in this repository and load it:

const schema = require('@zeit/schemas/deployment/config');

Next, set up AJV (the validator) and run the schema through it:

const AJV = require('ajv');

const ajv = new AJV({ allErrors: true });
const isValid = ajv.validate(schema, <object-to-validate>);

if (!isValid) {
	console.error(`The following entries are wrong: ${JSON.stringify(ajv.errors)}`);
}

That is all! πŸŽ‰

Contributing

We are currently not accepting external contributions for this repository.

schemas's People

Contributors

anatrajkovska avatar andybitz avatar antonmoiseev avatar arunoda avatar ernestd avatar fostersamuel avatar gaspar09 avatar gdborton avatar greenkeeper[bot] avatar iteratetograceness avatar javivelasco avatar johnphamous avatar leerob avatar leo avatar matheuss avatar maxleiter avatar natew avatar pranaygp avatar rauchg avatar rdev avatar simonhaenisch avatar tknickman avatar tootallnate avatar wentsul avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

schemas's Issues

Don't depend on `features.cloud: v2` for `slot`

Right now, if you try and set the slot key without setting feautres.cloud to v2, it'll error out. Unfortunately, for OSS, we already make cloud: v2 by default on the server, so we shouldn't do this. The logic should be:

You can set cloud: v2 and/or slot independently of each other:

  1. cloud: v2 is always respected on the server as an intent to opt-in to cloud v2 and will supply a default slot if one isn't provided
  2. Setting slot has no bearing on whether the deployment is/isn't v2, but if it is v2, this setting will override the default and be used for the deployment

The `limits` parameter of `now.json` doesn’t work with the error `config should NOT have additional properties`

Error: Invalid request: config should NOT have additional properties
    at deployment.retry (/Users/NaoyukiKanezawa/github.com/zeit/now-cli/src/providers/sh/util/index.js:275:14)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)

Tested with the canary branch of now-cli.

btw now-cli sends duplicated limit value in the request body like the following:

{ env: {},
  public: undefined,
  forceNew: false,
  name: 'test-slot',
  description: undefined,
  deploymentType: 'docker',
  registryAuthToken: undefined,
  files:
   [ { sha: '759d62c7c6c67fe510c0447891c1936dab297c13',
       size: 75,
       file: 'package.json',
       mode: 33188 },
     { sha: '4ca932a5423661e9eeed6ca069815c9d67e7ca17',
       size: 107,
       file: 'index.js',
       mode: 33188 },
     { sha: '48a077c7d28c5226dfb0cdd5263674abedce84f8',
       size: 108,
       file: 'now.json',
       mode: 33188 },
     { sha: '980fad954a72a9233102f59cf4086e5b4054a5b8',
       size: 88,
       file: 'Dockerfile',
       mode: 33188 } ],
  engines: undefined,
  scale: {},
  sessionAffinity: 'ip',
  limits: { maxConcurrentReqs: 1 },
  atlas: false,
  config:
   { type: 'docker',
     features: { cloud: 'v2' },
     limits: { maxConcurrentReqs: 1 } } }

I wonder if it's expected.

static deployments can't have env

I don't think this should be a valid now.json:

{
  "type": "static",
  "env": {
    "NPM_TOKEN": "@npm-token",
  }
}

As far as I know only build time env makes sense for static deployments.

Add JSON Schema files

πŸ‘‹ - One thing I used for Peril that has been really useful is to export a JSON schema in the repo for the app settings file. This is auto-generated from the objects in the repo.

Then you can use this arbitrarily in any JSON file by using "$schema": "[url]":

screen shot 2019-02-18 at 6 22 10 am

Now I've got validations + docs inline in my editor.

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.