-
Notifications
You must be signed in to change notification settings - Fork 2
Home
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.
- nodejs - this application is a nodejs application and requires nodejs to be installed.
- postman, fiddler, cURL, or similar - these tools help to facilitate hitting 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] (https://github.com/peasy/peasy-js-samples/blob/master/README.md#mongodb-configuration) for more details.
From a command line, navigate to the peasy-js-samples directory and run:
npm install
node index.js
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 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.
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
Coming soon ...
An overview of the solution and all of the projects can be viewed here.