0.3.0 • Published 7 years ago

workjs-core v0.3.0

Weekly downloads
1
License
Apache 2.0
Repository
bitbucket
Last release
7 years ago

WorkJS Build Status NPM Version

WorkJS is a NodeJS Web Design Pattern (tiny framework!?). Use JS annotation (JS Doc) to design your backend service (API) and defined router as the same time. WorkJS includes basejs, express and socket.io project. You can build your controller use Object-Oriented Programming. Write document and defined router at same time. Maybe, you can build your http service quickly.

Getting Started

Install from GitHub

# get code
$ git clone https://github.com/samejack/WorkJS.git

# install depends package (npm install first)
$ cd WorkJS
$ npm install

# run example
$ npm start

Open your browser and go http://127.0.0.1:3000

Install from npm package repository

$ npm install workjs-core

Controller JavaScript Example (book.js)

var Base = require('basejs');

var BookController = Base.extend(
  {
    /**
     * Get all book list
     *
     * @Uri("/book")
     * @Method("GET")
     */
    getBookList: function(req, res, workJS) {
    },
    /**
     * Get book information by ISBN
     *
     * @Uri("/book/:isbn")
     * @Method("GET")
     */
    getBookInfo: function(req, res, workJS) {
    },
    /**
     * Create book
     *
     * @Uri("/book")
     * @Method("POST")
     */
    createBook: function(req, res, workJS) {
    },
    /**
     * Modify book
     *
     * @Uri("/book/:isbn")
     * @Method("PUT")
     */
    modifyBook: function(req, res, workJS) {
    },
    /**
     * Delete book
     *
     * @Uri("/book/:isbn")
     * @Method("DELETE")
     */
    deleteBook: function(req, res, workJS) {
    }
  }
);

module.exports = BookController;

Create first WorkJS App

Create a bootstrap JavaScript file (app.js) as follows:

var WorkCore = require('workjs-core');

var workCore = new WorkCore({
  // your controller's path
  controllerPath: [__dirname + '/controller']
}).start();

Run it

# run by nodejs
$ sudo node app.js

WorkJS default is bind on localhost:80 port. Open your browser and go http://127.0.0.1

Configrations (Example)

ParameterDefaultNote
port3000Server port
hostlocalhostServer host
controllerPath./controller directoryController JS file path
corstrueEnable CORS Header for corss domain web server
staticPath./public directoryHTTP document root

Future Work

  • Integrate APIDoc to defined router.

License

Apache License 2.0

0.3.0

7 years ago

0.2.3

7 years ago

0.2.2

7 years ago

0.2.0

7 years ago

0.1.1

8 years ago

0.1.0

8 years ago