node package manager

sweets

Flexible declarative web framework for real-time projects

Sweets

Flexible declarative web framework for real-time projects

  • Focused on realtime RPC and events
  • Declarative api
  • No ORM
  • Modular
  • Fast and lightweight (startup time ~500ms)
  • JSON all the time

The best way to try Sweets is to clone sample app and follow the instruction from there.

All Sweets modules are also available through npm.

bin/sweets [options] command

--env=<envname> — overide environment settings.

start, stop, restart

worker — starts one instance of the app

console — starts the console with the loaded app

Based on matter-in-motion lib

For more info look into units documentation

Contracts are for routing. They are fully compatible with expressjs.

For example, look into sample app. More documentation will be available soon.

Database is optional for the Sweets app. You can create an app completely without database. But if you need database, you just define the Sweets database module in settings and your database will be available as a db unit. For example, nougat adds support for nosql rethinkdb.

You can define environment as:

  • MM_ENV environment variable
  • --env=<name> cli option

if the Sweets App finds any environment defined, it will try to load a environment.js file from the settings directory. For example, --env=dev loads dev.js:

"use strict";
module.exports = function (settings) {
    settings.core.debug = true;
    settings.core.web.listen.address = "0.0.0.0";
};

A sweet is an abstraction for one task. Here is the list of ready-to-use sweets

Resource docs

Services is a command line interface. You can run services as bin/sweets service command argument

  • create — creates db with a name from the settings
  • drop — drops db
  • updateScheme [resource] — updates the scheme for all resources or just one.
  • dropScheme [resource] — drops the scheme for all resources or just one.
  • rebuildIndexes [resource] — rebuilds indexes for all resources or just one.
  • create <resource> — creates a new resource in the lib/resources folder
  • loadContent [jsonfilename] — loads the content from all json files in the data folder except files begin with '_' underscore, or from a file.
  • create <id> <password> — creates a user with id and password. For default sweets auth provider id is an email.
  • create <name> — creates custom service. For details see Custom services.

To create a new service use the service create <name> service command. It makes services/name.js file. This is a simple class and every method can be run as bin/sweets servicename methodname arg1 arg2 .... All methods get a callback as the last argument. Run this callback when the service is finished. To make a service available for cli add it in the loader of your app:

let Loader = function (options) {
    SweetsLoader.call(this, options);
    this.addServices([
      'nougat.db',
      'lollipop.user'
    ]);
};

MIT License