Skip to content

Instantly share code, notes, and snippets.

Lucas andreybleme

Block or report user

Report or block andreybleme

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@andreybleme
andreybleme / user.integration.test.js
Last active May 28, 2019
andreybleme.com | Integration tests with Docker
View user.integration.test.js
const knex = require('knex')({
client: 'pg',
connection: process.env.PG_URL,
});
let pgContainer = await new GenericContainer('postgres')
.withEnv('POSTGRES_USER', 'test')
.withEnv('POSTGRES_PASSWORD', 'test')
.withExposedPorts(5432)
@andreybleme
andreybleme / test-setup.js
Created May 28, 2019
andreybleme.com | Integration tests with Docker
View test-setup.js
const {Docker} = require('node-docker-api');
const docker = new Docker({ socketPath: '/var/run/docker.sock' });
docker.container.create({
Image: 'postgres',
name: 'test'
})
.then(container => container.start())
@andreybleme
andreybleme / db.test.sh
Last active May 28, 2019
andreybleme.com | Integration tests with Docker
View db.test.sh
#!/bin/bash
CONTAINER_ID=$(docker run -p 5400:5432 -e POSTGRES_USER=test -e POSTGRES_PASSWORD=test -d postgres:9.6.5)
REDIS_CONTAINER_ID=$(docker run -p 6379:6379 -d redis:4.0-alpine)
echo "Running PG Container: $CONTAINER_ID"
echo "Running Redis Container: $REDIS_CONTAINER_ID"
# waits
sleep 5
# run db tests
@andreybleme
andreybleme / cli.js
Created Apr 12, 2019
andreybleme.com | Criando uma CLI para fazer deploy de sites estáticos
View cli.js
let rootFolder = '.'
program
.command('deploy')
.option('-b, --bucket <s>', 'Bucket name', setBucket)
.option('-k, --key <s>', 'AWS Key', setKey)
.option('-s, --secret <s>', 'AWS Secret', setSecret)
.option('-r, --root <s>', 'Root path', setRootFolder)
.option('-e, --ignore <items>', 'Ignore files', setIgnore)
.action(function () {
@andreybleme
andreybleme / cli.js
Created Apr 12, 2019
andreybleme.com | Criando uma CLI para fazer deploy de sites estáticos
View cli.js
let ignored = []
program
.command('deploy')
.option('-b, --bucket <s>', 'Bucket name', setBucket)
.option('-k, --key <s>', 'AWS Key', setKey)
.option('-s, --secret <s>', 'AWS Secret', setSecret)
.option('-e, --ignore <items>', 'Ignore files', setIgnore)
.action(function () {
s3Services.setAwsCredentials(awsCredentials)
@andreybleme
andreybleme / cli.js
Created Apr 11, 2019
andreybleme.com | Criando uma CLI para fazer deploy de sites estáticos
View cli.js
#!/usr/bin/env node
const program = require('commander')
const s3Services = require('./app/s3Services')
const filesystem = require('./app/filesystem')
const awsCredentials = {
region: 'us-east-1',
accessKeyId: '',
secretAccessKey: ''
@andreybleme
andreybleme / s3Services.js
Created Apr 11, 2019
andreybleme.com | Criando uma CLI para fazer deploy de sites estáticos
View s3Services.js
const AWS = require('aws-sdk')
const filesystem = require('./filesystem')
function setAwsCredentials(awsCredentials) {
// altera credenciais
}
function createBucket(bucketParams, staticHostParams) {
// cria o bucket
}
@andreybleme
andreybleme / filesystem.js
Created Apr 11, 2019
andreybleme.com | Criando uma CLI para fazer deploy de sites estáticos
View filesystem.js
const fs = require('fs')
const path = require('path')
const mime = require('mime')
function getAllFilesFrom(currentDirPath, callback) {
fs.readdirSync(currentDirPath).forEach(function (name) {
const filePath = path.join(currentDirPath, name)
const stat = fs.statSync(filePath)
if (stat.isFile()) {
@andreybleme
andreybleme / cli.js
Created Apr 11, 2019
andreybleme.com | Criando uma CLI para fazer deploy de sites estáticos
View cli.js
#!/usr/bin/env node
const program = require('commander')
const s3Services = require('./app/s3Services')
const awsCredentials = {
region: 'us-east-1',
accessKeyId: '',
secretAccessKey: ''
}
@andreybleme
andreybleme / s3Services.js
Created Apr 11, 2019
andreybleme.com | Criando uma CLI para fazer deploy de sites estáticos
View s3Services.js
const AWS = require('aws-sdk')
function setAwsCredentials(awsCredentials) {
AWS.config.update(awsCredentials)
}
function createBucket(bucketParams, staticHostParams) {
const s3 = new AWS.S3()
s3.createBucket(bucketParams, function(err, data) {
if (err) {
You can’t perform that action at this time.