MIT licensed by Freckle Engineering
Maintained by [email protected]
This version can be pinned in stack with:yesod-routes-flow-3.0.0.2@sha256:0d14f28b9401c7dcb6c078391e20c032e29980bd9b2ddf88cfda49738bab68c1,2421

Module documentation for 3.0.0.2

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.

Changes

Unreleased

None

v3.0.0.2

  • Support GHCs 9.0 and 9.2

v3.0.0.1

  • Setup CI/CD
  • Starting in yesod-core-1.6.2, yesod-core started deriving Show for ResourceTree and FlatResource. To prevent duplicate instance errors, this package now only derives Show for yesod-core < 1.6.2.
  • An implication of this is that building anything less than yesod-routes-flow-3.0.0.1 with yesod-core-1.6.2 will cause duplicate instance compiler errors.