Skip to content

Commit

Permalink
bump dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
brandon-pereira committed Dec 18, 2022
1 parent 74bc7bd commit 6ad79ae
Show file tree
Hide file tree
Showing 9 changed files with 9,571 additions and 7,726 deletions.
17,159 changes: 9,504 additions & 7,655 deletions package-lock.json

Large diffs are not rendered by default.

54 changes: 27 additions & 27 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,41 +12,41 @@
"author": "brandon-pereira",
"license": "ISC",
"dependencies": {
"@types/passport": "^1.0.7",
"@vvo/tzdb": "^6.45.0",
"body-parser": "^1.19.1",
"@types/passport": "^1.0.11",
"@vvo/tzdb": "^6.83.0",
"body-parser": "^1.20.1",
"connect-mongo": "^4.6.0",
"cookie-parser": "^1.4.6",
"date-fns": "^2.28.0",
"dotenv": "^16.0.0",
"express": "^4.17.2",
"express-session": "^1.17.2",
"mongodb": "^4.3.1",
"mongoose": "^6.2.0",
"passport": "^0.5.2",
"date-fns": "^2.29.3",
"dotenv": "^16.0.3",
"express": "^4.18.2",
"express-session": "^1.17.3",
"mongodb": "^4.12.1",
"mongoose": "^6.8.0",
"passport": "^0.6.0",
"passport-google-oauth20": "^2.0.0",
"web-notifier": "^2.0.2"
},
"devDependencies": {
"@shelf/jest-mongodb": "^2.2.0",
"@tsconfig/node14": "^1.0.1",
"@types/express": "^4.17.13",
"@types/express-session": "^1.17.4",
"@types/jest": "^27.4.0",
"@types/node": "^17.0.15",
"@shelf/jest-mongodb": "^4.1.4",
"@tsconfig/node14": "^1.0.3",
"@types/express": "^4.17.15",
"@types/express-session": "^1.17.5",
"@types/jest": "^29.2.4",
"@types/node": "^18.11.17",
"@types/passport-google-oauth20": "^2.0.11",
"@typescript-eslint/eslint-plugin": "^5.10.2",
"@typescript-eslint/parser": "^5.10.2",
"@typescript-eslint/eslint-plugin": "^5.46.1",
"@typescript-eslint/parser": "^5.46.1",
"cors": "^2.8.5",
"eslint": "^8.8.0",
"eslint": "^8.30.0",
"eslint-plugin-eslint-comments": "^3.2.0",
"eslint-plugin-jest": "^26.0.0",
"eslint-plugin-prettier": "^4.0.0",
"jest": "^27.5.0",
"prettier": "^2.5.1",
"ts-jest": "^27.1.3",
"ts-node": "^10.4.0",
"ts-node-dev": "^1.1.8",
"typescript": "^4.5.5"
"eslint-plugin-jest": "^27.1.7",
"eslint-plugin-prettier": "^4.2.1",
"jest": "^29.3.1",
"prettier": "^2.8.1",
"ts-jest": "^29.0.3",
"ts-node": "^10.9.1",
"ts-node-dev": "^2.0.0",
"typescript": "^4.9.4"
}
}
4 changes: 2 additions & 2 deletions src/authentication/logout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ const serverUrl = process.env.SERVER_URL || '/';

export default ({ app }: InternalRouter): void => {
app.get('/auth/logout', (req, res) => {
req.logout();
req.logout(() => null);
res.redirect(serverUrl);
});

app.post('/auth/logout', (req, res) => {
req.logout();
req.logout(() => null);
res.json({ success: true });
});
};
2 changes: 2 additions & 0 deletions src/database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ export interface Database {
Tasks: TaskModel;
}

mongoose.set('strictQuery', false);

export const MONGO_CONNECTION_URL =
process.env.MONGO_URL || `mongodb://localhost/${process.env.DATABASE_NAME || 'betterdo'}`;

Expand Down
20 changes: 10 additions & 10 deletions src/helpers/customLists.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ async function fetchHighPriority(router: RouterOptions): Promise<List> {
tasks,
members: [user._id],
owner: user._id
}).toObject();
}).toObject<List>();
list._id = 'highPriority';
list.id = 'highPriority';

return list;
}

Expand All @@ -73,9 +73,9 @@ async function fetchTomorrow(router: RouterOptions): Promise<List> {
tasks,
members: [user._id],
owner: user._id
}).toObject();
}).toObject<List>();
list._id = 'tomorrow';
list.id = 'tomorrow';

