A friendly MVC Framework for Node.js
This framework uses ECMAScript 6 (ES6). See the ES6 standard for full specification of the ECMAScript 6 language.
To install the framework, run this command and you're good to go.
npm run setup
- 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
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 Methodcreate
for GET Methodstore
for POST Methodshow
for GET Methodedit
for GET Methodupdate
for UPDATE Methoddestroy
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.group({ prefix: 'lorem', middleware: ['foo', 'bar'] }, () => {
...
// Insert route methods here
...
});
- Nested Route Groups
bes
command line interface (cli)
This project is licensed under the MIT License - see the LICENSE file for details