1.0.6 • Published 1 year ago

upscale-api v1.0.6

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year ago

Upscale API

This is a tool to validate data that was provided to your API.

Usage

  1. Create a file named api.json in the root of your project.
  2. Config the api.json file to match your endpoints and the validations that you need to perform.
{
	"/routepath": {
		"GET": [
			{
				"name": "parameter name",
				"type": "STRING",
				"required": true,
				"location": "query"
			}
		]
	}
}
  1. Add the Express middleware to you server
import * as express from 'express'
import { createServer } from 'http'
import { verifyExpressInformation } from 'upscale-api'

const app = express()
const PORT = 8888

app.use(express.json())

app.use(verifyExpressInformation)

const server = createServer(app)

server.listen(PORT)
  1. Fetch your API, if any errors are detected it will contain in the API response.

API Config

  • The api.json file is what config the validation that is performed on every request. - Every key of the JSON file is a route for your API - Inside every route ovject you can set the method of the request GET | POST | PUT | DELETE - In every method you can supply a list of validations with the following fields

Properties

PropertyTypeDescription
namestringName of the property
typeNUMBER - STRING - DATEThe type of the property
requiredbooleanIf the parameter is required
locationparams - query - bodyWhere the parameters is located in the request
1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago