forked from persvr/persevere-example-wiki
-
Notifications
You must be signed in to change notification settings - Fork 0
/
jackconfig.js
54 lines (49 loc) · 1.92 KB
/
jackconfig.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/**
* The starting point for Pintura running as a Jack app.
*/
var pinturaApp;
require("nodules").useLocal().ensure(["pintura/pintura", "app", "tunguska/jack-connector", "narwhal/narwhal/repl"], function(require){
require.reloadable(function(){
pinturaApp = require("pintura/pintura").app;
require("app");
});
require("tunguska/jack-connector").observe("worker", pinturaApp.addConnection);
// we start the REPL (the interactive JS console) because it is really helpful
if(require("jack/handler/simple-worker").options.firstWorker){
require("narwhal/narwhal/repl").repl(true);
}
});
var File = require("file"),
Transporter = require("jsgi/transporter").Transporter;
var perseverePath,
Static = require("jack/static").Static,
Directory = require("jack/dir").Directory;
var path = require.paths[0].match(/(.*?)[\/\\]packages[\/\\]/);
if(path){
perseverePath = path[1] + "/packages/persevere/public";
}
// now setup the development environment, handle static files before reloading the app
// for better performance
exports.app = exports.development = function(app, options){
// make the root url redirect to /Page/Root
return require("./lib/jsgi/redirect-root").RedirectRoot(
require("jack/cascade").Cascade([
// cascade from static to pintura REST handling
/* // this will provide module wrapping for the Dojo modules for the client
transporter.Transporter({
urlPrefix:"/js/",
paths:["../../persevere/public/js/"],
converter: transporter.Dojo
}),*/
// the main place for static files accessible from the web
Directory("public", Static(null, {urls:[""], root: "public"})),
Static(null, {urls:["/explorer"], root: perseverePath + "/explorer"}),
// this will provide access to the server side JS libraries from the client
Transporter({loader: require("nodules").forEngine("browser").useLocal().getModuleSource}),
// main Pintura handler
function(request){
return pinturaApp(request);
}
])
);
};