INTERNET ALL THE THINGS!

Do what he says! He has a giant cotton bud in his hand!

Like you I often spend my weekends writing REST APIs for fun. And like you I am often frustrated by the amount of server-side code I need to write just to expose some data to JavaScript. Boilerplate, boilerplate, boilerplate. Ugh! So this weekend, in between bouts of erratic and unsatisfying jetlag-sleep, I decided to try and simplify the task of exposing an API to JavaScript. Introducing “QuickModules for ASP.NET MVC”, available now as a NuGet package!

QuickModules

QuickModules provides you with a basic, modular framework for hanging API endpoints from. Internally using the Managed Extensibility Framework (MEF) to load modules, QuickModules gives you the ability to build encapsulated CRUD services without needing to write, or understand, the usual plumbing.

Consumer Experience

As a software developer, and a human (vaguely), I like an easy life, so I’m all about the consumer experience when publishing code or frameworks (see my JavaScript business-object CRUD framework at http://richstokoe.github.io).

In order to ease any concerns you may have I will run through all the steps required (there are very few) to get QuickModules into your MVC application.

Step 0: Open Visual Studio (Duh!)

Step 1: Create a new MVC project

quickmodules_1

 

Step 2: Choose an Empty, Basic, Internet, Intranet or SPA template (actually, any will do, but these make the most sense)

quickmodules_2

 

Step 3: Notice how barren your project is without QuickModules. 🙁 (I’ve chosen a Basic template here)

quickmodules_3

 

Step 4: Install QuickModules using NuGet: Right-click on the References node in your Solution Explorer tree and click on “Manage NuGet Packages”:

quickmodules_4

 

Step 5: Search for “QuickModules” and choose “Install”. (Don’t worry if the details and version numbers look a little different on your PC, this is a screenshot of an early work-in-progress package).

quickmodules_5

 

That’s it! Hit F5 to run your application. If you’ve chosen an Empty or Basic template you’ll probably get a 404 Not Found error. Try navigating to the sample “Nearby Restaurants” module by adding /QM/Get?ActivityType=NearbyRestaurants to your URL (QM being shorthand for QuickModules of course!).

You should see a list of food places from The Simpsons as a wonderful, unformatted, JSON object array, ready to be consumed by your JavaScript:

quickmodules_7

 

But Wait There’s More!

Built into the framework (and optionally supported by your modules) is paging, and filtering. All for the low, low price of $9.95.  (Just kidding, it’s free). Use the LINQ-style Skip and Take arguments to control paging:

quickmodules_8

 

And use the Filter argument to narrow the result set down:

quickmodules_9 Read more