0.0.11 • Published 4 years ago

loy v0.0.11

Weekly downloads
6
License
MIT
Repository
github
Last release
4 years ago

loy

Like Joi but for outputs

Loy is a little helper for defining REST outputs, Aimed to be used inside the Moser web framework.

Loy accomplish two missions:

  • Define the REST output in order to generate documentation automatically.
  • Restrict output fields based on user's permissions.

## Usage

Define an output function:

import {Give} from 'Joi'

const out:(resource,user)=>{
  return {
    field1: Give(resource.field1, user)
      .for('admin') // define the necessary user permission
      .or('user') // alternative permission
      // documentation:
      .as('string')
      .example('field example')
      .description('field description')
      // always finish with this:
      .ok()
  }
}

Moser will execute the function, and return the field only if the user have the permission.

to get the output definition

import {Give, Describe} from 'Joi'

const description= Describe(out)
0.0.11

4 years ago

0.0.10

5 years ago

0.0.9

5 years ago

0.0.8

5 years ago

0.0.7

5 years ago

0.0.6

5 years ago

0.0.5

5 years ago

0.0.4

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago

0.0.0

5 years ago