Skip to content

Customization Guide

Fred Chien edited this page Sep 30, 2015 · 7 revisions

Actually, Lantern was created for secondary development, developer can do customization work for own web service which is based on this project.

Configurations

See Configurations for details.

Database (Models)

You can modify the database schema to fit for purpose what you want. All of the schema files are stored in the ./models directory which contains member, permissions and role by default.

Models are defined by using Mongoose style object, it looks like below:

var mongoose require('mongoose');
var Schema = mongoose.Schema;

var Foo = new mongoose.Schema({
	name: String,
	count: Number,
	disabled: { type: Boolean, default: false },
	updated: { type: Date, default: Date.now }
});

module.exports = mongoose.model('Foo', Foo);

Routes

You must make it divided into two groups of routes, Restful APIs and Pages.

Restful APIs

We usually put all of restful APIs in the ./routes folder.

Pages

For isomorphic application, React is doing the page rendering work on client-side and server-side with own route settings. The routes relates to page is set in ./src/js/routes.js

Library

./lib stores all common functions you might use during development.

Rendering

All of pages need to be rendered on server and client both are put in the ./src directory. It includes less, Images, JavaScript and Translations.

The folder structure:

  • js (React Components and FLUX things)
  • images
  • less (CSS)
  • translations

React and FLUX

Front-end things are mainly React components and FLUX in the ./src/js directory, so you can see the folder structure like below:

  • components
  • actions
  • stores
  • extensions

Fluky

Lantern is using Fluky as FLUX framework. No matter what you like or not, Fluky is suitable with isomorphic application. The event-based design is making us be able to record behaviors and state which is triggered by React components.

With singleton, we can attach rich functions and methods to Fluky instance, I18n and API requests can be implemented easily.

Clone this wiki locally