1.10.9 • Published 4 years ago

monastery-js v1.10.9

Weekly downloads
65
License
MIT
Repository
github
Last release
4 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

4 years ago

1.10.8

4 years ago

1.10.7

4 years ago

1.10.6

4 years ago

1.10.5

5 years ago

1.10.4

5 years ago

1.10.3

5 years ago

1.10.2

5 years ago

1.10.1

5 years ago

1.10.0

5 years ago

1.9.3

5 years ago

1.9.2

5 years ago

1.9.1

5 years ago

1.9.0

5 years ago

1.8.2

5 years ago

1.8.1

5 years ago

1.8.0

5 years ago

1.7.1

5 years ago

1.7.0

5 years ago

1.6.6

5 years ago

1.6.5

5 years ago

1.6.4

5 years ago

1.6.3

5 years ago

1.6.2

5 years ago

1.6.1

5 years ago

1.6.0

5 years ago

1.5.0

5 years ago

1.4.0

5 years ago

1.3.29

5 years ago

1.3.28

5 years ago

1.3.26

5 years ago

1.3.27

5 years ago

1.3.25

5 years ago

1.3.24

5 years ago

1.3.23

5 years ago

1.3.22

5 years ago

1.3.21

5 years ago

1.3.20

5 years ago

1.3.19

5 years ago

1.3.18

5 years ago

1.3.17

5 years ago

1.3.16

5 years ago

1.3.15

5 years ago

1.3.14

5 years ago

1.3.13

5 years ago

1.3.12

5 years ago

1.3.11

5 years ago

1.3.10

5 years ago

1.3.9

5 years ago

1.3.8

5 years ago

1.3.7

5 years ago

1.3.6

5 years ago

1.3.5

5 years ago

1.3.4

5 years ago

1.3.3

5 years ago

1.3.2

5 years ago

1.3.1

5 years ago

1.3.0

5 years ago

1.2.1

5 years ago

1.2.0

5 years ago

1.1.0

5 years ago

1.0.0

5 years ago