1.5.3 • Published 8 months ago

@publicodes/rest-api v1.5.3

Weekly downloads
-
License
MIT
Repository
github
Last release
8 months ago

This package allows you to create a REST API, which follows OpenAPI 3.0 specifications, from your Publicodes rules.

It consists of Koa middleware that adds routes to your router:

  • POST /evaluate Evaluate one or more expressions with a given situation
  • GET /rules Returns the list of all your rules
  • GET /rules/{rule} Returns a specific rule

Getting started

npm install @publicodes/api
import Router from '@koa/router'
import Koa from 'koa'
import Engine from 'publicodes'
import { koaMiddleware as publicodesAPI } from '@publicodes/api'

const app = new Koa()
const router = new Router()

// Create middleware with your Engine
const apiRoutes = publicodesAPI(new Engine('coucou: 0'))

// Basic routes usage (/evaluate, /rules, etc.)
router.use(apiRoutes)

// Or use with specific route prefix (/v1/evaluate, /v1/rules, etc.)
router.use('/v1', apiRoutes)

app.use(router.routes()).listen(3000)

// ...
1.5.3

8 months ago

1.3.3

1 year ago

1.5.0

11 months ago

1.3.2

1 year ago

1.4.0

11 months ago

1.3.1

1 year ago

1.3.0

1 year ago

1.2.0

1 year ago

1.1.1

1 year ago

1.1.0

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

1.0.0-rc.7

1 year ago

1.0.0-rc.6

1 year ago

1.0.0-rc.5

1 year ago

1.0.0-rc.3

1 year ago

1.0.0-rc.4

1 year ago

1.0.0-rfc.2

1 year ago

1.0.0-rfc.1

1 year ago