All Projects → ptariche → koa-waterline

ptariche / koa-waterline

Licence: MIT License
Deprecated: A middleware for your hose

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to koa-waterline

Grant
OAuth Proxy
Stars: ✭ 3,509 (+24964.29%)
Mutual labels:  middleware, koa
Koa Useragent
Koa user-agent middleware
Stars: ✭ 54 (+285.71%)
Mutual labels:  middleware, koa
Concurrency Logger
Log HTTP requests/responses separately, visualize their concurrency and report logs/errors in context of a request.
Stars: ✭ 400 (+2757.14%)
Mutual labels:  middleware, koa
stats
📊 Request statistics middleware that stores response times, status code counts, etc
Stars: ✭ 15 (+7.14%)
Mutual labels:  middleware, koa
Tsed
📐 Ts.ED is a Node.js and TypeScript framework on top of Express to write your application with TypeScript (or ES6). It provides a lot of decorators and guideline to make your code more readable and less error-prone.
Stars: ✭ 1,941 (+13764.29%)
Mutual labels:  middleware, koa
Koa Helmet
Important security headers for koa
Stars: ✭ 595 (+4150%)
Mutual labels:  middleware, koa
Kona
a node.js service framework built on koa.js (generators)
Stars: ✭ 23 (+64.29%)
Mutual labels:  middleware, koa
Koatty
Koa2 + Typescript = Koatty. Use Typescript's decorator implement IOC and AOP.
Stars: ✭ 67 (+378.57%)
Mutual labels:  middleware, koa
Awilix Koa
Awilix helpers/middleware for Koa 2
Stars: ✭ 121 (+764.29%)
Mutual labels:  middleware, koa
Service Tools
Prepare your Node.js application for production
Stars: ✭ 89 (+535.71%)
Mutual labels:  middleware, koa
polix
🚀 Node.js Web Framework
Stars: ✭ 32 (+128.57%)
Mutual labels:  middleware, koa
Koa Hbs
Handlebars templates for Koa.js
Stars: ✭ 156 (+1014.29%)
Mutual labels:  middleware, koa
doa
A middleware framework for Deno's http serve🦕. Transplanted from Koa with ❤️
Stars: ✭ 20 (+42.86%)
Mutual labels:  middleware, koa
dog
Full repository for the Dog gateway
Stars: ✭ 21 (+50%)
Mutual labels:  middleware
fireo-nodejs
Google Cloud Firestore modern and simplest convenient ORM package in NodeJs. FireO is specifically designed for the Google's Firestore
Stars: ✭ 22 (+57.14%)
Mutual labels:  orm
yorm
Automatic object-YAML mapping for Python.
Stars: ✭ 23 (+64.29%)
Mutual labels:  orm
Guardian
Service Side Swift:Vapor 3 based API Guardian Middleware. 🦁
Stars: ✭ 90 (+542.86%)
Mutual labels:  middleware
typeorm-query-builder-wrapper
Easy Wrapper for TypeORM Query Builder
Stars: ✭ 20 (+42.86%)
Mutual labels:  orm
phpdebugbar
PSR-15 middleware for PHP Debug bar
Stars: ✭ 64 (+357.14%)
Mutual labels:  middleware
express-view-cache
Unobtrusive solution to express framework - cache rendered page, without database requests and rendering.
Stars: ✭ 20 (+42.86%)
Mutual labels:  middleware

koa-waterline

Middleware for your hose

Build Status

NPM

npm install koa-waterline

Usage

//see example.js
  function* (){
    let ctx            = this;
    let message        = 'This is an example';
    let commentCreated = yield ctx._waterline.collections.comments.create({message: message});
    // You can yield to the CRUD waterline functions because they are written as promises.
    console.log(commentCreated);
  }
// OR
  function* () {
    let waterline      = yield Waterline.init(injection);
    let message        = 'This is an example';
    let commentCreated = yield waterline.collections.comments.create({message: message});
  }
  • The model attributes of connection and adp must match the connection and adapter naming conventions when setting up your environment to inject into the middleware.

Example

  let connections = {
    couch: {
      adapter: "couch",
      host: '127.0.0.1',
      port: '5984',
      username: '',
      password: ''
    },
    mongo: {
      adapter: "mongo",
      host: 'localhost',
      port: '27017',
      user: '',
      password: '',
      database: 'waterline'
    },
    cassandra: {
      adapter: "cassandra",
      host: '',
      password: '',
      contactPoints: ['127.0.0.1'],
      keyspace: 'dev'
    }
  };

  let adapters = {
    couch:     require('sails-couchdb-orm'),
    mongo:     require('sails-mongo'),
    cassandra: require('sails-cassandra')
  };

  let models = {
      "comments": {
        "model": true,
        "adp": "couch",
        "connection": "couch",
        "properties": {
          "archived": {
              "type": "boolean",
              "defaultValue": false
          },
          "message": {
              "type": "string"
          }
        }
      },
      "history": {
        "model" : true,
        "adp": "mongo",
        "connection": "mongo",
        "properties": {
          "year": {
            "type": "string"
          }
        }
      },
      "tweet": {
        "adp": "cassandra",
        "connection": "cassandra",
        "index": ['tweet_body'],
        "properties": {
          "tweet_body": {
            "type": "string"
          }
        }
      },
      "error": {
        "model": false,
        "properties": {
          "erro": {
            "type": "string"
          }
        }
      }
    };

  let injection               = {};
  injection.methods           = false;
  injection.models            = models;
  injection.adapters          = adapters;
  injection.connections       = connections;

  app.use(waterline(injection));

##Attributes Models - Required

- Models must have an adp, connection, and the properties attributes with the same design pattern in the example above. There is an optional model flag that can be added inside the model that should be set to true or false; this allows you to not instiatiate specific models in waterline.

Adapters - Required

- The adapters refer to the connection adapters; this is required and while seeming redundant it is required to run waterline

Connections - Required

- The connection attributes are the setting parameters for the data models to create the waterline.

Methods - Optional

 - The methods attribute allows the injection of functions for virtual methods inside the model. An example of such an injection would something like this:

Methods Example:

 let methods = {
     history: function(){
     //virtual methods specific to the history model
     },
     comments: function(){
     //virtual methods specific to the comments model
     }
};

Notes

- Sails Cassandra fails the next time it's initialized because it attempts to over-ride; restart the service again until the actual sails-cassandra has been fixed

Debug

- DEBUG=koa-waterline node --harmony example.js

Authors

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].