A full implementation of a middle tier built using the peasy-js framework and consumed by react and 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. All efforts were made to keep this application as simple as possible to focus on how a middle tier can be written with peasy-js and consumed by multiple clients (client and server).
- nodejs - this application is a nodejs application and therefore must be installed.
- postman, fiddler, cURL, or similar - these tools help to facilitate communications with http endpoints.
- 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 for more details.
From a command line, navigate to the peasy-js-samples directory and run:
npm install
npm run start
By default, the client (react) application is configured to use http implementations of the data proxies that communicate with the Web API. In turn, the Web API ic configured to use in-memory data proxies. However, there are a few configuration possibilities. The configurations section provides details on setting up many potential configurations.
In this scenario, the client consumes business services that are injected with data proxies that communicate with in-memory data stores.
In this scenario, the client consumes business services that are injected with data proxies that use HTTP to communicate with the Web API application. In turn, the Web API application uses business services that are injected with data proxies that communicate with in-memory data stores.
In this scenario, the client consumes business services that are injected with data proxies that use HTTP to communicate with the Web API application. In turn, the Web API application uses business services that are injected with data proxies that communicate with a MongoDB database.
With the application up and running you can navigate to the following urls:
- http://localhost:3000/customers
- http://localhost:3000/orders
- http://localhost:3000/orderitems
- http://localhost:3000/products
- http://localhost:3000/categories
- http://localhost:3000/inventoryitems
This walkthrough covers creating a customer, category, product, and placing an order on behalf of the new customer. It also covers submitting and shipping an order to see how it affects inventory.
peasy-js was designed with unit testing in mind, and as a result, each actor in the application has corresponding unit tests, located in the /spec directory.
To run the tests, navigate to the /spec directory from a command line and run the following command:
jasmine
Please consider showing your support by starring the project.