Skip to content

Tutorial Getting started

Richard Andrew Cattermole edited this page Apr 2, 2014 · 1 revision

So how to get started. First off Cmsed is really targeted at those who are already familiar with how to use the basics of Vibe. And want something really to bridge the gap between core capability and productivity.

Keep in mind you are either willing to use Cmsed:base package or not at all. All of the other sub packages are useless without it. Dvorm is highly integrated into it. To give a high level of cross usage in multiple of areas.

Installation

Nothing really special about it. Just add it as part of your dub dependencies. It will define its own main function. Please note it does everything Vibe's does but a whole lot more. It has the capability of:

  • Continually executing on error (also logs on error!).
  • Running in installation / production mode
  • Running as a frontend or backend node. This will be important for larger web services when the node communication system is developed.

The code for this is defined in cmsed.base.main. If you feel you want to remove it, you can define the version ExcludeCmsedMain in your dub package file.

Your code

So how do you structure your code? Its a great question and very important.
Every route and data model must be registered into Cmsed. This can only be done at compile time because a lot of code is generated per class / struct.

You will have package files for every directory. And each directory should either be models or routes. Recommended to call it just that.
For example given that we have a movie database like IMDB we know we have data models like Movie and routes which allow us to access them.
So:

  • mymoviedb/routes/access.d
  • mymoviedb/routes/package.d
  • mymoviedb/models/movie.d
  • mymoviedb/models/package.d

So each of the package files will look like this:

public import mymoviedb.models.movie;

shared static this() {
    registerModel!Movie;
}

And a very similar one for route where instead of Model/models/Movie would be Route/routes/Access.

Conclusion

Please note I have not gone into depth of what a route/model looks like. Nor the configuration system. Thats for a later time or another tutorial.

Clone this wiki locally