Skip to content

TMJPEngineering/beline-server

Repository files navigation

bes.js

A friendly MVC Framework for Node.js

Build Status CircleCI

This framework uses ECMAScript 6 (ES6). See the ES6 standard for full specification of the ECMAScript 6 language.

Getting Started

To install the framework, run this command and you're good to go.

npm run setup

Features

  • Modular Structure
  • Passport
  • ES6 (ECMAScript 6)
  • Ready-made commands
    • npm test (For Testing)
    • npm start (Run framework using Babel)
    • npm run reload (Watch all the files)
    • npm run setup (Install framework)
    • npm run dev (Run webpack in development mode)
    • npm run prod (Run webpack in production mode)
    • npm run watch (Watch all files)
  • Bootstrap 4 (Beta)
  • MVC Architecture
  • TDD (Using karma and jasmine)
  • CI (Using CircleCI or Travis)
  • Helpers (e.g. env, logger, etc.)
  • Database Seeder
  • Socket.io

Usage

Route Methods

GET Method

Route.get('<uri>', '<controller>@<method>|<closure>', [<middlewares>]);

POST Method

Route.post('<uri>', '<controller>@<method>|<closure>', [<middlewares>]);

UPDATE Method

Route.update('<uri>', '<controller>@<method>|<closure>', [<middlewares>]);

DELETE Method

Route.delete('<uri>', '<controller>@<method>|<closure>', [<middlewares>]);

RESOURCE Method

Route.resource('<uri>', '<controller>', [<middlewares>], {only|except});

VIEW Method

It loads a html file.

Route.view('<uri>', '<file>', [<middlewares>]);

ALL Method

This method is used for loading middleware functions at a path for all request methods.

Route.all('<uri>', '<closure>');

In resource method, it provides get, post, update, and delete method. These are the following methods in controller that uses resource method:

  • index for GET Method
  • create for GET Method
  • store for POST Method
  • show for GET Method
  • edit for GET Method
  • update for UPDATE Method
  • destroy for DELETE Method

You can also limit by using only or except. See example below:

Example #1

export default () => {
    namespace('Blog'); // or
    namespace(config.modules.blog); // It must have a value inside modules (located in /config/modules.js)
    ...
    Route.resource('/user', 'UserController', ['client'], {
        only: ['index', 'show']
    });
    ...
};

Example #2

export default () => {
    namespace('Blog'); // or
    namespace(config.modules.blog); // It must have a value inside modules (located in /config/modules.js)
    ...
    Route.resource('/api/blog', 'UserController', ['oauth'], {
        except: ['create', 'edit']
    });
    ...
};

Example #3

export default () => {
    namespace('Home'); // or
    namespace(config.modules.home); // It must have a value inside modules (located in /config/modules.js)
    ...
    Route.view('/home', 'pages.home');
    // It says that route will load the html file in /resources/views/pages/home.html
    ...
};

Note: Every routes file must have a namespace inside the function. Always put it in the first line.

Route Groups

Route.group({ prefix: 'lorem', middleware: ['foo', 'bar'] }, () => {
   ...
   // Insert route methods here
   ...
});

TODO

  • Nested Route Groups
  • bes command line interface (cli)

Credits

License

This project is licensed under the MIT License - see the LICENSE file for details

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published