Giter Club home page Giter Club logo

no-hassle's Introduction

No Hassle

Makes Node.js route handling easy with support for Joi schema validation and automatic Swagger generation based on these schema definitions. Uses Expressjs routing mechanism.

  • ✅ Easy to maintain Joi schemas

  • ✅ Input validation

  • ✅ Easy integration tests data output validation

  • ✅ No more manual Swagger files, ever!

  • ✅ No extra comments above every function to expose

  • 🛠 Automatic mocked routes with the switch of a boolean (in progress)

  • 🛠 Automatic fully generated SDK file based on your routes (in progress)

Installation

Install via npm

npm install no-hassle

or via yarn

yarn add no-hassle

Usage

const express = require('express');
const swaggerUi = require("swagger-ui-express");

const { router, getSwagger } = require('no-hassle');

// Create Express app instance
const app = express();

// Declare route(s)
router.use(app, '/users')
  .get('/', {
    description: 'Get all users',
    tags: ['Users'],
    output: {
      [httpStatus.OK]: userOutputSchema, // Joi schema
    },
  },
    (req, res) => { ... }

// Get autogenerated Swagger
const swagger = getSwagger({
  version: '1.0.0',
  title: 'My super cool API',
  description: 'This describes all exposed api endpoints',
});

// Serve swagger-ui
app.use("/docs", swaggerUi.serve, swaggerUi.setup(swagger))

// Start server
app.listen(4000)

This will start an Express server with one route and autogenerated Swagger documentation based on the description, tags and output schema.

Remarks

Current support

Authors

See the list of contributors who participated in this project.

License

This project is licensed under the ISC License - see the LICENSE.md file for details

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.