Coronium Tips

Hi,

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 :slight_smile:

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!

Congratulations!  :smiley:

Using a digital ocean droplet, I discovered a console icon which works great and grant full access to coronium.

So no need to install putty (for windows users) unless you prefer it that way.

You may still need puttygen for generating the SSH keys.

This is a great idea. I’ll add some soon.  :slight_smile:

And thanks for the great feedback. I really appreciate it!

-dev

Tip: If you need to update your database passwords, have a look here.

-dev

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

Hi,

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

-dev

Hi,

By the way, you need to add the external modules using SFTP. The Webmin will eventually handle adding external modules, but not sure when.

-dev

Yes SFTP or some other way. Thats why I talked about GIt - I can create a repository and keep my files up to date using this repository

Using a digital ocean droplet, I discovered a console icon which works great and grant full access to coronium.

So no need to install putty (for windows users) unless you prefer it that way.

You may still need puttygen for generating the SSH keys.

This is a great idea. I’ll add some soon.  :slight_smile:

And thanks for the great feedback. I really appreciate it!

-dev

Tip: If you need to update your database passwords, have a look here.

-dev

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

Hi,

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

-dev

Hi,

By the way, you need to add the external modules using SFTP. The Webmin will eventually handle adding external modules, but not sure when.

-dev

Yes SFTP or some other way. Thats why I talked about GIt - I can create a repository and keep my files up to date using this repository