Skip to content

Commit

Permalink
Refactoring and Redundant Files Removal
Browse files Browse the repository at this point in the history
  • Loading branch information
GuilhermeF03 committed Mar 26, 2024
1 parent 8a80233 commit 3eb45bd
Show file tree
Hide file tree
Showing 49 changed files with 51 additions and 42 deletions.
4 changes: 2 additions & 2 deletions code/client/dev-dist/sw.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ if (!self.define) {
});
};
}
define(['./workbox-fda11f75'], (function (workbox) { 'use strict';
define(['./workbox-a0f72815'], (function (workbox) { 'use strict';

self.skipWaiting();
workbox.clientsClaim();
Expand All @@ -82,7 +82,7 @@ define(['./workbox-fda11f75'], (function (workbox) { 'use strict';
"revision": "3ca0b8505b4bec776b69afdba2768812"
}, {
"url": "index.html",
"revision": "0.m5gr4j769k"
"revision": "0.3hobnoep3ho"
}], {});
workbox.cleanupOutdatedCaches();
workbox.registerRoute(new workbox.NavigationRoute(workbox.createHandlerBoundToURL("index.html"), {
Expand Down
12 changes: 0 additions & 12 deletions code/client/jest.config.js

This file was deleted.

12 changes: 6 additions & 6 deletions code/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@
"devDependencies": {
"@types/lodash": "^4.17.0",
"@types/node": "^20.11.30",
"@types/react": "^18.2.67",
"@types/react": "^18.2.70",
"@types/react-dom": "^18.2.22",
"@types/react-router-dom": "^5.3.3",
"@typescript-eslint/eslint-plugin": "^7.3.1",
"@typescript-eslint/parser": "^7.3.1",
"@typescript-eslint/eslint-plugin": "^7.4.0",
"@typescript-eslint/parser": "^7.4.0",
"@vite-pwa/assets-generator": "^0.2.4",
"@vitejs/plugin-react": "^4.2.1",
"@vitest/coverage-v8": "^1.4.0",
Expand All @@ -47,12 +47,12 @@
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.4.6",
"jsdom": "^24.0.0",
"knip": "^5.2.2",
"knip": "^5.5.0",
"prettier": "^3.2.5",
"sass": "^1.72.0",
"typescript": "^5.4.3",
"vite": "^5.2.3",
"vite-plugin-pwa": "^0.19.6",
"vite": "^5.2.6",
"vite-plugin-pwa": "^0.19.7",
"vite-tsconfig-paths": "^4.3.2",
"vitest": "^1.4.0"
},
Expand Down
4 changes: 2 additions & 2 deletions code/client/src/editor/crdt/fugue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import { type Node, type Id } from '@notespace/shared/crdt/types/nodes';
import { type Style } from '@notespace/shared/crdt/types/styles';
import { FugueTree } from '@notespace/shared/crdt/FugueTree';
import { generateReplicaId } from './utils';
import { socket } from '@src/socket/socket';
import { socket } from '@src/socket.io/socket';
import { type InsertNode } from '@editor/crdt/types';
import { Cursor, Selection } from '@editor/slate/model/cursor';
import { Cursor, Selection } from '@editor/slate.js/model/cursor';
import { isEmpty, isEqual } from 'lodash';

/**
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion code/client/tests/editor/crdt/fugue.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Fugue } from '@editor/crdt/fugue';
import { InsertOperation, DeleteOperation } from '@notespace/shared/crdt/types';
import { Selection, Cursor } from '@editor/slate/model/cursor';
import { Selection, Cursor } from '@editor/slate.js/model/cursor';
import { InsertNode } from '@editor/crdt/types';
import { describe, it, expect, beforeEach } from 'vitest';

Expand Down
11 changes: 10 additions & 1 deletion code/server/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,15 @@ module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
transform: {},
moduleNameMapper: pathsToModuleNameMapper({ '@src/*': ['./src/*'] }, { prefix: '<rootDir>/' }),
moduleNameMapper: pathsToModuleNameMapper({
/*Controllers*/
"@controllers/*": ["./src/controllers/*"],
/*Databases*/
"@database/*": ["./src/database/*"],
/*Others*/
'@src/*': ['./src/*'],
"@domain/*": ["./src/domain/*"],
"@services/*": ["./src/services/*"],
}, { prefix: '<rootDir>/' }),
transformIgnorePatterns: ['/node_modules/(?!@notespace/shared).+\\.js$'],
};
8 changes: 4 additions & 4 deletions code/server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"@notespace/shared": "file:..\\shared",
"cors": "^2.8.5",
"dotenv": "^16.4.5",
"express": "^4.19.1",
"express": "^4.19.2",
"firebase-admin": "^12.0.0",
"lodash": "^4.17.21",
"socket.io": "^4.7.5",
Expand All @@ -31,12 +31,12 @@
"@types/lodash": "^4.17.0",
"@types/node": "^20.11.30",
"@types/supertest": "^6.0.2",
"@typescript-eslint/eslint-plugin": "^7.3.1",
"@typescript-eslint/parser": "^7.3.1",
"@typescript-eslint/eslint-plugin": "^7.4.0",
"@typescript-eslint/parser": "^7.4.0",
"babel-jest": "^29.7.0",
"eslint": "^8.57.0",
"jest": "^29.7.0",
"knip": "^5.2.2",
"knip": "^5.5.0",
"prettier": "^3.2.5",
"socket.io-client": "^4.7.5",
"test-jest": "^1.0.1",
Expand Down
4 changes: 2 additions & 2 deletions code/server/src/controllers/http/router.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import express from 'express';
import { DocumentService } from '@src/types';
import getDocument from '@src/controllers/http/document/getDocument';
import deleteDocument from '@src/controllers/http/document/deleteDocument';
import getDocument from '@controllers/http/document/getDocument';
import deleteDocument from '@controllers/http/document/deleteDocument';

export default function (service: DocumentService) {
if (!service) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Socket } from 'socket.io';
import { DocumentService } from '@src/types';
import { Operation } from 'shared/crdt/types/operations';
import { Operation } from '@notespace/shared/crdt/types/operations';

function onOperation(service: DocumentService) {
return (socket: Socket, operation: Operation) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import onOperation from '@src/controllers/socket/document/onOperation';
import onCursorChange from '@src/controllers/socket/document/onCursorChange';
import onOperation from '@controllers/socket.io/document/onOperation';
import onCursorChange from '@controllers/socket.io/document/onCursorChange';
import { DocumentService, SocketHandler } from '@src/types';

export default function events(service: DocumentService): Record<string, SocketHandler> {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import { Socket } from 'socket.io';
import { DocumentService, SocketHandler } from '@src/types';

/**
* Returns a connection handler for socket.io
* @param service
* @param events
*/
function onConnection(service: DocumentService, events: Record<string, SocketHandler>) {
return async (socket: Socket) => {
console.log('a client connected');
Expand Down
2 changes: 1 addition & 1 deletion code/server/src/database/firestore/operations.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { InsertOperation, DeleteOperation, StyleOperation } from '@notespace/shared/crdt/types/operations';
import { getTreeInstance, setDocument, updateTree } from '@src/database/firestore/firestore';
import { getTreeInstance, setDocument, updateTree } from '@databases/firestore/firestore';

async function getTree() {
const tree = await getTreeInstance();
Expand Down
8 changes: 4 additions & 4 deletions code/server/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import http from 'http';
import { Server } from 'socket.io';
import { config } from 'dotenv';
import cors from 'cors';
import serviceInit from './services/documentService';
import eventsInit from './controllers/socket/events';
import database from './database/memory/operations';
import serviceInit from '@services/documentService';
import eventsInit from '@controllers/socket.io/events';
import database from '@database/memory/operations';
import router from '@src/controllers/http/router';
import onConnection from '@src/controllers/socket/onConnection';
import onConnection from '@controllers/socket.io/onConnection';

config();
const PORT = process.env.PORT || 8080;
Expand Down
9 changes: 8 additions & 1 deletion code/server/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,14 @@
"downlevelIteration": true,
"baseUrl": "../",
"paths": {
"@src/*": ["./server/src/*"]
/*Controllers*/
"@controllers/*": ["./server/src/controllers/*"],
/*Databases*/
"@database/*": ["./server/src/database/*"],
/*Others*/
"@src/*": ["./server/src/*"],
"@domain/*": ["./server/src/domain/*"],
"@services/*": ["./server/src/services/*"],
}
},
"include": ["src/**/*"],
Expand Down
6 changes: 3 additions & 3 deletions code/shared/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
"devDependencies": {
"@types/lodash": "^4.17.0",
"@types/node": "^20.11.30",
"@typescript-eslint/eslint-plugin": "^7.3.1",
"@typescript-eslint/parser": "^7.3.1",
"@typescript-eslint/eslint-plugin": "^7.4.0",
"@typescript-eslint/parser": "^7.4.0",
"eslint": "^8.57.0",
"knip": "^5.2.2",
"knip": "^5.5.0",
"prettier": "^3.2.5",
"typescript": "^5.4.3"
},
Expand Down

0 comments on commit 3eb45bd

Please sign in to comment.