Skip to content
This repository was archived by the owner on Oct 26, 2024. It is now read-only.
afoster549Public archive

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Latest commit

 

History

123 Commits

Folders and files

Repository files navigation

Documentation

Middleware

Middleware

Validation

Code

Validates the data within the body of a request.

Arguments: data: Object, any: Boolean

Data is the data that should be included in the body, any indicates that only one or more of the items is required.

Usage

The example below is for the data agument, it indicates that the body must have a username and password and they must both be strings.

{
    "username": {
        type: "string"
    },
    "password": {
        type: "string"
    }
}

The example below is the middleware in use, the any argument is set to false meaning both items are required.

const express = require("express")
const router = express.Router()
const validation = require("/middleware/validation")

router.use(
    validation({
        "username": {
            type: "string"
        },
        "password": {
            type: "string"
        }
    }, false)
)

Auth

Code

Checks that a user has the correct authentication to make a request. This should be used for protected endpoints

Usage

const express = require("express")
const router = express.Router()
const auth_mid = require("/middleware/auth")

router.use(auth_mid)

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Contributors

Languages