Skip to content

Instantly share code, notes, and snippets.

@mutableideas
mutableideas / broken-request-context.ts
Last active July 16, 2025 18:50
DbConnection Factory Scope Fun
import { Inject, Injectable, Type } from '@nestjs/common';
import { ContextIdFactory, ModuleRef, REQUEST } from '@nestjs/core';
import { ChannelType } from '@social-sprinkler/social-common';
import { Request } from 'express';
import { IPublisher } from './publisher.interface';
import { SOCIAL_CHANNEL_PUBLISHER_SERVICE } from './const';
@Injectable()
export class SocialPublisherFactory {
@Inject()
@mutableideas
mutableideas / claims.directive.ts
Last active June 1, 2024 12:47
Angular SSR - Platform Provider Pattern
import { Directive, Input, TemplateRef, ViewContainerRef, inject } from '@angular/core';
import { Claims, RolesEnum } from '@org/platform-provider-pattern/domain';
import { jwtClaimsService } from '@org/platform-provider-pattern/ui/data-access';
@Directive({
selector: '[orgClaims]',
standalone: true,
})
export class ClaimsDirective {
protected jwtClaimsService = jwtClaimsService();
@mutableideas
mutableideas / cloud-task-emulator-start.sh
Last active April 27, 2024 12:52
Google Cloud Tasks / NestJs / Local Setup
# {{DIRECTORY_WITH_EMULATOR}}/cloud-tasks-emulator
# -host localhost \
# -port {{PORT}}
# -queue
# projects/{{PROJECT_NAME}}/locations/{{LOCATION}}/queues/{{QUEUE_NAME}}
./tools/emulators/cloud-tasks-emulator
-host localhost \
-port 8123 \
-queue projects/dev/locations/global/queues/test
@mutableideas
mutableideas / .dockerignore
Last active December 8, 2023 17:20
Nx Executor for Building Docker Images
node_modules/
.env
.angular/
coverage/
@mutableideas
mutableideas / db-connection.factory.ts
Last active October 15, 2023 18:43
NestJs Lazily Transactions
import { PoolConnection } from 'promise-mysql';
import { SqlDbPoolService } from '../services/sql-db-pool.service';
export abstract class DbConnectionFactory {
private _connection: PoolConnection;
constructor(protected dbPool: SqlDbPoolService) { }
public async connection(): Promise<PoolConnection> {
this._connection = this._connection || await this.dbPool.createConnection();
import { Inject, Injectable } from '@nestjs/common';
import { KeyManagementServiceClient } from '@google-cloud/kms';
import { ENCRYPTION_CONFIG } from './const';
import { IKmsEncryptionConfig } from './interfaces';
import { IEncryptionService } from '@shared/security-encryption-common';
@Injectable()
export class GoogleKmsService implements IEncryptionService { // implements the IEncryptionService interface
private keyName: string;
@Injectable()
export class OrganizationEffects extends BaseEntityEffects<IOrganization> {
// Line 4 is marked as uncovered
constructor(protected service: OrganizationService) {
super(service, OrganizationActionTypes, OrganizationActionCreators);
}
}
@mutableideas
mutableideas / AppModule.module.ts
Last active July 29, 2022 21:55
Firebase Upload Component
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { AppComponent } from './app.component';
import { RouterModule, Routes } from '@angular/router';
import { AngularFireModule } from '@angular/fire/compat';
import { FirebaseOptions } from 'firebase/app';
import { environment } from '../environments/environment';
@mutableideas
mutableideas / subscribing.ts
Last active May 6, 2022 10:26
RxJs Tutorial - How to Use RxJs in Angular
import { interval } from 'rxjs';
interval(5000).subscribe({
// The next value pushed in the stream
next: (value: number) => {
console.log(`${value} in the stream`);
},
// Observable is done emitting values, callback when complete
complete: () => console.log('The stream has completed.'),
// An Error Occurred in the stream
@mutableideas
mutableideas / breadcrumb.html
Created April 16, 2022 14:36
Breadcrumb component
<div *ngLet="{ breadcrumbs: (breadcrumbs$| async) } as data"
[ngClass]="breadCrumbClass">
<div [ngClass]="crumbCssClass"
*ngFor="let crumb of data.breadcrumbs; let i = index; let isLast = last">
<ng-container
[ngTemplateOutlet]="itemTemplate"
[ngTemplateOutletContext]="{ $implicit: crumb, index: i, last: isLast, crumbLength: data.breadcrumbs.length }">
</ng-container>
</div>
</div>