feat: creates backend for the project
This commit is contained in:
18
backend/src/utils.ts
Normal file
18
backend/src/utils.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import { Request, Response, NextFunction } from 'express';
|
||||
|
||||
export function maskAccountNumber(num: string): string {
|
||||
if (num.length <= 10) return num;
|
||||
return num.slice(0, 6) + '*'.repeat(num.length - 10) + num.slice(-4);
|
||||
}
|
||||
|
||||
export function escapeLike(input: string): string {
|
||||
return input.replace(/\\/g, '\\\\').replace(/%/g, '\\%').replace(/_/g, '\\_');
|
||||
}
|
||||
|
||||
type AsyncHandler = (req: Request, res: Response, next: NextFunction) => Promise<void>;
|
||||
|
||||
export function asyncHandler(fn: AsyncHandler) {
|
||||
return (req: Request, res: Response, next: NextFunction) => {
|
||||
fn(req, res, next).catch(next);
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user