russet
Example Usage
'use strict';var russet =Bundlereturn{return "this is working"}{return "bar"}Appreturnvar AwesomeApp =AwesomeAppstart
App
All Russet apps are a collection of bundles. The app itself usually requires minimal updates, and is essentially used to register your bundles.
'use strict';const russet =App/*** Return an array of bundles to register*/returnconst MyApp =/*** This starts the http server and starts serving traffic to any* matched routes in your registered bundles or in the ./public/* directory (usually used for static assets)*/MyAppstart
Bundle
Bundles are meant to be folders that contain a list of your models, stores, routes, and templates.
Each bundle requires a bundle object to register the routes.
'use strict';const russet =Bundlereturn{return "this is working"}
Routes
Routes for Russet are defined via a simply key => function syntax. The key begins with an HTTP Verb, and then the path to match.
'use strict';var LandingController =const MyRoutes ='GET:/': LandingControllerindexAction'POST:/login': LandingControllerloginAction'DELETE:/user/{userId}': LandingControllerdeleteUser'PUT:/user': LandingControllersaveUser
When the route is matched, the corresponding function will be called, and should return a russet.Response object. The function will receive a http.Request object, a http.Response object (which allows you to end the response outside of russet), and if the URL contains parameters, a 3rd object with the parameters:
'use strict';const russet =const MyRoutes ={return "Deleting user with ID: " + datauserId};
When using TypeScript, routes can use the Route Sanitizer Decorator from beef
Template Response
Russet allows you to return React objects in a response which will be rendered out to a string using ReactServer.
//written using jsx'use strict';const russet =const React =var MyComponent = Reactconst MyRoutes ={return <MyComponent />};