isaaccheng9 / fairsplit Goto Github PK
View Code? Open in Web Editor NEWA web application to split bills and track shared expenses in a group, with a transaction minimisation algorithm. Developed with Node and React.
A web application to split bills and track shared expenses in a group, with a transaction minimisation algorithm. Developed with Node and React.
server/controllers/userController.js
server/controllers/expenseController.js
username
for now that acts as a unique identifier.
firstName
and lastName
) at a later point.firstName
and lastName
can be implemented at a later point.jack3 -> 3 Users
creationDatetime
, author
, title
, amount
(GBP), lender
and borrowers
.
await
on when clearing the optimised debt model collection here.await
statement causes test failures:isaac@MBP16 server % npm test
> [email protected] test
> jest --verbose --coverage
PASS routes/users.test.js
Test for user routes
✓ GET /users (24 ms)
✓ POST /users (18 ms)
✓ GET /users/:username (6 ms)
✓ DELETE /users/:username (4 ms)
PASS routes/expenses.test.js
Test for expense routes
✓ GET /expenses (20 ms)
✓ POST /expenses (24 ms)
✓ POST /expenses/settlement (6 ms)
/Users/isaac/Library/CloudStorage/OneDrive-Personal/Documents/Programming/Projects/fairsplit/server/node_modules/mongodb/lib/operations/execute_operation.js:20
return callback(new error_1.MongoNotConnectedError('Client must be connected before running operations'));
^
MongoNotConnectedError: Client must be connected before running operations
at /Users/isaac/Library/CloudStorage/OneDrive-Personal/Documents/Programming/Projects/fairsplit/server/node_modules/mongodb/src/operations/execute_operation.ts:89:11
at maybePromise (/Users/isaac/Library/CloudStorage/OneDrive-Personal/Documents/Programming/Projects/fairsplit/server/node_modules/mongodb/src/utils.ts:518:3)
at executeOperation (/Users/isaac/Library/CloudStorage/OneDrive-Personal/Documents/Programming/Projects/fairsplit/server/node_modules/mongodb/src/operations/execute_operation.ts:83:22)
at Collection.deleteMany (/Users/isaac/Library/CloudStorage/OneDrive-Personal/Documents/Programming/Projects/fairsplit/server/node_modules/mongodb/src/collection.ts:624:28)
at NativeCollection.<computed> [as deleteMany] (/Users/isaac/Library/CloudStorage/OneDrive-Personal/Documents/Programming/Projects/fairsplit/server/node_modules/mongoose/lib/drivers/node-mongodb-native/collection.js:202:33)
at NodeCollection.deleteMany (/Users/isaac/Library/CloudStorage/OneDrive-Personal/Documents/Programming/Projects/fairsplit/server/node_modules/mquery/lib/collection/node.js:90:21)
at model.Query.Object.<anonymous>.Query.deleteMany (/Users/isaac/Library/CloudStorage/OneDrive-Personal/Documents/Programming/Projects/fairsplit/server/node_modules/mquery/lib/mquery.js:2661:20)
at model.Query.<anonymous> (/Users/isaac/Library/CloudStorage/OneDrive-Personal/Documents/Programming/Projects/fairsplit/server/node_modules/mongoose/lib/query.js:3211:32)
at model.Query._wrappedThunk [as _deleteMany] (/Users/isaac/Library/CloudStorage/OneDrive-Personal/Documents/Programming/Projects/fairsplit/server/node_modules/mongoose/lib/helpers/query/wrapThunk.js:27:8)
at /Users/isaac/Library/CloudStorage/OneDrive-Personal/Documents/Programming/Projects/fairsplit/server/node_modules/kareem/index.js:426:25 {
[Symbol(errorLabels)]: Set(0) {}
}
Node.js v18.2.0
/Users/isaac/Library/CloudStorage/OneDrive-Personal/Documents/Programming/Projects/fairsplit/server/node_modules/mongodb/lib/operations/execute_operation.js:20
return callback(new error_1.MongoNotConnectedError('Client must be connected before running operations'));
^
MongoNotConnectedError: Client must be connected before running operations
at /Users/isaac/Library/CloudStorage/OneDrive-Personal/Documents/Programming/Projects/fairsplit/server/node_modules/mongodb/src/operations/execute_operation.ts:89:11
at maybePromise (/Users/isaac/Library/CloudStorage/OneDrive-Personal/Documents/Programming/Projects/fairsplit/server/node_modules/mongodb/src/utils.ts:518:3)
at executeOperation (/Users/isaac/Library/CloudStorage/OneDrive-Personal/Documents/Programming/Projects/fairsplit/server/node_modules/mongodb/src/operations/execute_operation.ts:83:22)
at Collection.deleteMany (/Users/isaac/Library/CloudStorage/OneDrive-Personal/Documents/Programming/Projects/fairsplit/server/node_modules/mongodb/src/collection.ts:624:28)
at NativeCollection.<computed> [as deleteMany] (/Users/isaac/Library/CloudStorage/OneDrive-Personal/Documents/Programming/Projects/fairsplit/server/node_modules/mongoose/lib/drivers/node-mongodb-native/collection.js:202:33)
at NodeCollection.deleteMany (/Users/isaac/Library/CloudStorage/OneDrive-Personal/Documents/Programming/Projects/fairsplit/server/node_modules/mquery/lib/collection/node.js:90:21)
at model.Query.Object.<anonymous>.Query.deleteMany (/Users/isaac/Library/CloudStorage/OneDrive-Personal/Documents/Programming/Projects/fairsplit/server/node_modules/mquery/lib/mquery.js:2661:20)
at model.Query.<anonymous> (/Users/isaac/Library/CloudStorage/OneDrive-Personal/Documents/Programming/Projects/fairsplit/server/node_modules/mongoose/lib/query.js:3211:32)
at model.Query._wrappedThunk [as _deleteMany] (/Users/isaac/Library/CloudStorage/OneDrive-Personal/Documents/Programming/Projects/fairsplit/server/node_modules/mongoose/lib/helpers/query/wrapThunk.js:27:8)
at /Users/isaac/Library/CloudStorage/OneDrive-Personal/Documents/Programming/Projects/fairsplit/server/node_modules/kareem/index.js:426:25 {
[Symbol(errorLabels)]: Set(0) {}
}
Node.js v18.2.0
/Users/isaac/Library/CloudStorage/OneDrive-Personal/Documents/Programming/Projects/fairsplit/server/node_modules/mongodb/lib/operations/execute_operation.js:20
return callback(new error_1.MongoNotConnectedError('Client must be connected before running operations'));
^
MongoNotConnectedError: Client must be connected before running operations
at /Users/isaac/Library/CloudStorage/OneDrive-Personal/Documents/Programming/Projects/fairsplit/server/node_modules/mongodb/src/operations/execute_operation.ts:89:11
at maybePromise (/Users/isaac/Library/CloudStorage/OneDrive-Personal/Documents/Programming/Projects/fairsplit/server/node_modules/mongodb/src/utils.ts:518:3)
at executeOperation (/Users/isaac/Library/CloudStorage/OneDrive-Personal/Documents/Programming/Projects/fairsplit/server/node_modules/mongodb/src/operations/execute_operation.ts:83:22)
at Collection.deleteMany (/Users/isaac/Library/CloudStorage/OneDrive-Personal/Documents/Programming/Projects/fairsplit/server/node_modules/mongodb/src/collection.ts:624:28)
at NativeCollection.<computed> [as deleteMany] (/Users/isaac/Library/CloudStorage/OneDrive-Personal/Documents/Programming/Projects/fairsplit/server/node_modules/mongoose/lib/drivers/node-mongodb-native/collection.js:202:33)
at NodeCollection.deleteMany (/Users/isaac/Library/CloudStorage/OneDrive-Personal/Documents/Programming/Projects/fairsplit/server/node_modules/mquery/lib/collection/node.js:90:21)
at model.Query.Object.<anonymous>.Query.deleteMany (/Users/isaac/Library/CloudStorage/OneDrive-Personal/Documents/Programming/Projects/fairsplit/server/node_modules/mquery/lib/mquery.js:2661:20)
at model.Query.<anonymous> (/Users/isaac/Library/CloudStorage/OneDrive-Personal/Documents/Programming/Projects/fairsplit/server/node_modules/mongoose/lib/query.js:3211:32)
at model.Query._wrappedThunk [as _deleteMany] (/Users/isaac/Library/CloudStorage/OneDrive-Personal/Documents/Programming/Projects/fairsplit/server/node_modules/mongoose/lib/helpers/query/wrapThunk.js:27:8)
at /Users/isaac/Library/CloudStorage/OneDrive-Personal/Documents/Programming/Projects/fairsplit/server/node_modules/kareem/index.js:426:25 {
[Symbol(errorLabels)]: Set(0) {}
}
Node.js v18.2.0
/Users/isaac/Library/CloudStorage/OneDrive-Personal/Documents/Programming/Projects/fairsplit/server/node_modules/mongodb/lib/operations/execute_operation.js:20
return callback(new error_1.MongoNotConnectedError('Client must be connected before running operations'));
^
MongoNotConnectedError: Client must be connected before running operations
at /Users/isaac/Library/CloudStorage/OneDrive-Personal/Documents/Programming/Projects/fairsplit/server/node_modules/mongodb/src/operations/execute_operation.ts:89:11
at maybePromise (/Users/isaac/Library/CloudStorage/OneDrive-Personal/Documents/Programming/Projects/fairsplit/server/node_modules/mongodb/src/utils.ts:518:3)
at executeOperation (/Users/isaac/Library/CloudStorage/OneDrive-Personal/Documents/Programming/Projects/fairsplit/server/node_modules/mongodb/src/operations/execute_operation.ts:83:22)
at Collection.deleteMany (/Users/isaac/Library/CloudStorage/OneDrive-Personal/Documents/Programming/Projects/fairsplit/server/node_modules/mongodb/src/collection.ts:624:28)
at NativeCollection.<computed> [as deleteMany] (/Users/isaac/Library/CloudStorage/OneDrive-Personal/Documents/Programming/Projects/fairsplit/server/node_modules/mongoose/lib/drivers/node-mongodb-native/collection.js:202:33)
at NodeCollection.deleteMany (/Users/isaac/Library/CloudStorage/OneDrive-Personal/Documents/Programming/Projects/fairsplit/server/node_modules/mquery/lib/collection/node.js:90:21)
at model.Query.Object.<anonymous>.Query.deleteMany (/Users/isaac/Library/CloudStorage/OneDrive-Personal/Documents/Programming/Projects/fairsplit/server/node_modules/mquery/lib/mquery.js:2661:20)
at model.Query.<anonymous> (/Users/isaac/Library/CloudStorage/OneDrive-Personal/Documents/Programming/Projects/fairsplit/server/node_modules/mongoose/lib/query.js:3211:32)
at model.Query._wrappedThunk [as _deleteMany] (/Users/isaac/Library/CloudStorage/OneDrive-Personal/Documents/Programming/Projects/fairsplit/server/node_modules/mongoose/lib/helpers/query/wrapThunk.js:27:8)
at /Users/isaac/Library/CloudStorage/OneDrive-Personal/Documents/Programming/Projects/fairsplit/server/node_modules/kareem/index.js:426:25 {
[Symbol(errorLabels)]: Set(0) {}
}
Node.js v18.2.0
FAIL routes/debts.test.js
● Test suite failed to run
Jest worker encountered 4 child process exceptions, exceeding retry limit
at ChildProcessWorker.initialize (node_modules/jest-worker/build/workers/ChildProcessWorker.js:211:21)
------------------------|---------|----------|---------|---------|-------------------------------------------
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
------------------------|---------|----------|---------|---------|-------------------------------------------
All files | 79.27 | 34.61 | 81.81 | 79.27 |
controllers | 94.73 | 50 | 100 | 94.73 |
expense_controller.js | 91.3 | 50 | 100 | 91.3 | 10,18
user_controller.js | 100 | 100 | 100 | 100 |
controllers/helpers | 51.16 | 31.81 | 50 | 51.16 |
index.js | 51.16 | 31.81 | 50 | 51.16 | ...9,43-44,53,65-74,93,96,101-107,119-138
models | 100 | 100 | 100 | 100 |
debt.js | 100 | 100 | 100 | 100 |
expense.js | 100 | 100 | 100 | 100 |
optimised_debt.js | 100 | 100 | 100 | 100 |
user.js | 100 | 100 | 100 | 100 |
user_debt.js | 100 | 100 | 100 | 100 |
routes | 100 | 100 | 100 | 100 |
expenses.js | 100 | 100 | 100 | 100 |
users.js | 100 | 100 | 100 | 100 |
------------------------|---------|----------|---------|---------|-------------------------------------------
Test Suites: 1 failed, 2 passed, 3 total
Tests: 7 passed, 7 total
Snapshots: 0 total
Time: 3.664 s
Ran all test suites.
Save
on a video) when the 'Add Expense' button is pressed, which would have a form for the user to add the expense with the following fields:
title
author
lender
borrowers
borrowers
field could be changed from [String]
to [String, Number]
to represent the username and how much they owe.datetime
, title
, payee
, and amount
.Amount
, entries which are too long, etc.) and null inputs. // Check whether we can settle a debt between two users.
test("POST /debts/settle", async () => {
const server = supertest(app);
await server
.post("/debts/settle")
.send({
from: "testuser456",
to: "testuser123",
amount: 50,
})
.expect(200);
// Check whether the debt was successfully reduced by 50.
await debtModel
.findOne({
from: "testuser123",
to: "testuser456",
})
.then((debt) => {
expect(debt.amount).toBe(50);
});
});
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.