Skip to content

Commit 094f7e0

Browse files
authored
Merge pull request #62 from Wavely-project/major-refactor
refactor(all): majorrr
2 parents d89d2a5 + d14c68b commit 094f7e0

File tree

74 files changed

+1431
-684
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+1431
-684
lines changed

.eslintrc.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@
99
"sourceType": "module"
1010
},
1111
"plugins": ["@typescript-eslint", "simple-import-sort", "prettier"],
12-
"extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended", "prettier"],
12+
"extends": [
13+
"eslint:recommended",
14+
"plugin:@typescript-eslint/recommended",
15+
"prettier"
16+
],
1317
"rules": {
1418
"@typescript-eslint/no-explicit-any": "off",
1519
"simple-import-sort/imports": "error",

.prettierrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"trailingComma": "es5",
33
"tabWidth": 4,
4-
"printWidth": 120,
4+
"printWidth": 80,
55
"singleQuote": true,
66
"semi": true,
77
"useTabs": true

db/migrations/20240409163927_create_users_table.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,19 @@ export async function up(knex: Knex): Promise<void> {
2525
table.string('password').notNullable();
2626
table.string('bio');
2727
table.string('avatarUrl');
28-
table.enum('status', ['online', 'offline', 'away']).defaultTo('offline');
29-
table.timestamps(true, true, true);
28+
table
29+
.enum('status', ['online', 'offline', 'away'])
30+
.defaultTo('offline');
31+
table
32+
.dateTime('createdAt')
33+
.notNullable()
34+
.defaultTo(knex.raw('CURRENT_TIMESTAMP'));
35+
table
36+
.dateTime('updatedAt')
37+
.notNullable()
38+
.defaultTo(
39+
knex.raw('CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP')
40+
);
3041
});
3142
}
3243

db/migrations/20240412000348_add_workspace_table.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,18 @@ export async function up(knex: Knex): Promise<void> {
88
table.string('avatarUrl');
99
table.integer('ownerId').unsigned();
1010
table.foreign('ownerId').references('id').inTable('users');
11-
table.timestamps(true, true, true);
11+
12+
table
13+
.dateTime('createdAt')
14+
.notNullable()
15+
.defaultTo(knex.raw('CURRENT_TIMESTAMP'));
16+
17+
table
18+
.dateTime('updatedAt')
19+
.notNullable()
20+
.defaultTo(
21+
knex.raw('CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP')
22+
);
1223
});
1324
}
1425

db/migrations/20240412002911_add_channel_table.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,18 @@ export async function up(knex: Knex): Promise<void> {
2626
table.integer('creatorId').unsigned();
2727
table.integer('workspaceId').unsigned();
2828

29-
//TODO: add this to another migrationFile
3029
table.foreign('creatorId').references('id').inTable('users');
3130
table.foreign('workspaceId').references('id').inTable('workspaces');
32-
table.timestamps(true, true, true);
31+
table
32+
.dateTime('createdAt')
33+
.notNullable()
34+
.defaultTo(knex.raw('CURRENT_TIMESTAMP'));
35+
table
36+
.dateTime('updatedAt')
37+
.notNullable()
38+
.defaultTo(
39+
knex.raw('CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP')
40+
);
3341
});
3442
}
3543

db/migrations/20240412002952_add_messages_table.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,16 @@ export async function up(knex: Knex): Promise<void> {
2929
table.foreign('senderId').references('id').inTable('users');
3030
table.foreign('channelId').references('id').inTable('channels');
3131
table.foreign('parentMessageId').references('id').inTable('messages');
32-
33-
table.timestamps(true, true, true);
32+
table
33+
.dateTime('createdAt')
34+
.notNullable()
35+
.defaultTo(knex.raw('CURRENT_TIMESTAMP'));
36+
table
37+
.dateTime('updatedAt')
38+
.notNullable()
39+
.defaultTo(
40+
knex.raw('CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP')
41+
);
3442
});
3543
}
3644

