-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.lua
More file actions
62 lines (62 loc) · 1.4 KB
/
init.lua
File metadata and controls
62 lines (62 loc) · 1.4 KB
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
56
57
58
59
60
61
62
local config = require("lapis.config").get()
local render_html
do
local _obj_0 = require("lapis.html")
render_html = _obj_0.render_html
end
local insert, concat
do
local _obj_0 = table
insert, concat = _obj_0.insert, _obj_0.concat
end
local empty_routes = {
path = "",
name = "",
__base = { }
}
local empty_render
empty_render = function(...)
return ""
end
local empty_capture
empty_capture = function(...) end
if config._name == "development" then
return {
_VERSION = "alpha",
routes = (function()
if config.luminary and config.luminary.enable_console == false then
return empty_routes
else
return require("luminary.apps.main")
end
end)(),
capture_queries = function(self)
self._luminary = {
queries = { }
}
local db = require("lapis.db")
local old_logger = db.get_logger()
return db.set_logger({
query = function(q)
insert(self._luminary.queries, q)
if old_logger then
return old_logger.query(q)
end
end
})
end,
render_toolbar = function(lapis_env)
local w = require("luminary.views.toolbar")
w:include_helper(lapis_env)
return render_html(function()
return raw(w:render_to_string())
end)
end
}
else
return {
routes = empty_routes,
capture_queries = empty_capture,
render_toolbar = empty_render
}
end