Skip to content

Commit

Permalink
Add Codeowners, organize logsremover, organize consts
Browse files Browse the repository at this point in the history
  • Loading branch information
fadihanna123 committed Oct 10, 2024
1 parent 37c93b1 commit 24d3e4c
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 44 deletions.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @fadihanna123
4 changes: 2 additions & 2 deletions src/controllers/addUser.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Response } from 'express';
import { users } from '../consts';
import { User, typedRequestBody } from '../types';
import { users } from '../utils/consts';
import { typedRequestBody, User } from 'types';

/**
* @author Fadi Hanna<[email protected]>
Expand Down
2 changes: 1 addition & 1 deletion src/controllers/deleteUser.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { User, typedRequestBody } from '../types';
import { users } from '../consts';
import { users } from '../utils/consts';
import { Response } from 'express';

/**
Expand Down
2 changes: 1 addition & 1 deletion src/controllers/getUsers.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { users } from '../consts';
import { users } from '../utils/consts';
import { User, typedRequestBody } from '../types';
import { Response } from 'express';

Expand Down
2 changes: 1 addition & 1 deletion src/controllers/updateUser.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { users } from '../consts';
import { users } from '../utils/consts';
import { User, typedRequestBody } from '../types';
import { Request, Response } from 'express';

Expand Down
33 changes: 0 additions & 33 deletions src/tasks/fileClenaer.ts

This file was deleted.

30 changes: 25 additions & 5 deletions src/tasks/logsRemover.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,34 @@
import { fileCleaner } from './fileClenaer';
import fs from 'fs';

/**
* @author Fadi Hanna<[email protected]>
*/

/**
* Clean log and error data in the database and call fileCleaner.
* Clean log and error files.
* @function logsRemover
* @async
* @returns { Promise<void> }
* @returns { void }
* @example logsRemover();
*/
export const logsRemover = async (): Promise<void> => fileCleaner();
export const logsRemover = (): void => {
const logsPath: string = './src/logs/debug.log';
const errorPath: string = './src/logs/error.log';
const newValue: string = '';

fs.promises
.readFile(logsPath)
.then(() => {
fs.promises.writeFile(errorPath, newValue).catch((err: Error) => {
if (err) {
throw err;
}

console.log('Done cleaning');
});
})
.catch((err: Error) => {
if (err) {
throw err;
}
});
};
3 changes: 2 additions & 1 deletion src/types/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Request } from 'express';

/**
* @author Fadi Hanna<[email protected]>
*/
Expand Down Expand Up @@ -28,4 +29,4 @@ interface typedRequestBody<T> extends Request {
body: T;
}

export { Routes, User, typedRequestBody };
export { User, typedRequestBody, Routes };
File renamed without changes.

0 comments on commit 24d3e4c

Please sign in to comment.