yesod-routes-flow: Generate Flow routes for Yesod

[ library, mit, web ] [ Propose Tags ]

Parse the Yesod routes data structure and generate routes that can be used with Flow.


[Skip to Readme]

Modules

[Index] [Quick Jump]

Downloads

Maintainer's Corner

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 1.0, 1.0.1, 1.0.2, 1.1, 1.1.1, 2.0, 3.0.0.1, 3.0.0.2
Change log Changelog.md
Dependencies attoparsec (>=0.13.2.2), base (>=4.11.1.0 && <5), classy-prelude (>=0.7), containers (>=0.5.11.0), system-fileio (>=0.3.16.4), system-filepath (>=0.4), text (>=1.2.3.1), yesod-core (>=1.4 && <2.0) [details]
License MIT
Copyright 2021 Renaissance Learning Inc
Author Freckle Engineering
Maintainer engineering@freckle.com
Category Web
Home page https://github.com/freckle/yesod-routes-flow
Bug tracker https://github.com/freckle/yesod-routes-flow/issues
Source repo head: git clone https://github.com/freckle/yesod-routes-flow
Uploaded by PatrickBrisbin at 2022-03-31T14:15:26Z
Distributions LTSHaskell:3.0.0.2, NixOS:3.0.0.2, Stackage:3.0.0.2
Downloads 3444 total (36 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2022-03-31 [all 1 reports]

Readme for yesod-routes-flow-3.0.0.2

[back to package description]

yesod-routes-flow

Parse the Yesod routes data structure and generate routes that can be used in Flow.

The routing structure is generated by:

mkYesodDispatch "App" resourcesApp

You can generate routes at startup inside the makeApplication function

when development $
    genFlowRoutes resourcesApp "assets/ts/paths-gen.ts"

This generates Flow code:

class PATHS_TYPE_paths {
  contacts: PATHS_TYPE_paths_contacts;
  admin: PATHS_TYPE_paths_admin;

  constructor(){
    this.contacts = new PATHS_TYPE_paths_contacts();
    this.admin = new PATHS_TYPE_paths_admin();
  }
}

class PATHS_TYPE_paths_contacts {
  get(): string { return '/api/v1/contacts/get'; }
}

class PATHS_TYPE_paths_admin {
  adminDocs: PATHS_TYPE_paths_admin_adminDocs;

  constructor(){
    this.adminDocs = new PATHS_TYPE_paths_admin_adminDocs();
  }
}

class PATHS_TYPE_paths_admin_adminDocs {
  get(): string { return '/api/v1/admin/docs/get'; }
}


var PATHS:PATHS_TYPE_paths = new PATHS_TYPE_paths();

In your Flow code you can now do:

PATHS.admin.adminDocs.get()

Please note that the Haskell code was hastily translated from Javascript code, then translated from TypeScript to Flow, and is pretty horrible. There are bugs and edge cases to be addressed, but this works ok for us.