Skip to content

Instantly share code, notes, and snippets.

View GoodnessEzeokafor's full-sized avatar
🏠
Working from home

Ezeokafor GoodnessEzeokafor

🏠
Working from home
View GitHub Profile
@GoodnessEzeokafor
GoodnessEzeokafor / upload.html
Created January 10, 2025 10:23
Multipart File Upload
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Video Upload</title>
</head>
<body>
@GoodnessEzeokafor
GoodnessEzeokafor / index.html
Created January 2, 2025 15:49
Multipart Upload
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Video Upload</title>
</head>
<body>
import * as twilio from 'twilio';
import { Injectable } from '@nestjs/common';
import { ResponseUtilsService } from 'src/services/utils-service';
import {
TWILIO_ACCOUNT_SID,
TWILIO_AUTH_TOKEN,
TWILIO_SANDBOX_NUMBER,
} from 'src/core';
@Injectable()
@GoodnessEzeokafor
GoodnessEzeokafor / factory.ts
Created November 13, 2024 11:46
Refactoring my transaction factory service
@Injectable()
export class TransactionFactoryServices {
constructor(public readonly dbUtils: DatabaseUtilsService) {}
private mapProperty(source: any, target: any, propertyName: string): void {
if (source[propertyName]) {
target[propertyName] = source[propertyName];
}
}
import { Injectable, OnApplicationShutdown } from '@nestjs/common';
import { FeedbackFactoryServices } from './feedback-factory.service';
import { DataSource } from 'typeorm';
import { IDatabaseServices } from 'src/core';
@Injectable()
export class FeedbackServices implements OnApplicationShutdown {
constructor(
private readonly data: IDatabaseServices,
private readonly factory: FeedbackFactoryServices,
@GoodnessEzeokafor
GoodnessEzeokafor / abstraction.ts
Created September 15, 2024 13:07
clean-code architecture
/** generic repository */
/* eslint-disable @typescript-eslint/no-unused-vars */
import { Model } from 'sequelize';
import { IGenericRepository } from 'src/core';
export class SequelizeGenericRepository<T extends Model>
implements IGenericRepository<T>
{
private model: any;
/**
* gets the userId
* creates a redis key(identifier)
* checks if the key exists
* returns the data instead
*/
const redisKey = `transactions-v3-${userId}-${JSON.stringify(payload)}`;
const redisValue = await this.cache.get(redisKey);
if (redisValue) {
const { data, pagination } =
await this.data.transactions.findAllWithPagination(
{
...filterQuery,
isRevenue: false,
reconTransactionType: Not(In(excludedTransactionType)),
},
{
relationFields: ['user'],
selectFields: this.selectFields,
@GoodnessEzeokafor
GoodnessEzeokafor / db-select.ts
Created September 15, 2024 10:32
Select technique
const selectFields = [
'id',
'currency',
'currencyType',
'amount',
'type',
'reference',
'description',
'status',
// Use @UploadedFile() when uploading a single file/video/image
@Post('/upload-file')
@UseInterceptors(FileInterceptor('video'))
async createCheckedIn(
@UploadedFile() file: Express.Multer.File,
@Res() res: Response,
) {}
// use @UploadedFiles() when uploading multiple file/video/images