Last active
July 23, 2023 06:53
-
-
Save vdelacou/996f290aa5d108b55688229e15ff4b3b to your computer and use it in GitHub Desktop.
Revisions
-
vdelacou revised this gist
Apr 25, 2021 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,4 @@ import { sum } from './example'; describe('Calc', () => { test('should return 10 for add(6, 4)', () => { -
vdelacou revised this gist
Apr 25, 2021 . 6 changed files with 61 additions and 7 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -20,4 +20,10 @@ mkdir src curl -o src/example.ts https://gist.githubusercontent.com/vdelacou/996f290aa5d108b55688229e15ff4b3b/raw/example.ts curl -o .eslintrc.json https://gist.githubusercontent.com/vdelacou/996f290aa5d108b55688229e15ff4b3b/raw/.eslintrc.json curl -o tsconfig.json https://gist.githubusercontent.com/vdelacou/996f290aa5d108b55688229e15ff4b3b/raw/tsconfig.json npm install --save-dev jest @types/jest ts-jest curl -o jest.config.js https://gist.githubusercontent.com/vdelacou/996f290aa5d108b55688229e15ff4b3b/raw/jest.config.js mkdir src/lib curl -o src/lib/log.ts https://gist.githubusercontent.com/vdelacou/996f290aa5d108b55688229e15ff4b3b/raw/log.ts npx json -I -f package.json -e 'this.scripts={...this.scripts , "test": "jest" }' curl -o src/example.test.ts https://gist.githubusercontent.com/vdelacou/996f290aa5d108b55688229e15ff4b3b/raw/example.test.ts ``` 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,10 @@ import { sum } from './password'; describe('Calc', () => { test('should return 10 for add(6, 4)', () => { expect(sum(6, 4)).toBe(10); }); test('should return 9 for add(10, -1)', () => { expect(sum(10, -1)).toBe(9); }); }); 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 charactersOriginal file line number Diff line number Diff line change @@ -1,19 +1,23 @@ import { newLogger } from './lib/log'; const logger = newLogger('password'); export const sum = (a: number, b: number): number => { return a + b; }; const delay = (milliseconds: number, a: number, b: number): Promise<number> => { return new Promise((resolve) => { setTimeout(() => { resolve(sum(a, b)); }, milliseconds); }); }; (async () => { logger.info('Start'); const count = await delay(1000, 2, 6); logger.info(`End with count: ${count}`, { count }); })().catch((e) => { logger.error(e); }); 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 charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,3 @@ { "recommendations": ["dbaeumer.vscode-eslint", "esbenp.prettier-vscode", "editorconfig.editorconfig", "eamodio.gitlens", "orta.vscode-jest"] } 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,13 @@ module.exports = { roots: ['<rootDir>/src'], testMatch: ['**/__tests__/**/*.+(ts|js)', '**/?(*.)+(spec|test).+(ts|js)'], transform: { '^.+\\.(ts)$': 'ts-jest', }, collectCoverageFrom: ['**/*.{js,ts}', '!**/*.d.ts', '!**/node_modules/**'], globals: { 'ts-jest': { tsconfig: 'tsconfig.json', }, }, }; 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,21 @@ import winston from 'winston'; const { createLogger, format, transports } = winston; export const newLogger = (service: string): winston.Logger => { const logger = createLogger({ level: 'info', format: format.combine( format.timestamp({ format: 'YYYY-MM-DD HH:mm:ss', }), format.ms(), format.errors({ stack: true }), format.splat(), format.json() ), defaultMeta: { service }, transports: [new transports.Console()], }); return logger; }; -
vdelacou revised this gist
Apr 25, 2021 . 3 changed files with 37 additions and 4 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -6,8 +6,8 @@ curl -o .gitignore https://gist.githubusercontent.com/vdelacou/1954a25d720f702b4af011ba2773001b/raw/.gitignore curl -o .prettierrc https://gist.githubusercontent.com/vdelacou/58484f1c11af70aaa457f4e5c289e893/raw/.prettierrc mkdir .vscode curl -o .vscode/extensions.json https://gist.githubusercontent.com/vdelacou/996f290aa5d108b55688229e15ff4b3b/raw/extensions.json curl -o .vscode/settings.json https://gist.githubusercontent.com/vdelacou/996f290aa5d108b55688229e15ff4b3b/raw/settings.json curl -o .editorconfig https://gist.githubusercontent.com/vdelacou/58484f1c11af70aaa457f4e5c289e893/raw/.editorconfig npm install --save-dev typescript ts-node eslint @typescript-eslint/eslint-plugin @typescript-eslint/parser prettier eslint-config-prettier eslint-plugin-prettier npm install husky --save-dev @@ -21,5 +21,3 @@ curl -o src/example.ts https://gist.githubusercontent.com/vdelacou/996f290aa5d10 curl -o .eslintrc.json https://gist.githubusercontent.com/vdelacou/996f290aa5d108b55688229e15ff4b3b/raw/.eslintrc.json curl -o tsconfig.json https://gist.githubusercontent.com/vdelacou/996f290aa5d108b55688229e15ff4b3b/raw/tsconfig.json ``` 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,3 @@ { "recommendations": ["dbaeumer.vscode-eslint", "esbenp.prettier-vscode", "editorconfig.editorconfig", "eamodio.gitlens"] } 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,32 @@ { "editor.formatOnSave": true, "editor.codeActionsOnSave": { "source.organizeImports": true }, "typescript.tsdk": "node_modules\\typescript\\lib", "files.autoSave": "afterDelay", "search.exclude": { "**/node_modules": true, "**/.vscode": true }, "git.autofetch": true, "javascript.format.enable": false, "typescript.implementationsCodeLens.enabled": true, "editor.trimAutoWhitespace": true, "files.encoding": "utf8", "files.trimFinalNewlines": true, "files.trimTrailingWhitespace": true, "eslint.validate": ["javascript", "typescript"], "[javascript]": { "editor.formatOnSave": false, "editor.codeActionsOnSave": { "source.fixAll.eslint": true } }, "[typescript]": { "editor.formatOnSave": false, "editor.codeActionsOnSave": { "source.fixAll.eslint": true } } } -
vdelacou revised this gist
Apr 25, 2021 . 1 changed file with 3 additions and 3 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -17,9 +17,9 @@ npx json -I -f package.json -e 'this.scripts={...this.scripts , "start": "ts-nod npm install winston npm install --save-dev @types/node mkdir src curl -o src/example.ts https://gist.githubusercontent.com/vdelacou/996f290aa5d108b55688229e15ff4b3b/raw/example.ts curl -o .eslintrc.json https://gist.githubusercontent.com/vdelacou/996f290aa5d108b55688229e15ff4b3b/raw/.eslintrc.json curl -o tsconfig.json https://gist.githubusercontent.com/vdelacou/996f290aa5d108b55688229e15ff4b3b/raw/tsconfig.json ``` -
vdelacou created this gist
Apr 25, 2021 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,24 @@ { "env": { "node": true, "es2020": true }, "extends": [ "plugin:prettier/recommended", "plugin:@typescript-eslint/eslint-recommended", "plugin:@typescript-eslint/recommended", "plugin:@typescript-eslint/recommended-requiring-type-checking", "prettier" ], "globals": { "Atomics": "readonly", "SharedArrayBuffer": "readonly" }, "parser": "@typescript-eslint/parser", "parserOptions": { "sourceType": "module", "project": "./tsconfig.json" }, "plugins": ["@typescript-eslint", "prettier"], "rules": {} } 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,25 @@ # How to install a typescript project `npm init private` ``` curl -o .gitignore https://gist.githubusercontent.com/vdelacou/1954a25d720f702b4af011ba2773001b/raw/.gitignore curl -o .prettierrc https://gist.githubusercontent.com/vdelacou/58484f1c11af70aaa457f4e5c289e893/raw/.prettierrc mkdir .vscode curl -o .vscode/extensions.json https://gist.githubusercontent.com/vdelacou/c5f3fd74c5e836706c0adaeb0d383bd0/raw/extensions.json curl -o .vscode/settings.json https://gist.githubusercontent.com/vdelacou/c5f3fd74c5e836706c0adaeb0d383bd0/raw/settings.json curl -o .editorconfig https://gist.githubusercontent.com/vdelacou/58484f1c11af70aaa457f4e5c289e893/raw/.editorconfig npm install --save-dev typescript ts-node eslint @typescript-eslint/eslint-plugin @typescript-eslint/parser prettier eslint-config-prettier eslint-plugin-prettier npm install husky --save-dev npx json -I -f package.json -e 'this.husky={"hooks":{"pre-commit": "npm run lint","pre-push": "npm run lint"}}' npx json -I -f package.json -e 'this.scripts={...this.scripts , "lint": "eslint . --ext .js,.ts" }' npx json -I -f package.json -e 'this.scripts={...this.scripts , "start": "ts-node ./src/example.ts" }' npm install winston npm install --save-dev @types/node mkdir src curl -o src/example.ts https://gist.githubusercontent.com/vdelacou/58484f1c11af70aaa457f4e5c289e893/raw/example.ts curl -o .eslintrc.json https://gist.githubusercontent.com/vdelacou/58484f1c11af70aaa457f4e5c289e893/raw/.eslintrc.json curl -o tsconfig.json https://gist.githubusercontent.com/vdelacou/58484f1c11af70aaa457f4e5c289e893/raw/tsconfig.json ``` 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,19 @@ import winston from 'winston'; const logger = winston.createLogger({ transports: [new winston.transports.Console()] }); const delay = (milliseconds: number, count: number): Promise<number> => { return new Promise((resolve) => { setTimeout(() => { resolve(count); }, milliseconds); }); }; (async () => { logger.info('Start'); const count = await delay(1000, 2); logger.info(`End with count: ${count}`); })().catch((e) => { logger.error(e); }); 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,16 @@ { "compilerOptions": { "target": "ES2020", "module": "commonjs", "lib": ["ES2020"], "strict": true, "noImplicitAny": true, "strictNullChecks": true, "strictFunctionTypes": true, "strictBindCallApply": true, "strictPropertyInitialization": true, "noImplicitThis": true, "alwaysStrict": true, "esModuleInterop": true } }