This file contains hidden or 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
// basic stream handling (keeping it manual so pipeline doesn't automatically close the response) | |
const http = require("http"); | |
const fs = require("fs"); | |
const { Transform, PassThrough } = require("stream"); | |
const { finished } = require("stream/promises"); | |
const createUpperCaseTransform = () => { | |
return new Transform({ | |
transform(chunk, encoding, callback) { | |
// callback(null, chunk.toString().toUpperCase()); |
This file contains hidden or 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
version: '3.8' | |
services: | |
db: | |
container_name: pg_container | |
image: postgres | |
restart: always | |
environment: | |
POSTGRES_USER: root | |
POSTGRES_PASSWORD: root | |
POSTGRES_DB: postgres |
This file contains hidden or 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
export const dynamicImport = (packageName: string) => | |
new Function(`return import('${packageName}');`)(); |
This file contains hidden or 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
// @experimentalDecorators | |
// @emitDecoratorMetadata | |
// use a more elegant cache in prod - something like node-cache or another cache | |
// this is a simplified example - for simplicity after the first method call we will simply set it to true. | |
// We also will not implement the cache expiration for simplicity. | |
// also note this is for cached aggregation of data that doesn't change, not "multi-tenant" data | |
let cacheObject: any = null; |
This file contains hidden or 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
const configKeys = [ | |
"NODE_ENV", | |
"PORT", | |
"SECRET1", | |
"SECRET2", | |
"SECRET3", | |
"ASYNC_SECRET", | |
] as const; | |
export type AppConfig = { |
This file contains hidden or 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
FROM node:12-alpine as local-dev | |
EXPOSE 3001 | |
RUN mkdir -p /app | |
WORKDIR /app | |
COPY *.json ./ | |
RUN npm install | |
COPY . /app | |
RUN npm run build | |
CMD ["npm", "run", "start:watch"] |
This file contains hidden or 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
const fs = require('fs'); | |
const cp = require('child_process'); | |
const util = require('util'); | |
const path = require('path'); | |
const exec = util.promisify(cp.exec); | |
const writeFile = util.promisify(fs.writeFile); | |
const prettierConfigVscode = { | |
'editor.codeActionsOnSave': { |
This file contains hidden or 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
FROM node:10-alpine AS build | |
# install gyp tools | |
# if you have an npm dependency that depends on native code | |
# like the redis package, you'll need these tools to compile | |
# that dependency | |
RUN apk add --update --no-cache \ | |
python \ | |
make \ | |
g++ |