Skip to content

Commit

Permalink
chore: initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
dantasrafael committed Oct 21, 2022
1 parent 89d9494 commit 571553e
Show file tree
Hide file tree
Showing 72 changed files with 7,076 additions and 0 deletions.
26 changes: 26 additions & 0 deletions .env_example
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
ENVIRONMENT=production/sandbox/development/test
APP_NAME=Nome da aplicação
APP_TYPE=service/serverless

PORT=8080

CLOUD=aws/gcp/firebase
CLOUD_PROJECT_ID=XYZ
CLOUD_HOST=http://localhost:4566
CLOUD_REGION=us-east-1
CLOUD_SECRET=no_secret
CLOUD_TOKEN=no_token
CLOUD_DISABLE_SSL=true

DB=sql/nosql
DB_HOST=localhost
DB_PORT=5432
DB_USER=postgres
DB_PASSWORD=postgres
DB_NAME=dojo_modulo_escolar
DB_SSL_MODE=disable

CACHE_URI=localhost:6379
CACHE_PASSWORD=

NEW_RELIC_LICENSE=123465ABCDE
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,13 @@
# Output of the go coverage tool, specifically when used with LiteIDE
*.out

# Jetbrains IDE
.idea/
*.iml

# VsCode IDE
.vscode/
.history/

# Dependency directories (remove the comment below to include it)
# vendor/
12 changes: 12 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

fmt:
go fmt ./...

mock:
go generate -v ./...

test: mock
go test ./... --coverprofile coverage.out

cover:
go tool cover -html coverage.out
42 changes: 42 additions & 0 deletions colibri.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package colibri

import (
"fmt"

"github.com/colibri-project-io/colibri-sdk-go/pkg/base/cloud"
"github.com/colibri-project-io/colibri-sdk-go/pkg/base/config"
"github.com/colibri-project-io/colibri-sdk-go/pkg/base/logging"
"github.com/colibri-project-io/colibri-sdk-go/pkg/base/monitoring"
)

const banner = `
. _ _ _ _ _
{ \/'o;=== | (_) | (_)
.----'-/'-/ ___ ___ | |_| |__ _ __ _
'-..-| / / __ / _ \| | | '_ \| '__| |
/\/\ | (__| (_) | | | |_) | | | |
'--' \___ \___/|_|_|_.__/|_| |_|
project - v%s
`

var Version string = "v.0.0.0"

func InitializeApp() {
if err := config.Load(); err != nil {
logging.Fatal("Occurred a error on try load configs: %v", err)
}

printBanner()
printApplicationName()

monitoring.Initialize()
cloud.Initialize()
}

func printBanner() {
fmt.Printf(banner, Version)
}

func printApplicationName() {
fmt.Printf("\n# %s #\n\n", config.APP_NAME)
}
15 changes: 15 additions & 0 deletions development-environment/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
STACK_NAME=dev

start:
docker-compose -p ${STACK_NAME} up -d --remove-orphans

stop:
docker-compose -p ${STACK_NAME} stop

restart: stop start

clean:
docker-compose -p ${STACK_NAME} down -v

logs:
docker-compose -p ${STACK_NAME} logs -f
5 changes: 5 additions & 0 deletions development-environment/database/add-users.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
INSERT INTO profiles (id, name) VALUES (100, 'ADMIN');
INSERT INTO profiles (id, name) VALUES (200, 'USER');

INSERT INTO users (id, name, birthday, profile_id) VALUES (1, 'ADMIN USER', '2022-01-10', 100);
INSERT INTO users (id, name, birthday, profile_id) VALUES (2, 'OTHER USER', '2020-03-25', 200);
2 changes: 2 additions & 0 deletions development-environment/database/clear-database.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
delete from users;
delete from profiles;
13 changes: 13 additions & 0 deletions development-environment/database/schema.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
CREATE TABLE IF NOT EXISTS profiles (
id INTEGER PRIMARY KEY,
name VARCHAR(255) NOT NULL
);

CREATE TABLE IF NOT EXISTS users (
id INTEGER PRIMARY KEY,
name VARCHAR(255) NOT NULL,
birthday TIMESTAMP NOT NULL,
profile_id INTEGER NOT NULL,
CONSTRAINT fk_users_profiles FOREIGN KEY (profile_id) REFERENCES profiles (id)
);

32 changes: 32 additions & 0 deletions development-environment/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
version: "3"

services:
wiremock:
image: wiremock/wiremock:2.32.0
command: "--local-response-templating"
ports:
- "5050:8080"
volumes:
- ./wiremock:/home/wiremock:ro
networks:
- dev

