This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The stage for e2e in the Jenkinsfile: | |
stage('E2E') { | |
steps { | |
script { | |
nodejs(your_jenkins_nodejs_plugin_config_options_here) { | |
try { | |
sh 'yarn start-server-and-script e2e:prod' | |
} catch (err) { | |
def specsToRetryFilePath = 'tmp/app-e2e/specs-to-retry.txt'; | |
// Don't retry if file doesn't exist which happens |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { enableProdMode, NgZone } from '@angular/core'; | |
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; | |
import { Router, NavigationStart } from '@angular/router'; | |
import { AppProps } from 'single-spa'; | |
import { | |
singleSpaAngular, | |
getSingleSpaExtraProviders, | |
} from 'single-spa-angular'; | |
import { AppModule } from './app/app.module'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { finalize, firstValueFrom, timeout } from 'rxjs'; | |
const KEEP_ALIVE_INTERVAL = 3 * 1000; | |
const KEEP_ALIVE_TIMEOUT = 2 * 60 * 1000; | |
export interface ErrorInHttpResponse { | |
errorMsg: string; | |
status: number; | |
name?: string; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// One-line console log/warn/error/info + Angular Material snackbar messages | |
// | |
// Example Usage: | |
// | |
// constructor(private notifySvc: NotifyService) {} | |
// | |
// Replaces: | |
// console.error(e); | |
// this.notifySvc.notify(e); | |
// |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Compact terminal output, colorized, with the following fields highlighted with | |
// brighter text for easier readability: request ID, request method, request URL, | |
// request Authorization header, response status code, and context which is usually | |
// a string passed when creating each logger object e.g. "SomeController". | |
import { Module } from '@nestjs/common'; | |
import { blackBright, inverse } from 'cli-color'; | |
import { pick } from 'lodash'; | |
import { LoggerModule } from 'nestjs-pino'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { join } from 'path'; | |
import { Module } from '@nestjs/common'; | |
import { ServeStaticModule } from '@nestjs/serve-static'; | |
import { replaceInFile } from 'replace-in-file'; | |
const STATIC_FILES_DIR = join(__dirname, 'client'); | |
const YOUR_GLOBAL_PREFIX = 'api'; // Typically imported from some other file | |
@Module({ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { ValidationPipe } from '@nestjs/common'; | |
import { NestFactory } from '@nestjs/core'; | |
import { ExpressAdapter } from '@nestjs/platform-express'; | |
import { urlencoded, json } from 'express'; | |
import { AppModule } from './app/app.module'; | |
(async () => { | |
const nestExpressAppAdapter = new ExpressAdapter(); | |
const app = await NestFactory.create(AppModule, nestExpressAppAdapter, {}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# This script is somewhat unsafe, but may be useful. This script deletes dependencies | |
# in package.json by deleting any lines that match | |
# the regexp in the grep, runs yarn install --prod, and then reverts package.json and | |
# yarn.lock back to their original contents. | |
# | |
# This script assumes yarn 1.x, i.e. yarn classic. If using npm instead of yarn 1.x: | |
# 1. Replace "yarn.lock" with "package-lock.json" | |
# 2. Replace "yarn install --prod" with "npm install --only=prod" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// JavaScript String Compression of Filenames in a URL | |
// | |
// Problem: Reduce length of URL caused by storing a list of long filenames in URL query parameter. | |
// | |
// Solution: Switch between a 5-bit alphabet of letters and 4-bit alphabet of numbers. Use a special | |
// character to switch between lowercase and uppercase ("shift"). Represent the resulting bit | |
// string as a URL-safe base62 encoded string. | |
// | |
// Results: From my test set of ~100 strings from real filenames on a project: | |
// avg compression ratio: 0.87 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Cypress.Commands.add( | |
'dragDrop', | |
{ prevSubject: false }, | |
(selector: string, originIdx: number, destIdx: number) => { | |
// Based on https://stackoverflow.com/a/55436989 | |
const elements = Cypress.$(selector); | |
[originIdx, destIdx].forEach((idx) => { | |
if (originIdx < 0 || originIdx >= elements.length) { | |
throw Error( | |
`Cannot index element ${idx} of ${elements.length} draggable elements.`, |
NewerOlder