When you need an API server for testing there's Total.js framework to get you up and running in minutes. If You want to know how then keep reading.
First thing we do is setup a server using framework.http:
The above code can be used as a static file server. If You create a
public folder then whatever you place in there will be accessible. e.g. ./public/favicon.ico =>
Next we setup a schema and some properties using SchemaBuilder.
Now it's time to create some routes using F.route. In each route we use
*Product flag which tells the framework we want to use the schema methods in a controller.
Since we've specified the
*Product flag we can use schema methods such as
$get, $query, $save, etc..
Let's add logging for each request so we know what's going on:
Find the gist here index.js.
If you want it to work really quickly you can use recently added functionality
NOSQL inmemory. Add it just bellow
This will keep all documents from
products collection in memory for quicker access.