return list;
}

Expand All @@ -89,9 +89,9 @@ async function fetchWeek(router: RouterOptions): Promise<List> {
tasks,
members: [user._id],
owner: user._id
}).toObject();
}).toObject<List>();
list._id = 'week';
list.id = 'week';

return list;
}

Expand All @@ -105,9 +105,9 @@ async function fetchOverdue(router: RouterOptions): Promise<List> {
tasks,
members: [user._id],
owner: user._id
}).toObject();
}).toObject<List>();
list._id = 'overdue';
list.id = 'overdue';

return list;
}

Expand All @@ -121,9 +121,9 @@ async function fetchToday(router: RouterOptions): Promise<List> {
completedTasks,
members: [user._id],
owner: user._id
}).toObject();
}).toObject<List>();
list._id = 'today';
list.id = 'today';

return list;
}

Expand Down
2 changes: 1 addition & 1 deletion src/schemas/lists.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Task, TaskDocument } from './tasks';
import { throwError } from '../helpers/errorHandler';

export interface List {
_id: ObjectId;
_id: ObjectId | string;
title: string;
tasks: Array<PopulatedDoc<TaskDocument>>;
completedTasks: Array<string>;
Expand Down
8 changes: 5 additions & 3 deletions test/global-setup.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
// @ts-expect-error: not bothering adding typing for setup file for this package
import jestMongoSetup from '@shelf/jest-mongodb/setup';
import jestMongoSetup from '@shelf/jest-mongodb/lib/setup';

export default async (): Promise<void> => {
process.env.TZ = 'America/Edmonton';
await jestMongoSetup();
// @ts-expect-error dsas
await jestMongoSetup({
rootDir: process.cwd()
});
};
30 changes: 11 additions & 19 deletions test/lists.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ describe('Lists', () => {

test('Provides clear error messages when invalid data provided', async () => {
const router = await createRouter();
await expect(createList({ title: '' }, router)).rejects.toThrowError(
await expect(createList({ title: '' }, router)).rejects.toThrow(
`List validation failed: title: Path \`title\` is required.`
);
});
Expand All @@ -66,14 +66,14 @@ describe('Lists', () => {
const list = await createList({ title: 'Good List' }, userRequest1);
await expect(
updateList(list._id, { title: 'Malicious List' }, userRequest2)
).rejects.toThrowError('Invalid List ID');
).rejects.toThrow('Invalid List ID');
});

test('Protects against fetching invalid list ID', async () => {
const router = await createRouter();
await expect(
createTask('INVALID_ID', { title: 'Good List' }, router)
).rejects.toThrowError('Invalid List ID');
await expect(createTask('INVALID_ID', { title: 'Good List' }, router)).rejects.toThrow(
'Invalid List ID'
);
});

test('Allows list to be modified', async () => {
Expand Down Expand Up @@ -128,18 +128,14 @@ describe('Lists', () => {
const userRequest1 = await createRouter();
const userRequest2 = await createRouter();
const list = await createList({ title: 'Good List' }, userRequest1);
await expect(getLists(list._id, {}, userRequest2)).rejects.toThrowError(
'Invalid List ID'
);
await expect(getLists(list._id, {}, userRequest2)).rejects.toThrow('Invalid List ID');
});

test('Protects against non-member deletion', async () => {
const userRequest1 = await createRouter();
const userRequest2 = await createRouter();
const list = await createList({ title: 'Good List' }, userRequest1);
await expect(deleteList(list._id, userRequest2)).rejects.toThrowError(
'Invalid List ID'
);
await expect(deleteList(list._id, userRequest2)).rejects.toThrow('Invalid List ID');
});

test('Allows members to be added to list', async () => {
Expand All @@ -165,9 +161,7 @@ describe('Lists', () => {
await updateList(list._id, { members: [user1._id, user2._id] }, userRequest1);
await expect(
updateList(list._id, { members: [user2._id] }, userRequest2)
).rejects.toThrowError(
'List validation failed: members: Not permitted to remove owner!'
);
).rejects.toThrow('List validation failed: members: Not permitted to remove owner!');
});

test('Allows lists tasks to be reordered', async () => {
Expand Down Expand Up @@ -208,7 +202,7 @@ describe('Lists', () => {
{ tasks: [badTask._id.toString(), task1._id.toString()] },
router
)
).rejects.toThrowError('Invalid modification of tasks');
).rejects.toThrow('Invalid modification of tasks');
const list: List = await getLists(newList._id, {}, router);
expect(list?.tasks).toHaveLength(2);
expect(list?.tasks[1]._id).toMatchId(task1._id);
Expand All @@ -220,7 +214,7 @@ describe('Lists', () => {
const newList = await createList({ title: 'Test' }, router);
const task1 = (await createTask(newList._id, { title: 'Good Task' }, router))._id;
const task2 = (await createTask(newList._id, { title: 'Good Task' }, router))._id;
await expect(updateList(newList._id, { tasks: [task2] }, router)).rejects.toThrowError(
await expect(updateList(newList._id, { tasks: [task2] }, router)).rejects.toThrow(
'Invalid modification of tasks'
);
const list = await getLists(newList._id, {}, router);
Expand All @@ -240,9 +234,7 @@ describe('Lists', () => {
);
}
for (const color of badColors) {
await expect(createList({ title: 'test', color }, props)).rejects.toThrowError(
/hex/
);
await expect(createList({ title: 'test', color }, props)).rejects.toThrow(/hex/);
}
});
});
Expand Down
18 changes: 9 additions & 9 deletions test/notifier.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,20 @@ describe('Notifier', () => {
describe('User', () => {
test('tweaks user.isPushEnabled', async () => {
const router = await createRouter();
expect(router.notifier.send).not.toBeCalled();
expect(router.notifier.send).not.toHaveBeenCalled();
await updateUser({ isPushEnabled: false }, router);
expect(router.notifier.send).toBeCalledTimes(1);
expect(router.notifier.send).toHaveBeenCalledTimes(1);
const payload = (router.notifier.send as jest.Mock).mock.calls[0];
expect(payload[0]).toBe(router.user._id);
expect(payload[1].title).toBe("You're subscribed!");
});

test('tweaks user.pushSubscription', async () => {
const router = await createRouter();
expect(router.notifier.send).not.toBeCalled();
expect(router.notifier.send).not.toHaveBeenCalled();
const fakeSubscription = `${Math.random()}`;
await updateUser({ pushSubscription: fakeSubscription }, router);
expect(router.notifier.send).toBeCalledTimes(1);
expect(router.notifier.send).toHaveBeenCalledTimes(1);
const payload = (router.notifier.send as jest.Mock).mock.calls[0];
expect(payload[0]).toBe(router.user._id);
expect(payload[1].title).toBe("You're subscribed!");
Expand All @@ -60,16 +60,16 @@ describe('Notifier', () => {
});

test('adds task', async () => {
expect(user1?.notifier.send).toBeCalledTimes(0);
expect(user1?.notifier.send).toHaveBeenCalledTimes(0);
await createTask(sharedList._id, { title: 'just do it' }, user1);
expect(user1?.notifier.send).toBeCalledTimes(1);
expect(user1?.notifier.send).toHaveBeenCalledTimes(1);
const payload = (user1?.notifier.send as jest.Mock).mock.calls[0];
expect(payload[0]).toMatchObject(user2?.user._id);
expect(payload[1].title).toBe('unitTest added just do it to shared list.');
});

test('marks task completed', async () => {
expect(user1?.notifier.send).toBeCalledTimes(0);
expect(user1?.notifier.send).toHaveBeenCalledTimes(0);
const task = await createTask(sharedList._id, { title: 'just do it' }, user1);
// reset notification from creation
(user1?.notifier.send as jest.Mock).mockReset();
Expand All @@ -80,7 +80,7 @@ describe('Notifier', () => {
});

test('updates task', async () => {
expect(user1?.notifier.send).toBeCalledTimes(0);
expect(user1?.notifier.send).toHaveBeenCalledTimes(0);
const task = await createTask(sharedList._id, { title: 'old' }, user1);
// reset notification from creation
(user1?.notifier.send as jest.Mock).mockReset();
Expand All @@ -91,7 +91,7 @@ describe('Notifier', () => {
});

test('deletes task', async () => {
expect(user1?.notifier.send).toBeCalledTimes(0);
expect(user1?.notifier.send).toHaveBeenCalledTimes(0);
const task = await createTask(sharedList._id, { title: 'just do it' }, user1);
// reset notification from creation
(user1?.notifier.send as jest.Mock).mockReset();
Expand Down

0 comments on commit 6ad79ae

Please sign in to comment.