routes: Move root route to controllers module The routes were now in modules in the root, which created a messy situation for the future. For now the routes will be moved to the controllers module and later additional changes will be done to further clean this up.

zj
Sep 21, 2021, 8:34 AM
3E77DEMDLYBFJEGS2SLQKLQJQIXG2Y4TBDHAG3UKFLMKQ53CFOKQC

Dependencies

  • [2] FS2NWBVN pijul: Start of push/pull work This change includes one API endpoint, .pijul. It allows for getting a channels remote ID. A lot of plumbing around repositories is added too, from init to opening pristine and actions like it.
  • [3] ZGXZ2IRI Cleanup leftover files Recorded earlier, but uninteded. Now it's cleaned up again.
  • [4] KFVJ3KMW frontend: Introduce navigation bar Minor changes to the front-end mostly, to allow users to register, sign in, and sign out. The sign out route is changed to a GET endpoint, as links in HTML cannot DELETE.
  • [5] W3M3C7CC Initial commit This change includes a very small hello world application server written in Rust using Rocket.rs. Managing dependencies is done with Nix as that works well between Linux and Mac for me.
  • [6] 5UNA2DEA routes: Register and authenticate users Allow users to sign up, and sign in/sign out. The routes are added, though the design of the pages is very bare bones still, it's hard to go through the full flow to demo. On the server side: Passwords are stored encrypted in the database with salts. This uses the PG encrypt tooling to prevent against bugs and maintainance costs on this project. When a user is signed in, the user ID is set in a private cookie. Rocket has Guards for routes, which has not been implemented yet for this project.
  • [7] TWIZ7QV4 db: Add interface to add a project Right now a project has a name, and an owner which is hardcoded to 1. This is because basically I'm speedrunning to implement push/pull of Pijul and then revisit to add depth to features and tests. Model code is now split into files properly too.
  • [8] KULVODXD routes: User route mod exposes routes() now Other routes already did this to keep the routes clean when mounting. Now the user routes do too.
  • [9] K4JNAJOF database: Connect to postgres on Rocket boot As database I've chosen PostgreSQL, as my personal experience has been good with it. This change allows Rocket to connect to the database on booting the server. It depends on the DATABASE_URL being set, and for now circumvents the Rocket config helpers as it seemed faster to be up and running this way.

Change contents

  • file deletion: root.rs (----------)
    [3.179][3.2536:2567](),[3.2567][3.2568:2568]()
    use rocket::form::Context;
    use rocket_dyn_templates::Template;
    #[get("/")]
    pub fn landing() -> Template {
    Template::render("landing", &Context::default())
    }
  • edit in src/main.rs at line 12
    [3.8055]
    [3.8055]
    mod controllers;
  • edit in src/main.rs at line 16
    [3.4107][3.2732:2742](),[3.8067][3.2732:2742]()
    mod root;
  • replacement in src/main.rs at line 30
    [3.4156][3.2743:2787](),[2.5544][3.2743:2787](),[3.8399][3.2743:2787]()
    .mount("/", routes![root::landing])
    [2.5544]
    [3.823]
    .mount("/", controllers::routes())
  • file addition: controllers (d--r------)
    [3.179]
  • file addition: root.rs (----------)
    [0.85]
    use rocket::form::Context;
    use rocket::Route;
    use rocket_dyn_templates::Template;
    #[get("/")]
    fn landing() -> Template {
    Template::render("landing", &Context::default())
    }
    pub fn routes() -> Vec<Route> {
    routes![landing]
    }
  • file addition: mod.rs (----------)
    [0.85]
    use rocket::Route;
    pub mod root;
    pub fn routes() -> Vec<Route> {
    root::routes()
    }