deepjs/server oriented tools and middlewares for expressjs.
Autobahnjs comes with two kind of tools :
As autobahnjs is an environnement that tie a bunch of tools together and should be piloted from your own index.js : You should use the yeoman autobahnjs generator to get a workable structure.
coming really soon.
Or simply use the example folder, provided in autobahn lib under autobahnjs/lib. when you're in (after clone or npm install) :
npm installnode index.js
var deep =express =autobahn = // bunch of middlware for expressjsUnit = ; // for deepjs unit testingvar cookieParser = ;var session = ;var bodyParser = ;// bind actual JSON-Schema validator. taking one from deepjs core.deepValidator;// set root path and cwd (used in certain protocol/stores/chains)deepglobalsrootPath = __dirname;deep;// assign default modes.deep;//_________________________ Start your app constructionvar app = ;// simple app examplevar autobahnApp = autobahn;app// set simple session management (pure expressjs)// to get posted body parsed automatically (json/files/..)// ------ context and modes// create and bind unique context to each incoming request// assign OCM modes to each incoming req. context// ------ login and logout// catch post on /logout and break session.// catch post on /login and try to login// ------ Your maps-to-* middleware// deep-restful map-to-services// deep-views/deep-routes map-to-html rendering.// map-to-statics file server///____________________________________________________ Finish app construction;// bind global app. Allow us to apply login/logout/impersonate (and more) from chained API.deep;console;var repl =startprompt: "node via stdin> "input: processstdinoutput: processstdout;
For full info on how managing/designing restful stores, see deep-restful and deepjs core documentation.
var deep = ;;moduleexports ="/user": deep"/foo":deep;
For full info on how managing/designing html routes map, see deep-views and deep-routes documentation.
var deep = ;;// create json client that look from /www. use it under "json" protocol.protocol: "json"basePath: "/www";// create swigjs client that look from /www. use it under "swig" protocol.protocol: "swig"basePath: "/www";// map for html pages produced by server. the map itself, or the entries of the map, could be OCM.// example of map :moduleexports =head:deepindex:deep;
var deep = ;// map for static files served by server (the map itself could be OCM)moduleexports ="/": // serve rootpath: deepglobalsrootPath + '/www'options: // native expressjs connect-statics optionsmaxAge: 86400000redirect: false;
Outside means from you prefered http client (maybe your browser) to the server. If you use previous map in your autobahnjs/express skeleton (as above) :
Open your browser and try by example :
And with your prefered restful client, you should try to post/put/patch/del/get/range/... to /foo service.
Inside means from nodejs CLI or from any script executed server side.
deep;//...deep // endoss localy user identity (context, session, modes, ...)// take "myCollection" restful collection// put something in it as john doe.// break current chain session// endoss localy other user identity// ...;
deepjs core provides additionnaly the
.modes(...) API that allow you, by example, to do :
deep; // you should see an array with users.
Imagine that you produce different expressjs skeleton/autobhan js app in the same nodejs process.
You should want to switch from one to another and/or execute each in its own context. For that you have two method that encapsulate the provided app in chain context.