Skip to content
Aaron Hanusa edited this page Aug 20, 2016 · 23 revisions

peasy

Showcases a middle tier built with peasy-js.

A full implementation of a middle tier built using the peasy-js framework and consumed by nodejs can be found here. You can clone the repo (git clone https://github.com/peasy/peasy-js-samples.git) or download the entire solution as a zip.

The sample application is a ficticious order entry / inventory management system web api. All efforts were made to keep this application as simple as possible to keep the focus on how a middle tier is written with peasy-js and consumed by multiple clients (client and server).

By default, this project is configured to use in-memory implementations of the data proxies. However, there is a multitude of configuration possibilities. The configurations section provides details on setting up many potential configurations.

Requirements

  1. nodejs - this application is a nodejs application and requires nodejs to be installed.
  2. postman, fiddler, cURL, or similar - these tools help to facilitate hitting http endpoints.
  3. mongodb (optional) - this application by default is configured to work with in-memory data proxies, however, you can easily swap data proxies to interact with a mongodb instance if desired. See [Mongodb Configuration] (https://github.com/peasy/peasy-js-samples/blob/master/README.md#mongodb-configuration) for more details.

Running the application

From a command line, navigate to the peasy-js-samples directory and run:

  1. npm install
  2. node index.js

Testing out the application

With the application up and running you can navigate to the following urls:

Application Walkthrough

This walkthrough will cover creating a customer, category, product, and placing an order on behalf of the new customer. Further, you will ship an order and see how it affects inventory as well.

Mongodb Configuration

The sample applications can be configured to interact with a mongodb database. With mongodb installed and running, here are the steps to setup the application to interact with it:

1.) Navigate to wireUpRoutes.js in the root of the application

2.) Locate and comment out the following line:

var proxyFactory = require('./data_proxies/in-memory/inMemoryDataProxyFactory');

3.) Locate and uncomment the following line:

var proxyFactory = require('./data_proxies/mongo/mongoDataProxyFactory');

Here is what you should have:

4.) Restart the application to ensure that the new proxies are consumed

5.) Test the app according to these steps

Running the unit tests

Videos

Coming soon ...

Solution and Project Structure

An overview of the solution and all of the projects can be viewed here.

Clone this wiki locally