Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

Re: Multiuser app with SQLite, Dancer2 and CLI

by 1nickt (Canon)
on Dec 04, 2018 at 23:15 UTC ( #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/ +++ +++ Route/ +++++++++ # handles routing for /account +++++++++ Account/ +++++++++++++++++ +++ API/ +++++++ # does stuff with an account +++++++ Account/ +++++++++++++++ +++ +++ # provides access to the database +++
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?

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

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (6)
As of 2022-12-09 12:26 GMT
Find Nodes?
    Voting Booth?

    No recent polls found