{"id":15048052,"url":"https://github.com/mastprogs/custom-codes","last_synced_at":"2026-01-01T22:32:30.332Z","repository":{"id":47118042,"uuid":"431421326","full_name":"MastProgs/custom-codes","owner":"MastProgs","description":"필요에 의해서 직접 구현했던 몇몇 커스텀 코드 기록보관소","archived":false,"fork":false,"pushed_at":"2022-09-19T01:37:23.000Z","size":86,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-01-20T17:17:31.387Z","etag":null,"topics":["async","async-await","asynchronous","asynchronous-programming","cpp20","go","golang","http","mysql","mysql-database","redis","string","typeorm","typescript"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MastProgs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-11-24T09:26:42.000Z","updated_at":"2022-04-21T02:52:34.000Z","dependencies_parsed_at":"2023-01-18T13:40:26.933Z","dependency_job_id":null,"html_url":"https://github.com/MastProgs/custom-codes","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MastProgs%2Fcustom-codes","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MastProgs%2Fcustom-codes/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MastProgs%2Fcustom-codes/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MastProgs%2Fcustom-codes/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MastProgs","download_url":"https://codeload.github.com/MastProgs/custom-codes/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243489778,"owners_count":20298997,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["async","async-await","asynchronous","asynchronous-programming","cpp20","go","golang","http","mysql","mysql-database","redis","string","typeorm","typescript"],"created_at":"2024-09-24T21:07:32.210Z","updated_at":"2026-01-01T22:32:25.312Z","avatar_url":"https://github.com/MastProgs.png","language":"Go","readme":"# custom-codes\n\u003e 필요에 의해서 직접 구현했던 몇몇 커스텀 코드 기록보관소\n\n# 각 파일 설명\n\n## [**_DBJob.ts_**](https://github.com/MastProgs/custom-codes/blob/main/DBJob.ts)\n\u003e 각 DB 쿼리 및 Redis 요청을 하나의 job 으로 잡고, 여러 다수의 job 처리들을 하나의 트랜젝션 같이 runtime 서버 상에서 코드적으로 보장하는 핸들러 클래스.\n\u003e AddJob_DBMS 로 SQL Job 을 추가하고, AddJob_REDIS 로 Redis 요청을 추가하여, Run() 을 통해 각 요청들을 한 번에 편히 처리 가능.\n### 주의점\n1. typeORM 이 필요하다\n2. Run() 함수에서 await Promise.all() 함수는 최대 10개만 처리 가능하므로, 더 많은 job 을 처리해야하는 경우에는 커스텀이 필요하다. (하지만 10개의 job 이 넘어간다면 코드 구조가 잘못된거 아닐까?)\n### 사용예시\n```typescript\nlet dbjob = new DBJob()\n{\n    dbjob.AddJob_DBMS(EDBMS_COMMIT_TYPE.UPDATE, Profile, {\n        platformID: userProfileInfo.platformID\n    }, {\n        grade: userProfileInfo.grade + 1,\n        followings: userProfileInfo.followings + 1\n    })\n\n    dbjob.AddJob_DBMS(EDBMS_COMMIT_TYPE.UPDATE, Profile, {\n        platformID: targetUserProfileInfo.platformID\n    }, {\n        followers: targetUserProfileInfo.followers + 1\n    })\n\n    // rank dbms update\n    dbjob.AddJob_DBMS(EDBMS_COMMIT_TYPE.UPDATE, RankProfile, { platformID: targetUserProfileInfo.platformID }, { follow: targetUserProfileInfo.followers + 1 })\n\n    // #Notification\n    const notificationEntity = notificationInfo.toEntity()\n    dbjob.AddJob_DBMS(EDBMS_COMMIT_TYPE.SAVE, Notification, notificationEntity)\n\n    dbjob.AddJob_REDIS(Redis.Inst(ERedisIndex.FOLLOW).ZAddAsync, this.followingsRedis.GetRedisKey_Followings() + platformID, Number(currentUTCTime().format('YYYYMMDDHHMMSS')), targetPlatformID)\n    dbjob.AddJob_REDIS(Redis.Inst(ERedisIndex.FOLLOW).ZAddAsync, this.followingsRedis.GetRedisKey_Followers() + targetPlatformID, Number(currentUTCTime().format('YYYYMMDDHHMMSS')), platformID)\n\n    // Ranking redis follow\n    dbjob.AddJob_REDIS(Redis.Inst(ERedisIndex.RANK).ZAddAsync, this.rankService.GetRedisKey_Follow(), \"INCR\", 1, targetUserProfileInfo.platformID)\n}\nconst res = await dbjob.Run()\n```\n\n## [**_Pager.ts_**](https://github.com/MastProgs/custom-codes/blob/main/Pager.ts)\n\u003e 페이지네이션 기법을 조금 더 쉽게 활용할 수 있도록, 한 번 더 랩핑한 핸들러 클래스.\n\u003e 필요한 쿼리를 넣으면, hash pointer index 와 그에 대응대는 필요한 value 들을 반환 받을 수 있음.\n\n### 주의점\n1. typeORM 이 필요하다.\n2. pagination 이 필요하다.\n\n### 사용예시\n```typescript\npublic async GetNextMyNFTList(walletAddress: WALLET_ADDR[], afterCursor: string) {\n    let owner = this.create()\n    owner.nftSN = 0\n\n    let condition = []\n    walletAddress.forEach(e =\u003e {\n        condition.push({\n            walletAddress: e\n        })\n    })\n\n    if (1 \u003e condition.length) { return new PagerResult\u003cNFTOwner\u003e(undefined, \"\", true) }\n\n    let pager = new Pager(NFTOwner, Object.getOwnPropertyNames(owner), afterCursor, 50)\n    pager.SetQuery(this.createQueryBuilder(NFTOwner.name).where(condition))\n    return await pager.GetResult()\n}\n```\n\n## [**_Redis.ts_**](https://github.com/MastProgs/custom-codes/blob/main/Redis.ts)\n\u003e Redis 를 따로 클러스터링을 사용하지 않고, 각 redis index number DB 형태로 접근하여 사용하는 경우, 편하게 index 번호만 입력하여 redis 로 요청을 날릴 수 있는 핸들러 클래스.\n\n### 주의점\n1. redis 모듈이 필요하다.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmastprogs%2Fcustom-codes","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmastprogs%2Fcustom-codes","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmastprogs%2Fcustom-codes/lists"}