yesod-routes-typescript: generate TypeScript routes for Yesod

[ library, mit, web ] [ Propose Tags ]

parse the Yesod routes data structure and generate routes that can be used in typescript

[Skip to Readme]




Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees


  • No Candidates
Versions [RSS]
Dependencies attoparsec, base (<5), classy-prelude (>=0.7), system-fileio, text, yesod-core (>=1.2 && <2.0), yesod-routes (>=1.2 && <2.0) [details]
License MIT
Author Max Cantor
Category Web
Home page
Uploaded by GregWeber at 2014-04-16T22:59:04Z
Reverse Dependencies 1 direct, 0 indirect [details]
Downloads 996 total (6 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Successful builds reported [all 1 reports]

Readme for yesod-routes-typescript-

[back to package description]


parse the Yesod routes data structure and generate routes that can be used in typescript

The routing structure is generated by:

mkYesodDispatch "App" resourcesApp

You can generate routes at startup inside the makeApplication function

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

This generates typescript code:

class PATHS_TYPE_paths {
  public contacts: PATHS_TYPE_paths_contacts;
  public admin: PATHS_TYPE_paths_admin;

    this.contacts = new PATHS_TYPE_paths_contacts();
    this.admin = new PATHS_TYPE_paths_admin();

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

class PATHS_TYPE_paths_admin {
  public adminDocs: PATHS_TYPE_paths_admin_adminDocs;

    this.adminDocs = new PATHS_TYPE_paths_admin_adminDocs();

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

var PATHS:PATHS_TYPE_paths = new PATHS_TYPE_paths();

In your typescript code you can now do:


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