# contract_node

> Yet Another Contract Code

Latest version **1.0.1** (published 2016-04-22) · MIT license · 0 weekly downloads

## Install

```sh
npm install contract_node
pnpm add contract_node
yarn add contract_node
bun add contract_node
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2016-04-22 |
| First published | 2016-04-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | NikkoScript |
| Maintainers | nikkoscript |
| Keywords | contract, nodejs |

## Links

- npm: https://www.npmjs.com/package/contract_node
- Repository: https://github.com/NikkoScript/contract_node
- Homepage: https://github.com/NikkoScript/contract_node#readme
- Issues: https://github.com/NikkoScript/contract_node/issues
- npm.io page: https://npm.io/package/contract_node

## Recent versions

- 1.0.1 (latest) — 2016-04-22

## README

## Contract Node

SomeTime you want to check the request properties send to your back-end. Specially if you want update your database (MongoDB-like)with this request.
That what this module do. Check the name of your properties and only that.

## Code Example
Contract contructor:
````javascript
//@Param mandatory Array(String) mandatory parameter to fullfill the contract
//@Param optionnal Array(String) parameter can be pass but not needed to fullfill the contract
Contract(mandatory,optionnal)
````

Give one object given by the client to fullfill the contract
````javascript
//@Param Object Object request send by the client to fullfild the contract
contract.params(Object)
````

End the contract:
````javascript
contract.end()
````
Get the state of the contract ( false : invalid, true : valid )
````javascript
contract.valid()
````
#Code Sample
````javascript
var mycontract= new Contract(["id","name"])
var request={ id : "a00000"
              name : "John"
            }
if(mycontract.params(request).end().valid()){
  // update my DB with request
}


// you have another request ?

var newrequest={ id : "a00001"
              name : "Peter"
            }
if(mycontract.params(newrequest).end().valid()){
  // this will never be done, add a new parameter to an ended contract fail everytime
}

// you need a new contract for another request
var mynewcontract= new Contract(["id","name"])
if(mynewcontract.params(newrequest).end().valid()){
  // You can update your databse now
}
````

## Motivation

To devellop my skill in Javascript and Specially with NodeJs i need to do some work. So this present library is the beginning of this.

## Installation

npm install


## License

MIT : Feel free to use.

---
_Source: https://npm.io/package/contract_node · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
