superjs-starter

0.1.0 • Public • Published

SuperJS Starter App

A simple starting point for a SuperJS application. Everything in SuperJS is class-based and extendable with the _extend method. See the SuperJS documentation for more information: http://github.com/asleepinglion/superjs

Installing the Application:

  • Clone the Starter Repository
  • Run npm intall to install required modules
  • Update the config/data.js settings to point to a real database
  • Create a real module in the modules folder which reflects an actual table
  • Run node app.js

Testing The API:

By default security is disabled and all REST routes are publicly available. Content-type application/json is required on POST, PUT, and DELETE requests. All REST routes have RPC routes that match, for example a GET on a table is also available at http://127.0.0.1:8888/yourtable/search and a POST is also available at http://127.0.0.1:8888/yourtable/create.

  • GET http://127.0.0.1:8888 to check if the server is up.
  • GET http://127.0.0.1:8888/describe to describe available controllers and methods.
  • GET http://127.0.0.1:8888/yourtable to get the contents of yourtable
  • POST http://127.0.0.1:8888/yourtable to create a new yourtable record.
  • PUT http://127.0.0.1:8888/yourtable to update a yourtable` record

Basic Structure

app.js

The application starting point contains the instantiation of the SuperJS.Application class. The class could be extended to override functionality, such as the middleware loaded. You can also hook into events such as the started event.

config

There are three configuration files, data, security, and server settings. Please check those files for more detailed descriptions.

modules

You can either create modules inside the module folder by naming a folder after the module, such as user and then inside that folder have a controller.js and a model.js OR you can have controllers and models folders which contain files like user.js. Larger applications will probably prefer the modules method, but this is user preference.

models

Models define the available models for the API. The configuration of models is dependent on the engine used. See the data.js configuration file for more information.

controllers

Controllers are entirely extendable and routes are automatically created. Any method beginning with an underscore is essentially private and unroutable and any regularl method will have a route created for it. Methods that are web accessible will receive two params, the req object provided by express, and a callback which needs to be called at the end of your method otherwise the process will be blocked. Controllers are entirely extendable, so you can create base classes and abstract common functionality. There is a base Controller class available in the SuperJS package or you can use the Rest Enabled controller classes provided by the database engine. You can also hook into events such as the beforeAction and afterAction events.

Readme

Keywords

none

Package Sidebar

Install

npm i superjs-starter

Weekly Downloads

0

Version

0.1.0

License

MIT

Last publish

Collaborators

  • asleepinglion