ronin-rb / ronin-app

A local web interface for Ronin.
https://ronin-rb.dev
GNU Affero General Public License v3.0
26 stars 8 forks source link

Use `Sinatra::Router` to split up `App` into multiple classes? #77

Closed postmodern closed 11 months ago

postmodern commented 11 months ago

The app.rb file is getting quite large. Perhaps we could use Sinatra::Router to split up the App class into multiple sub-App classes that are routed together?

AI-Mozi commented 11 months ago

Currently moving /db/* routes outside of a app.rb would be enough. I though about moving scanning section (nmap, masscan, recon, vulns, spider) also, but it not as huge as db.

I was wondering if we should create db_routes.rb file in root directory or maybe api/db.rb or routes/db.rb? (I think creating additional namespace requires changes in views directory structure)

Beside moving db, we could consider making it more compact. Most of these routes are repeatable so we could define them similar to what we did for notes.

AI-Mozi commented 11 months ago

Hmm.. maybe instead of creating new class for db we should just "compact" them as I mentioned before?

AI-Mozi commented 11 months ago

But on the other side It might be much less readable..

postmodern commented 11 months ago

Another downside would be that if we split apart the app into multiple apps, the /db/ app would still be giant, as that is where the majority of the routes are.

postmodern commented 11 months ago

A simpler alternative to using Sinatra::Router, would be to just open up the class again in multiple files.

app.rb:

class App < Sinatra::Base
  ...
end

require './app/db'
require './app/scanning'

app/db.rb:

class App < Sinatra::Base
  get '/db/...' do
    ...
  end
end
postmodern commented 11 months ago

Yeah let's split the app.rb file apart by just re-opening the App class. I will make a new issue.