Compatible with Blockbase Framework
You should use blockbase v1.0.12 as a minimum version.
0.0.1
$ npm i --save blockbase-claudia
Then add to your config/{env}.yml
the following (example) instructions depending of your system
claudia :
routes :
# Classic view with no Controller
- type: view
src: /
dest: index
method: get
extra:
apiKeyRequired: true
# Controller Related route
- type: controller
src: /api/foo
dest: foo::bar
method: get
The entire usage of the driver is done by the config/{env}.yml
, we've tried to make it as simple as it need.
It refers to the Claudia JS API Builder to push lambda function directly in the cloud from your project.
We've added in blockbase the possibility to remove the init callback so you can export directly the app (requirement from AWS Lambda).
You src/app.js
would look like that
const blockbase = require('blockbase')
const app = blockbase({root: __dirname})
let api = app.drivers.claudia.api;
module.exports = api
A route can have two type : controller
or view
.
As it looks like a controller will be a program call (in a app.controller.*
controller) and a view will call a view in the folder /views
.
The following routes are programmed as described below :
- controller
ex : creates a route on
localhost:1340/foo/bar
that will trigger theapp.controllers.foo.bar()
method on the GET method
- type: controller
src: /foo/bar
dest: /controllers/foo::bar
method: get
- view
ex : creates a route on
localhost:1340/
that will show the/views/home.twig
template on the GET method
- type: view
src: /
dest: home
method: get
You can populate the route.extra
value with a json (yml formatted) object, corresponding to the last parameter of the api(path, method, extra)
method.
For example
claudia :
routes :
- type: controller
src: /echo
dest: index
method: get
extra:
apiKeyRequired: true
is equivalent to
api.get('/echo', function (request) { ... }, { apiKeyRequired: true });
You can easily deploy to Lambda your blockbase project using claudia create
and claudia update
commands (in package.json scripts for ex).
Example claudia create --use-local-dependencies --region eu-west-1 --api-module src/app
For advanced usage, please refer to the official Claudia documentation.
If you find any issue, feel free to post it in the repo on Github
(Licence MIT) Coded by Blacksmith
Free Software, Hell Yeah!