1.3.4 • Published 7 years ago

molti v1.3.4

Weekly downloads
2
License
MIT
Repository
github
Last release
7 years ago

NPM Version NPM Downloads Gemnasium

Coveralls branchTravis branch AppVeyor branch

Molti

A self documenting extensible framework powered by express and knex

More documentation coming!

Installation

$ npm install molti

Basic Usage

As a server

const { Parameter, Response, Application, Handler, Controller, Generics } = require('molti');

const sampleController = new Controller({
  basePath: '/'
});

sampleController.get(new Handler({
  path: '/some_path/:id',
  params: [Generics.params.id],
  responses: [Generics.responses.success],
  handler({ id }, { success }) {
    return success({ message: `Found ${id}` });
  }
}));

const sample = new Application({
  controllers: [sampleController]
});

sample.listen(3000);

As an ORM

const { Schema, ModelFactory, Registry } = require('molti');

const parentSchema = new Schema({
  name: {
    type: Schema.Types.String
  },
  children: {
    type: Schema.Types.Models
  }
});

class Parent extends ModelFactory(parentSchema) {
  feedChildren() {
    return this.children.map(child => child.eat());
  }
}

const childSchema = new Schema({
  name: {
    type: Schema.Types.String
  },
  parent: {
    type: Schema.Types.Model
  }
});

class Child extends ModelFactory(childSchema) {
  eat() {
    return `I, ${this.name}, ate ${this.parent.name}'s food`;
  }
}

const registry = new Registry({
  client: 'sqlite',
  connection: {
    filename: ':memory:'
  }
}, [
  Child,
  Parent
]);

Parent.findById(1, { withRelated: ['children'] })
  .then(parent => console.log(parent.feedChildren()));
1.3.4

7 years ago

1.3.3

7 years ago

1.3.2

7 years ago

1.3.1

7 years ago

1.3.0

7 years ago

1.2.6

7 years ago

1.2.5

7 years ago

1.2.4

7 years ago

1.2.3

7 years ago

1.2.2

7 years ago

1.2.1

7 years ago

1.2.0

7 years ago

1.1.6

7 years ago

1.1.5

7 years ago

1.1.4

7 years ago

1.1.3

7 years ago

1.1.2

7 years ago

1.1.1

7 years ago

1.1.0

7 years ago

1.0.14

7 years ago

1.0.13

7 years ago

1.0.12

7 years ago

1.0.11

7 years ago

1.0.10

7 years ago

1.0.9

7 years ago

1.0.8

7 years ago

1.0.7

7 years ago

1.0.6

7 years ago

1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago

0.0.11

7 years ago

0.0.10

7 years ago

0.0.9

7 years ago

0.0.8

7 years ago

0.0.7

7 years ago

0.0.6

7 years ago

0.0.5

7 years ago

0.0.4

7 years ago

0.0.3

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago

0.0.0

7 years ago