Skip to content

Instantly share code, notes, and snippets.

View brunokrebs's full-sized avatar

Bruno Krebs brunokrebs

View GitHub Profile
const { MongoMemoryServer } = require('mongodb-memory-server');
async function connect() {
const mongoConnection = new MongoMemoryServer({ debug: true });
const status = mongoConnection.getInstanceInfo();
console.log(status);
const connectionString = await mongoConnection.getConnectionString();
console.log('=================================================================================');
const { MongoMemoryServer } = require('mongodb-memory-server');
async function connect() {
const mongoConnection = new MongoMemoryServer({ debug: true });
const status = mongoConnection.getInstanceInfo();
console.log(status);
const connectionString = await mongoConnection.getConnectionString();
console.log('=================================================================================');
  1. Você não precisa gerenciar CORS na API. Para o ambiente de desenvolvimento você pode utilizar o React Proxy: https://facebook.github.io/create-react-app/docs/proxying-api-requests-in-development

  2. Ao utilizar o proxy informado acima, você vai poder remover http://localhost:3001 do seu código.

  3. Não precisa adicionar o termo fetch nas suas sagas. Ou seja, ao invés de fetchAddBuilding e callFetchAddBuilding, basta addBuilding e callAddBuilding.

  4. store.dispatch(loadBuildingsList()); não deveria estar no index.js (eu sei que no meu artigo está assim, mas aquilo é só um exemplo básico). Não são todas as páginas que vão precisar carregar a lista de buildings. Por exemplo, se o usuário for diretamente para http://localhost:3000/new-item, não tem porque disparar uma requisição para carregar a listagem de buildings.

  5. Inclusive, o fato de esse store.dispatch(loadBuildingsList()); estar no index faz com que ele seja chamado apenas uma vez. Se eu acesso o sistema, vou para a página de adi

[
{ "_id": 123, "title": "Buy pizza" },
{ "_id": 456, "title": "Watch Netflix" }
]

Creating a Cluster on Amazon Elastic Kubernetes Service (EKS)

To create your Kubernetes cluster on AWS (Amazon Web Services), first, you will have to create a new account on this service (you can also use one that you might have available). Then, you will have to follow these instructions to install the AWS Command-Line Interface (CLI). Make sure you follow the instructions for your operating system.

After creating your account and installing the CLI tool, you will have to create an Amazon EKS Service Role and create an Amazon EKS Cluster VPC. To accomplish that, you can go through the steps shown in this AWS documentation.

Now, still on the Getting Started with Amazon EKS page, search for the section that teaches you "to install `aw

# coding=utf-8
# 1 - imports
from datetime import date
from actor import Actor
from base import Session, engine, Base
from movie import Movie
# 2 - generate database schema
const client = new ApolloClient({
uri: "http://localhost:4000/graphql",
request: operation => {
operation.setContext(context => ({
headers: {
...context.headers,
authorization: "Bearer " + auth.getIdToken(),
},
}));
},
apiVersion: v1
kind: Service
metadata:
name: nginx-cluster-ip
spec:
ports:
- port: 80
protocol: TCP
targetPort: 80
selector:
handleAuthentication() {
return new Promise((resolve, reject) => {
this.auth0.parseHash((err, authResult) => {
if (err) return reject(err);
if (!authResult || !authResult.idToken) {
return reject(err);
}
this.idToken = authResult.idToken;
this.profile = authResult.idTokenPayload;
// set the time that the id token will expire at
var express = require('express');
var bodyParser = require('body-parser');
const jwt = require('express-jwt');
const jwksRsa = require('jwks-rsa');
var app = express();
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
const jwtCheck = jwt({