Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Multiuser app with SQLite, Dancer2 and CLI

by 1nickt (Canon)
on Dec 04, 2018 at 23:15 UTC ( [id://1226747]=note: print w/replies, xml ) Need Help??


in reply to Multiuser app with SQLite, Dancer2 and CLI

Hi, I usually separate out the Dancer route handling code and the actual do-the-work code into separate modules precisely so I can access the latter outside the framework.

Sometimes there are three layers because the Dancer route-handling code that makes use of the true back end libraries (that you want to consume separately) gets so voluminous that I want to keep it out of the actual route handling classes. In that case I wind up with a somewhat parallel structure for the first two layers, like maybe:

lib/ +++ Routes.pm +++ Route/ +++++++++ Account.pm # handles routing for /account +++++++++ Account/ +++++++++++++++++ User.pm +++ API/ +++++++ Account.pm # does stuff with an account +++++++ Account/ +++++++++++++++ User.pm +++ Config.pm +++ DB.pm # provides access to the database +++ LowLevelBizStuff.pm
etc., where a cron script or whatever can access the database outside the Dancer framework.

On the other hand, if your database needs are simple, you can use Dancer2::Plugin::Database to greatly simplify your web app code, but in that case you'd have to write other code to get at your data off line. All depends how complex your data is, how complex your app is, and how complex the actions your want to take on the data off line are.

Hope this helps!


The way forward always starts with a minimal test.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1226747]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (5)
As of 2024-04-18 20:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found