A simple Node.js API to manage transactions.
To run this API you will need:
- Node.js v6.11.x+
- MongoDB v3.6+
Run npm install
to install dependencies
On the MongoDB /bin folder
mongod --dbpath ../data
npm start
API will run on http://localhost:3001/api
- /app - Application specific code
- /api
- /transaction - Transaction Domain
- /api
- /bin - Server execution code
- /config - General configuration of the server
- /database - Database configuration
- /middleware - Custom server middleware
- /routes - Routing specific code. This folder maintains the same structure of available routes.
Retrieve transactions.
You can use the Link header for pagination reference (first, previous, next and/or last pages).
- paymentType: (money|credit)
Filter by payment type.
- startDate: Number
Get transactions that were created after startDate. Parameter must be a date in milliseconds.
- endDate: Number
Get transactions that were created before endDate. Parameter must be a date in milliseconds.
- page: Number
Page of transactions to retrieve.
- limit: Number
Number of transactions per page.
- sort: String
Pass the name of the fields you want to sort. Use a '-' to sort on descending order.
E.g.: -amount,description will sort by amount on descending and description on ascending order.
Create a new transaction.
Update a transaction with the corresponding id.
Delete a transaction with the corresponding id.
To save some time while developing, you can use the development server which automatically reloads once a file is changed.
npm run dev
To enable all application loggers just set the DEBUG
environment variable before running the server.
On Windows:
set DEBUG=cashflower-api:*
On *nix:
export DEBUG=cashflower-api:*
For more information about the logger, take a look at the docs of the [debug] module.
npm test
This script will run all the test suites in the project.
This project uses Standard style. Run the linter with:
npm run lint