@@ -15,8 +15,8 @@ I18n = I18nClass.new("en")
1515ProgramMaxPayloadSize (10485760 ) -- 10 MB
1616
1717-- DB connection
18- local db_config = DecodeJson (LoadAsset (" config/database.json" ))
19- InitDB (db_config )
18+ -- local db_config = DecodeJson(LoadAsset("config/database.json"))
19+ -- InitDB(db_config)
2020
2121Views = {}
2222isApi = false
@@ -27,71 +27,70 @@ isApi = false
2727LastModifiedAt = {}
2828
2929function OnServerStart ()
30- LoadPublicAssetsRecursively (" public" )
31- if BeansEnv == " production" then
32- LoadViewsRecursively (" app/views" )
33- end
30+ LoadPublicAssetsRecursively (" public" )
31+ if BeansEnv == " production" then
32+ LoadViewsRecursively (" app/views" )
33+ end
3434end
3535
3636function OnServerReload ()
3737end
3838
3939function OnServerHeartbeat ()
40- LoadCronsJobs ()
40+ LoadCronsJobs ()
4141end
4242
4343function OnWorkerStart ()
44- -- Uncomment code if you use SQLite
45- -- HandleSqliteFork(db_config) -- you can remove it if you do not use SQLite
44+ -- Uncomment code if you use SQLite
45+ -- HandleSqliteFork(db_config) -- you can remove it if you do not use SQLite
4646end
4747
4848-- OnError hook
4949function OnError (status , message , details )
50- -- Define the error for an API
51- -- WriteJSON({ status = status, message = message })
52-
53- -- Define the error page via a page with a layout
54- Params .status = status
55- Params .message = message
56- Params .details = details
57- Params .env = BeansEnv
58- Page (" errors/index" , " app" )
50+ -- Define the error for an API
51+ -- WriteJSON({ status = status, message = message })
52+
53+ -- Define the error page via a page with a layout
54+ Params .status = status
55+ Params .message = message
56+ Params .details = details
57+ Params .env = BeansEnv
58+ Page (" errors/index" , " app" )
5959end
6060
6161-- OnHttpRequest hook
6262function OnHttpRequest ()
6363
64- -- local redis = require "db.redis"
65- -- Redis = redis.connect()
64+ -- local redis = require "db.redis"
65+ -- Redis = redis.connect()
6666
67- Params = GetParams ()
68- PrepareMultiPartParams () -- if you handle file uploads
67+ Params = GetParams ()
68+ PrepareMultiPartParams () -- if you handle file uploads
6969
70- SetDevice () -- comment if you do not need this feature
70+ SetDevice () -- comment if you do not need this feature
7171
72- -- Uncomment code if you use ArangoDB
73- if Adb then
74- Adb .primary :RefreshToken () -- reconnect to arangoDB if needed
75- end
72+ -- Uncomment code if you use ArangoDB
73+ -- if Adb then
74+ -- Adb.primary:RefreshToken() -- reconnect to arangoDB if needed
75+ -- end
7676
77- -- Uncomment code if you use surrealdb
78- -- if (db_config ~= nil and db_config["engine"] == "surrealdb") then
79- -- Surreal.refresh_token(db_config[BeansEnv]) -- reconnect to surrealdb if needed
80- -- end
77+ -- Uncomment code if you use surrealdb
78+ -- if (db_config ~= nil and db_config["engine"] == "surrealdb") then
79+ -- Surreal.refresh_token(db_config[BeansEnv]) -- reconnect to surrealdb if needed
80+ -- end
8181
82- DefineRoute (GetPath (), GetMethod ())
82+ DefineRoute (GetPath (), GetMethod ())
8383
84-
85- HandleRequest ()
86- -- Uncomment if you use redis
87- -- unix.close(Redis.network.socket)
84+ HandleRequest ()
85+ -- Uncomment if you use redis
86+ -- unix.close(Redis.network.socket)
8887end
8988
9089function SetDevice ()
91- local user_agent = GetHeader (" User-Agent" )
92- Params .request = { variant = " " }
93- local preg = assert (re .compile (" iPhone" ))
94- if preg :search (user_agent ) then
95- Params .request .variant = " iphone"
96- end
90+ local user_agent = GetHeader (" User-Agent" )
91+ Params .request = { variant = " " }
92+ local preg = assert (re .compile (" iPhone" ))
93+ if preg :search (user_agent ) then
94+ Params .request .variant = " iphone"
95+ end
9796end
0 commit comments