1.10.9 • Published 3 years ago

monastery-js v1.10.9

Weekly downloads
65
License
MIT
Repository
github
Last release
3 years ago

npm.io

NPM Build Status

Features

  • User friendly API design
  • Simple CRUD methods with model population
  • Model validation deriving from your schema
  • Custom error messages can be defined in your schema
  • Error response ready for client consumption
  • Automatic index setup
  • Lightweight

Install

This repository is distributed with NPM. After installing NPM, you can install Monastery via:

npm install --save monastery-js

Usage

// Require monastery
const monastery = require('monastery-js')

// Initalise a model
let user = monastery.model('user', {
  fields: {
    name: { type: 'string' },
    pets: [{ type: 'string' }],
    address: { city: { type: 'string', minLength: 20 } },
    points: [[{ type: 'number' }]]
  }
})

// Validate some data
user.validate({
  name: 'Ip Man', 
  pets: ['sparky', 'tiny'],
  address: { city: 'Christchurch' },
  points: [[1, 5], [3, 1]]

}).then(data => {
  // valid data..

}).catch(errs => {
  // [{
  //   detail: "Value needs to be at least 10 characters long.",
  //   status: "400",
  //   title: "city",
  //   meta: {
  //     model: "user",
  //     path: "address.city",
  //     rule: "minLength"
  //   }
  // }]
})

Contributing

Coming soon...

License

Copyright 2019 Ricky Boyce. Code released under the MIT license.

1.10.9

3 years ago

1.10.8

3 years ago

1.10.7

3 years ago

1.10.6

3 years ago

1.10.5

3 years ago

1.10.4

3 years ago

1.10.3

3 years ago

1.10.2

3 years ago

1.10.1

3 years ago

1.10.0

3 years ago

1.9.3

4 years ago

1.9.2

4 years ago

1.9.1

4 years ago

1.9.0

4 years ago

1.8.2

4 years ago

1.8.1

4 years ago

1.8.0

4 years ago

1.7.1

4 years ago

1.7.0

4 years ago

1.6.6

4 years ago

1.6.5

4 years ago

1.6.4

4 years ago

1.6.3

4 years ago

1.6.2

4 years ago

1.6.1

4 years ago

1.6.0

4 years ago

1.5.0

4 years ago

1.4.0

4 years ago

1.3.29

4 years ago

1.3.28

4 years ago

1.3.26

4 years ago

1.3.27

4 years ago

1.3.25

4 years ago

1.3.24

4 years ago

1.3.23

4 years ago

1.3.22

4 years ago

1.3.21

4 years ago

1.3.20

4 years ago

1.3.19

4 years ago

1.3.18

4 years ago

1.3.17

4 years ago

1.3.16

4 years ago

1.3.15

4 years ago

1.3.14

4 years ago

1.3.13

4 years ago

1.3.12

4 years ago

1.3.11

4 years ago

1.3.10

4 years ago

1.3.9

4 years ago

1.3.8

4 years ago

1.3.7

4 years ago

1.3.6

4 years ago

1.3.5

4 years ago

1.3.4

4 years ago

1.3.3

4 years ago

1.3.2

4 years ago

1.3.1

4 years ago

1.3.0

4 years ago

1.2.1

4 years ago

1.2.0

4 years ago

1.1.0

4 years ago

1.0.0

4 years ago