new Controller(name)
Controller class
Name | Type | Description |
---|---|---|
name | string | Name of the Controller |
- Since
- 1.0.0
- Copyright
- MIT
- Source
const {Controller} = require('@neobeach/core');
const controller = new Controller('IndexController');
controller.get('/', [], (req, res) => {
res.json(1000, {
hello: 'world!'
});
});
Members
name :string
Controller name used for internal logs
- string
- Since
- 1.0.0
- Copyright
- MIT
- Source
router :Router
Express router instance used by the Express server
- Since
- 1.0.0
- Copyright
- MIT
- Source
routes :array.<object>
Array of routes which to implement within Express
- array.<object>
- Since
- 1.0.0
- Copyright
- MIT
- Source
Methods
copy(path, middlewares, handler)
Add a COPY route to the Controller
Name | Type | Description |
---|---|---|
path | string | A path to bind the handler function to |
middlewares | array.<function(*, *, *)> | An array of Middlewares |
handler | function | A handler function that handles the incoming HTTP request |
- Since
- 1.0.0
- Copyright
- MIT
- Source
const {Controller} = require('@neobeach/core');
const controller = new Controller('IndexController');
controller.copy('/', [], (req, res) => {
// Custom handler code here
});
delete(path, middlewares, handler)
Add a DELETE route to the Controller
Name | Type | Description |
---|---|---|
path | string | A path to bind the handler function to |
middlewares | array.<function(*, *, *)> | An array of Middlewares |
handler | function | A handler function that handles the incoming HTTP request |
- Since
- 1.0.0
- Copyright
- MIT
- Source
const {Controller} = require('@neobeach/core');
const controller = new Controller('IndexController');
controller.delete('/', [], (req, res) => {
// Custom handler code here
});
get(path, middlewares, handler)
Add a GET route to the Controller
Name | Type | Description |
---|---|---|
path | string | A path to bind the handler function to |
middlewares | array.<function(*, *, *)> | An array of Middlewares |
handler | function | A handler function that handles the incoming HTTP request |
- Since
- 1.0.0
- Copyright
- MIT
- Source
const {Controller} = require('@neobeach/core');
const controller = new Controller('IndexController');
controller.get('/', [], (req, res) => {
// Custom handler code here
});
head(path, middlewares, handler)
Add a HEAD route to the Controller
Name | Type | Description |
---|---|---|
path | string | A path to bind the handler function to |
middlewares | array.<function(*, *, *)> | An array of Middlewares |
handler | function | A handler function that handles the incoming HTTP request |
- Since
- 1.0.0
- Copyright
- MIT
- Source
const {Controller} = require('@neobeach/core');
const controller = new Controller('IndexController');
controller.head('/', [], (req, res) => {
// Custom handler code here
});
lock(path, middlewares, handler)
Add a LOCK route to the Controller
Name | Type | Description |
---|---|---|
path | string | A path to bind the handler function to |
middlewares | array.<function(*, *, *)> | An array of Middlewares |
handler | function | A handler function that handles the incoming HTTP request |
- Since
- 1.0.0
- Copyright
- MIT
- Source
const {Controller} = require('@neobeach/core');
const controller = new Controller('IndexController');
controller.lock('/', [], (req, res) => {
// Custom handler code here
});
options(path, middlewares, handler)
Add a OPTIONS route to the Controller
Name | Type | Description |
---|---|---|
path | string | A path to bind the handler function to |
middlewares | array.<function(*, *, *)> | An array of Middlewares |
handler | function | A handler function that handles the incoming HTTP request |
- Since
- 1.0.0
- Copyright
- MIT
- Source
const {Controller} = require('@neobeach/core');
const controller = new Controller('IndexController');
controller.options('/', [], (req, res) => {
// Custom handler code here
});
patch(path, middlewares, handler)
Add a PATCH route to the Controller
Name | Type | Description |
---|---|---|
path | string | A path to bind the handler function to |
middlewares | array.<function(*, *, *)> | An array of Middlewares |
handler | function | A handler function that handles the incoming HTTP request |
- Since
- 1.0.0
- Copyright
- MIT
- Source
const {Controller} = require('@neobeach/core');
const controller = new Controller('IndexController');
controller.patch('/', [], (req, res) => {
// Custom handler code here
});
post(path, middlewares, handler)
Add a POST route to the Controller
Name | Type | Description |
---|---|---|
path | string | A path to bind the handler function to |
middlewares | array.<function(*, *, *)> | An array of Middlewares |
handler | function | A handler function that handles the incoming HTTP request |
- Since
- 1.0.0
- Copyright
- MIT
- Source
const {Controller} = require('@neobeach/core');
const controller = new Controller('IndexController');
controller.post('/', [], (req, res) => {
// Custom handler code here
});
purge(path, middlewares, handler)
Add a PURGE route to the Controller
Name | Type | Description |
---|---|---|
path | string | A path to bind the handler function to |
middlewares | array.<function(*, *, *)> | An array of Middlewares |
handler | function | A handler function that handles the incoming HTTP request |
- Since
- 1.0.0
- Copyright
- MIT
- Source
const {Controller} = require('@neobeach/core');
const controller = new Controller('IndexController');
controller.purge('/', [], (req, res) => {
// Custom handler code here
});
put(path, middlewares, handler)
Add a PUT route to the Controller
Name | Type | Description |
---|---|---|
path | string | A path to bind the handler function to |
middlewares | array.<function(*, *, *)> | An array of Middlewares |
handler | function | A handler function that handles the incoming HTTP request |
- Since
- 1.0.0
- Copyright
- MIT
- Source
const {Controller} = require('@neobeach/core');
const controller = new Controller('IndexController');
controller.put('/', [], (req, res) => {
// Custom handler code here
});
unlock(path, middlewares, handler)
Add a UNLOCK route to the Controller
Name | Type | Description |
---|---|---|
path | string | A path to bind the handler function to |
middlewares | array.<function(*, *, *)> | An array of Middlewares |
handler | function | A handler function that handles the incoming HTTP request |
- Since
- 1.0.0
- Copyright
- MIT
- Source
const {Controller} = require('@neobeach/core');
const controller = new Controller('IndexController');
controller.unlock('/', [], (req, res) => {
// Custom handler code here
});