Flexible declarative web framework for real-time projects


Flexible declarative web framework for real-time projects

  • Focused on RESTful api
  • Auto api routing generation
  • No ORM
  • Modular
  • Fast and lightweight (startup time ~300ms)
  • 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.

###Comands bin/sweets [options] command

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

####Commands to control the Sweets app in the deamon mode: start, stop, restart

####Commands useful for developing: worker — starts one instance of the app

console — starts the console with the loaded app

Based on apis lib

For more info look into units documentation

Contracts are for routing. But unlike the other frameworks contracts and routes they validate the incoming data. They also can validate outcoming data. All resources contracts are generated once at the app start.

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:

  • APIS_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 = "";

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:

var Loader = function (options) {
    SweetsLoader.call(this, options, ["your_service_name", "another_custom_service"]);

MIT License