Skip to content

Instantly share code, notes, and snippets.

View gabrielh-silvestre's full-sized avatar
🚀

Gabriel Silvestre gabrielh-silvestre

🚀
View GitHub Profile

Criação/Configuração de Variável

Exemplo

var json = JSON.parse(responseBody);

if (responseCode.code >= 200 && responseCode.code < 300) {
    // Variável da coleção
    pm.collectionVariables.set("productId", json.data.id);
@gabrielh-silvestre
gabrielh-silvestre / tsconfig.json
Created September 12, 2022 18:26
copy/paste tsconfig
{
"compilerOptions": {
"module": "commonjs",
"target": "ES2016",
"rootDir": ".",
"outDir": "./dist",
"baseUrl": ".",
"esModuleInterop": true,
"strict": true,
"strictPropertyInitialization": false,
@gabrielh-silvestre
gabrielh-silvestre / express-json.json
Last active May 20, 2022 14:07
package.json with basic scripts
{
{ // for typescript
"start": "node dist/server.js",
"dev": "ts-node-dev --inspect --transpile-only --ignore node_modules --respawn src/server.ts",
"test": "mocha -r ts-node/register src/**/*.spec.ts"
},
{ // for javascript
"start": "node src/server.js",
"dev": "nodemon src/server.js",
"test": "mocha -r src/**/*.spec.js"
@gabrielh-silvestre
gabrielh-silvestre / init-express.md
Last active July 9, 2022 16:02
Steps to create a Express API
npm init -y
npm i express

With TypeScript

@gabrielh-silvestre
gabrielh-silvestre / .env.example
Last active October 18, 2022 14:32
copy/past docker-compose for express + mysql with ENV variables
FRONT_PORT=3000
PORT=3001
DB_USER=user
DB_PASS=password
DB_NAME=database
DB_PORT=3306
MONGO_PORT=27017
REDIS_PORT=6379
@gabrielh-silvestre
gabrielh-silvestre / helpersLocalStorage.ts
Created February 12, 2022 16:21
Functions to work in Local Storage
function getInitialValue(
key: string,
defaultValue: any,
convertFromString = JSON.parse
) {
const localStorageValue = localStorage.getItem(key);
if (localStorageValue) {
try {
return convertFromString(localStorageValue);
} catch {
@gabrielh-silvestre
gabrielh-silvestre / genericFilter.js
Last active November 18, 2022 00:05
Generic filter for multiples conditions
const FILTERS_LOGIC = {
// Logic to filter
};
const recursive = (apiArray, filtersArray) => (
apiArray.reduce((acc, crv) => filteredData(acc, filtersArray), [...apiArray]));
const filteredData = (apiArray, filtersArray) => (
apiArray.filter((item) =>
filtersArray.every((filterObj) =>
@gabrielh-silvestre
gabrielh-silvestre / testHelpers.js
Last active June 21, 2022 19:36
Test helpers for RTL
import React, { createContext } from 'react';
import { render } from '@testing-library/react';
import { Provider } from 'react-redux';
import { applyMiddleware, createStore } from 'redux';
import thunk from 'redux-thunk';
import { Router } from 'react-router';
import { createMemoryHistory } from 'history';
export const renderWithRouter = (component) => {
const history = createMemoryHistory();