# zeenix

> An ES5 Express.js wrapper to quickly spin up a Node.js + MongoDB API.

Latest version **2.0.1** (published 2017-04-07) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

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

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 2.0.1 |
| Published | 2017-04-07 |
| First published | 2017-03-20 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Known vulnerabilities | 0 (+6 in 4 direct dependencies) |
| Install scripts | no |
| Author | Robby Marston |
| Maintainers | robmarston |

## Links

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

## Dependencies (4)

- [extend](https://npm.io/package/extend.md) 3.0.0
- [express](https://npm.io/package/express.md) 4.15.0
- [mongodb](https://npm.io/package/mongodb.md) 2.2.24
- [body-parser](https://npm.io/package/body-parser.md) 1.17.0

## Recent versions

- 2.0.1 (latest) — 2017-04-07
- 2.0.0 — 2017-04-06
- 1.0.1 — 2017-03-21
- 1.0.0 — 2017-03-20

## README

# Zeenix

An ES2015 Express.js wrapper to quickly spin up a Node.js + MongoDB REST(ish) API.

## Prequisities

* [Node.js](https://nodejs.org/en/) >=6.9.5
* [MongoDB](https://www.mongodb.com/) 

## Installation

Run `npm install zeenix`

## Setup

1. Create a MongoDB database.

2. Create a project directory that contains a directory called 'models.'

3. Set up the following environment variables using your preferred method, e.g. a [Procfile](https://devcenter.heroku.com/articles/procfile).

    * NODE_ENV - development or other (default = development)
    * MONGODB_URI - the URL of your MongoDB database (default = mongodb://localhost)

4. Create a model in the models directory. Note, the file name will be the name of your collection in the database and URI.

```
module.exports = {
  create: { // create, update, read, and delete are supported
    new: { // new and newWithID supported for create, one and many supported for read, update, and delete
      customAuth: {
        memberCollection: 'users',
        memberCollectionField: 'facebookID',
        memberField: 'toFacebookID'
      },
      defaultValues: {
        foo: 'bar'
      },
      mutableFields: [
        foo: 'bar'
      ],
      ownersField: 'memberUserIDs', // the name of a field that contains an array of secondary owner userIDs
      preware: function() { // called prior to executing the desired action
        // has access to zeenix methods including this.database, to exit call this.respond or this.next
      },
      postware: function(status, data) { // called after executing the desired action
        // has access to zeenix methods including this.database, to exit call this.respond 
      },
      requiredFields: [
        'foo'
      ],
      requiresAuthentication: false, // requires a valid authorization header, assumed if requiresAuthorization or setOwner is true, not supported by create
      requiresAuthorization: false, // requires a valid authorization header, not supported by create
      setOwner: true // requires a valid authorization header, only supported by create
    }
  }
};
```

5. Initialize Zeenix.

```
let Zeenix = require('zeenix').Zeenix;
new Zeenix();
```

## Filtering

You can filter the data returned by GET requests using the following query parameter structure:

`?[field]=[operator]:[value]`

Where operator is one of the following:

* eq - equals (default)
* ne - doesn't equal

## Notes

* Zeenix logs are only visible if your NODE_ENV is set to 'development.'
* Zeenix sets the ownerField on all documents created via a POST request.
* Zeenix uses the accessToken field in the authCollection for auth.
* Zeenix uses standard HTTP Status codes for all errors.
* Zeenix uses the '/me' alias in lieu of '/authCollection/:id' and any routes that require authorization.
* The query parameter 'action' is a reserved, all others are considered filters.

&copy;2017 Robby Marston. All Rights Reserved.

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