db/migrations/20240412003023_add_invites_table.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,25 @@ export async function up(knex: Knex): Promise<void> {
2323
table.integer('senderId').unsigned();
2424
table.integer('inviteeId').unsigned();
2525

26-
table.timestamps(true, true, true);
2726
table.timestamp('expiresAt').notNullable();
28-
table.enum('status', ['pending', 'accepted', 'cancelled']).defaultTo('pending');
27+
table
28+
.enum('status', ['pending', 'accepted', 'cancelled'])
29+
.defaultTo('pending');
2930

3031
// TODO: add this to another migrationFile
3132
table.foreign('workspaceId').references('id').inTable('workspaces');
3233
table.foreign('inviteeId').references('id').inTable('users');
3334
table.foreign('senderId').references('id').inTable('users');
35+
table
36+
.dateTime('createdAt')
37+
.notNullable()
38+
.defaultTo(knex.raw('CURRENT_TIMESTAMP'));
39+
table
40+
.dateTime('updatedAt')
41+
.notNullable()
42+
.defaultTo(
43+
knex.raw('CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP')
44+
);
3445
});
3546
}
3647

db/migrations/20240412003051_add_notification_table.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import type { Knex } from 'knex';
1414
notifications.message_id < messages.id
1515
*/
1616

17-
//TODO: fix related repo and stuff.
17+
//TODO: fix related repo and stuff, also add URL.
1818
export async function up(knex: Knex): Promise<void> {
1919
await knex.schema.createTable('notifications', (table) => {
2020
table.increments('id').primary();

db/seeds/01-userSeeding.ts

Lines changed: 42 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,47 @@ export async function seed(knex: Knex): Promise<void> {
88

99
// Inserts seed entries
1010
await Promise.all([
11-
EntityFactory.createUser(1, 'user 1', '[email protected]', 'Test User 1', 'password'),
12-
EntityFactory.createUser(2, 'user 2', '[email protected]', 'Test User 2', 'password'),
13-
EntityFactory.createUser(3, 'user 3', '[email protected]', 'Test User 3', 'password'),
14-
EntityFactory.createUser(4, 'user 4', '[email protected]', 'Test User 4', 'password'),
15-
EntityFactory.createUser(5, 'user 5', '[email protected]', 'Test User 5', 'password'),
16-
EntityFactory.createUser(6, 'user 6', '[email protected]', 'Test User 6', 'password'),
11+
EntityFactory.createUser(
12+
1,
13+
'user 1',
14+
15+
'Test User 1',
16+
'password'
17+
),
18+
EntityFactory.createUser(
19+
2,
20+
'user 2',
21+
22+
'Test User 2',
23+
'password'
24+
),
25+
EntityFactory.createUser(
26+
3,
27+
'user 3',
28+
29+
'Test User 3',
30+
'password'
31+
),
32+
EntityFactory.createUser(
33+
4,
34+
'user 4',
35+
36+
'Test User 4',
37+
'password'
38+
),
39+
EntityFactory.createUser(
40+
5,
41+
'user 5',
42+
43+
'Test User 5',
44+
'password'
45+
),
46+
EntityFactory.createUser(
47+
6,
48+
'user 6',
49+
50+
'Test User 6',
51+
'password'
52+
),
1753
]);
1854
}

db/seeds/02-workspaceSeeding.ts

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,40 @@ export async function seed(knex: Knex): Promise<void> {
1515
* */
1616

1717
await Promise.all([
18-
EntityFactory.createWorkspace(1, 1, 'workspace 1', 'Descrcription', 'url'),
19-
EntityFactory.createWorkspace(2, 1, 'workspace 2', 'Descrcription', 'url'),
20-
EntityFactory.createWorkspace(3, 6, 'workspace 3', 'Descrcription', 'url'),
21-
EntityFactory.createWorkspace(4, 2, 'workspace 4', 'Descrcription', 'url'),
22-
EntityFactory.createWorkspace(5, 5, 'workspace 5', 'Descrcription', 'url'),
18+
EntityFactory.createWorkspace(
19+
1,
20+
1,
21+
'workspace 1',
22+
'Descrcription',
23+
'url'
24+
),
25+
EntityFactory.createWorkspace(
26+
2,
27+
1,
28+
'workspace 2',
29+
'Descrcription',
30+
'url'
31+
),
32+
EntityFactory.createWorkspace(
33+
3,
34+
6,
35+
'workspace 3',
36+
'Descrcription',
37+
'url'
38+
),
39+
EntityFactory.createWorkspace(
40+
4,
41+
2,
42+
'workspace 4',
43+
'Descrcription',
44+
'url'
45+
),
46+
EntityFactory.createWorkspace(
47+
5,
48+
5,
49+
'workspace 5',
50+
'Descrcription',
51+
'url'
52+
),
2353
]);
2454
}

0 commit comments

Comments
 (0)