-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit.moon
56 lines (42 loc) · 1.07 KB
/
init.moon
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
55
config = require"lapis.config".get!
import render_html from require "lapis.html"
import insert, concat from table
-- This is totally a hack on how Moonscript and lapis.Application handles @include(other_app)
empty_routes =
path: ""
name: ""
__base: {}
empty_render = (...) ->
return ""
empty_capture = (...) ->
return
if config._name == "development"
{
_VERSION: "alpha"
routes: if config.luminary and config.luminary.enable_console == false
empty_routes
else
require "luminary.apps.main"
capture_queries: =>
@_luminary = {
queries: {}
}
db = require "lapis.db"
old_logger = db.get_logger!
db.set_logger {
query: (q) ->
insert @_luminary.queries, q
old_logger.query q if old_logger
}
render_toolbar: (lapis_env) ->
w = require "luminary.views.toolbar"
w\include_helper lapis_env
render_html ->
raw w\render_to_string!
}
else
{
routes: empty_routes
capture_queries: empty_capture
render_toolbar: empty_render
}