localstack:
image: localstack/localstack
ports:
- "127.0.0.1:4510-4559:4510-4559" # external service port range
- "127.0.0.1:4566:4566" # LocalStack Edge Proxy
environment:
- DEBUG=${DEBUG-}
- SERVICES=sns,sqs,s3,dynamodb
- DATA_DIR=${DATA_DIR-}
- LAMBDA_EXECUTOR=${LAMBDA_EXECUTOR-}
- HOST_TMP_FOLDER=${TMPDIR:-/tmp/}localstack
- DOCKER_HOST=unix:///var/run/docker.sock
volumes:
- "/var/run/docker.sock:/var/run/docker.sock"
networks:
- dev

networks:
dev:
19 changes: 19 additions & 0 deletions development-environment/localstack/localstack-init.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash

awslocal sns create-topic --name COLIBRI_PROJECT_USER_CREATE
awslocal sqs create-queue --queue-name COLIBRI_PROJECT_USER_CREATE_APP_CONSUMER
awslocal sns subscribe --topic-arn arn:aws:sns:us-east-1:000000000000:COLIBRI_PROJECT_USER_CREATE \
--protocol sqs \
--notification-endpoint arn:aws:sqs:us-east-1:queue:COLIBRI_PROJECT_USER_CREATE_APP_CONSUMER


awslocal sns create-topic --name COLIBRI_PROJECT_FAIL_USER_CREATE
awslocal sqs create-queue --queue-name COLIBRI_PROJECT_FAIL_USER_CREATE_APP_CONSUMER
awslocal sqs create-queue --queue-name COLIBRI_PROJECT_FAIL_USER_CREATE_APP_CONSUMER_DLQ
awslocal sns subscribe --topic-arn arn:aws:sns:us-east-1:000000000000:COLIBRI_PROJECT_FAIL_USER_CREATE \
--protocol sqs \
--notification-endpoint arn:aws:sqs:us-east-1:queue:COLIBRI_PROJECT_FAIL_USER_CREATE_APP_CONSUMER

awslocal s3api create-bucket --bucket my-bucket --acl public-read

echo "localstack topics and queues started"
1 change: 1 addition & 0 deletions development-environment/storage/file.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Test file
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"priority": 1,
"request": {
"method": "GET",
"urlPathPattern": "/users-api/v1/2"
},
"response": {
"status": 200,
"fixedDelayMilliseconds": 2000,
"headers": {
"Content-Type": "application/json; charset=utf-8"
},
"jsonBody": {
"id": 2,
"name": "Jaya Ganaka MD",
"email": "[email protected]"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"priority": 1,
"request": {
"method": "DELETE",
"urlPattern": "/users-api/v1/users/12"
},
"response": {
"status": 204
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"priority": 1,
"request": {
"method": "DELETE",
"urlPattern": "/users-api/v1/users/11"
},
"response": {
"status": 200,
"headers": {
"Content-Type": "application/json; charset=utf-8"
},
"jsonBody": {
"id": 11,
"name": "User 11 deleted",
"email": "[email protected]"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"priority": 1,
"request": {
"method": "GET",
"urlPathPattern": "/users-api/v1/1"
},
"response": {
"status": 200,
"headers": {
"Content-Type": "application/json; charset=utf-8"
},
"jsonBody": {
"id": 1,
"name": "Jaya Ganaka MD",
"email": "[email protected]"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"priority": 1,
"request": {
"method": "GET",
"urlPathPattern": "/users-api/v1"
},
"response": {
"status": 200,
"headers": {
"Content-Type": "application/json; charset=utf-8"
},
"jsonBody": [
{
"id": 1,
"name": "Jaya Ganaka 1",
"email": "[email protected]"
},
{
"id": 2,
"name": "Jaya Ganaka 2",
"email": "[email protected]"
},
{
"id": 3,
"name": "Jaya Ganaka 3",
"email": "[email protected]"
},
{
"id": 4,
"name": "Jaya Ganaka 4",
"email": "[email protected]"
},
{
"id": 5,
"name": "Jaya Ganaka 5",
"email": "[email protected]"
}
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"priority": 1,
"request": {
"method": "POST",
"urlPattern": "/users-api/v1/users",
"bodyPatterns": [
{
"equalToJson": {
"name": "User 10",
"email": "[email protected]"
}
}
]
},
"response": {
"status": 201,
"headers": {
"Content-Type": "application/json; charset=utf-8"
},
"jsonBody": {
"id": 10,
"name": "User 10",
"email": "[email protected]"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"priority": 1,
"request": {
"method": "PUT",
"urlPattern": "/users-api/v1/users/10",
"bodyPatterns": [
{
"equalToJson": {
"id": 10,
"name": "User 10 edited",
"email": "[email protected]"
}
}
]
},
"response": {
"status": 200,
"headers": {
"Content-Type": "application/json; charset=utf-8"
},
"jsonBody": {
"id": 10,
"name": "User 10 edited",
"email": "[email protected]"
}
}
}
Loading

0 comments on commit 571553e

Please sign in to comment.