yup-x
TypeScript icon, indicating that this package has built-in type declarations

0.2.1 • Public • Published

YupX


      _____                    _____                    _____
     |\    \                  /\    \                  /\    \                 ______
     |:\____\                /::\____\                /::\    \               |::|   |
     |::|   |               /:::/    /               /::::\    \              |::|   |
     |::|   |              /:::/    /               /::::::\    \             |::|   |
     |::|   |             /:::/    /               /:::/\:::\    \            |::|   |
     |::|   |            /:::/    /               /:::/__\:::\    \           |::|   |
     |::|   |           /:::/    /               /::::\   \:::\    \          |::|   |
     |::|___|______    /:::/    /      _____    /::::::\   \:::\    \         |::|   |
     /::::::::\    \  /:::/____/      /\    \  /:::/\:::\   \:::\____\  ______|::|___|___ ____
    /::::::::::\____\|:::|    /      /::\____\/:::/  \:::\   \:::|    ||:::::::::::::::::|    |
   /:::/~~~~/~~      |:::|____\     /:::/    /\::/    \:::\  /:::|____||:::::::::::::::::|____|
  /:::/    /          \:::\    \   /:::/    /  \/_____/\:::\/:::/    /  ~~~~~~|::|~~~|~~~
 /:::/    /            \:::\    \ /:::/    /            \::::::/    /         |::|   |
/:::/    /              \:::\    /:::/    /              \::::/    /          |::|   |
\::/    /                \:::\__/:::/    /                \::/____/           |::|   |
 \/____/                  \::::::::/    /                  ~~                 |::|   |
                           \::::::/    /                                      |::|   |
                            \::::/    /                                       |::|   |
                             \::/____/                                        |::|___|
                              ~~                                               ~~

Quick Start

Check out our recipes repo to learn how everything works.

Description

YupX lets you deploy an API for your backend using just yup schemas.

Essentially, it does all the work to turn this:

const personSchema = yup.object({
  firstName: yup.string().defined(),
  nickName: yup.string().default('').nullable(),
  sex: yup
    .mixed()
    .oneOf(['male', 'female', 'other'] as const)
    .defined(),
  email: yup.string().nullable().email(),
  birthDate: yup.date().nullable().min(new Date(1900, 0, 1)),
});

Into this:

const express = require('express');
const yup = require('yup');
const router = express.Router();

// Create (POST)
router.post('/person', async (req, res) => {
	// ...
});

// Read (GET)
router.get('/person/:id', async (req, res) => {
	// ...
});

// Update (PUT)
router.put('/person/:id', async (req, res) => {
	// ...
});

// Delete (DELETE)
router.delete('/person/:id', async (req, res) => {
	// ...
});

module.exports = router;

Authors

License

BSD-3-Clause

Package Sidebar

Install

npm i yup-x

Weekly Downloads

0

Version

0.2.1

License

ISC

Unpacked Size

130 kB

Total Files

95

Last publish

Collaborators

  • kamarmack