Perhaps a good idea, now that Coronium Core has been released.
Find some good solution, helpful tool or just a nifty way to achieve something?
Post it here
Anaqim
Sidenote!,
I am running coronium utilizing both mySQL and the serverside lua custom api, and I got to hand it to develephant, this is a major upgrade for corona developers, especially in terms of ease of use and implementation.
We have a windows server in the cloud where we need to dabble in .net code, asp and soap rest calls to make things work. And while it does work well, the server side scripting is no where as efficient (and fun) as when doing it in lua using coronium core. We are abandoning the windows server in favor of this new “droplet” and have already moved most of our stuff over.
Keep up the good work and keep adding functions and possibilities, cause this rocks!
Any tips how I can split my api code into parts? I’m thinking about installing git on machine, because webmin doesn’t allow me to have more than 1 file per api project
You can split your code files up in the same project, but only the main.lua can return a result to the client (and you should always return something to the client, to properly close the request). So you need to keep this in mind when building the split modules.
Let’s assume we have a project folder called “myapp” so the structure looks like:
projects myapp main.lua
You can add additional modules to the “myapp” directory and use them in the main.lua. So let’s add our own external module called db.lua:
projects myapp db.lua main.lua
In the main.lua we can require the external module like so:
--main.lua local db\_mod = require("myapp.db") --external module local api = core.api() function api.doSomething(input) local res, err = db\_mod.selectStuff(params) --we must return something from the main.lua if not res then return core.error(err) end return res end return api
The db.lua might look like:
--db.lua local db\_mod = {} function db\_mod.selectStuff(params) local res, err = core.mysql.select("mydb", { tbl = params.my\_tbl }) --you could check for errors here, but its better --to push the result and error back to main. return res, err --OR --if you have nothing to give back, just make sure to return from the method. return end return db\_mod
You can add as many external modules as you want, just remember that you can only return a result to the client from the main.lua
Any tips how I can split my api code into parts? I’m thinking about installing git on machine, because webmin doesn’t allow me to have more than 1 file per api project
You can split your code files up in the same project, but only the main.lua can return a result to the client (and you should always return something to the client, to properly close the request). So you need to keep this in mind when building the split modules.
Let’s assume we have a project folder called “myapp” so the structure looks like:
projects myapp main.lua
You can add additional modules to the “myapp” directory and use them in the main.lua. So let’s add our own external module called db.lua:
projects myapp db.lua main.lua
In the main.lua we can require the external module like so:
--main.lua local db\_mod = require("myapp.db") --external module local api = core.api() function api.doSomething(input) local res, err = db\_mod.selectStuff(params) --we must return something from the main.lua if not res then return core.error(err) end return res end return api
The db.lua might look like:
--db.lua local db\_mod = {} function db\_mod.selectStuff(params) local res, err = core.mysql.select("mydb", { tbl = params.my\_tbl }) --you could check for errors here, but its better --to push the result and error back to main. return res, err --OR --if you have nothing to give back, just make sure to return from the method. return end return db\_mod
You can add as many external modules as you want, just remember that you can only return a result to the client from the main.lua