Skip to content
This repository has been archived by the owner on Nov 27, 2018. It is now read-only.

Build your Classic App tutorial

Frank Rousseau edited this page Jan 8, 2015 · 12 revisions

Build your Cozy App

Simple app

Building your own app for Cozy Light is almost like building a Node.js app based on Express. It just requires one function in your main file. That functions receive port and host on which to listen in paremeters. It should notify that server is started by sending back the app and server variables to the call function.

var express = require('express');

module.exports.start = function (options, callback) {
  var port = options.port || process.env.PORT || 9104;
  var host = options.host || process.env.HOST || '127.0.0.1';

  var app = express();
  app.get('/', function (req, res) { res.send('Hello world!'); });
  var server = app.listen(port, host, function () {
      callback(null, app, server);
  });
}

This is how should look your main file. As you understand, once you're done with the start function, you're done with the Express app writing.

Simple app with shared persistence

What is cool with Cozy Light, is that every apps share the same database. That way, they can communicate each other. To database is given trough the options. It's a PouchDB database.

Clone this wiki locally