Project
boxlang-express-mvc
ColdBox-style handlers, routes, views and layouts for boxlang-express. It is familiar, not compatible: a ColdBox developer will recognise function index( event, rc, prc ), the route().to() DSL and views/ + layouts/, but existing ColdBox apps and modules don't run on it. Everything compiles to plain BoxExpress routes when the app starts.
Handlers you know
Actions take event, rc and prc, with setView(), renderData(), relocate(), buildLink(), flash, and preHandler, postHandler and aroundHandler hooks.
A routes file
route().to(), get()/post() shortcuts, group(), named routes, resources() with _method for forms, and an opt-in /:handler/:action? convention route. A route to a missing handler or action fails at startup.
Views and layouts
Implicit views/{handler}/{action}.bxm inside layouts/Main.bxm, with #view()# for the body and for partials. Edits to .bxm files show up without a restart.
Services, your way
Fill handler properties from a plain struct, or pass a WireBox injector and use inject=. Handlers and interceptors are wired once, at startup.
renderData() and relocate() send immediately, and there are no built-in interception points or HMVC modules. Read what carries over and what doesn't.bashinstall-bx-module boxlang-express boxlang-express-mvc bx-esapi --local
javascript// server.bxs
app = boxExpress()
app.use( boxExpressUrlencoded() )
mvc = boxExpressMvc( {
handlers: expandPath( "./handlers" ),
views : expandPath( "./views" ),
layouts : expandPath( "./layouts" ),
routes : expandPath( "./config/Router.bx" )
} )
app.use( mvc.router() )
app.listen( 3000 )
// config/Router.bx
class {
function configure() {
route( "/", "items.index" )
route( "/items/:id(\d+)" ).as( "itemDetail" ).to( "items.show" )
}
}
// handlers/items.bx
class {
function index( event, rc, prc ) {
prc.items = [ { id: 1, name: "Anvil" } ]
// renders views/items/index.bxm inside layouts/Main.bxm
}
}