forked from colibri-project-io/colibri-sdk-go
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
89d9494
commit 571553e
Showing
72 changed files
with
7,076 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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 characters
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 |
This file contains 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 characters
This file contains 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 characters
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 |
This file contains 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 characters
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) | ||
} |
This file contains 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 characters
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 |
This file contains 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 characters
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); |
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
delete from users; | ||
delete from profiles; |
This file contains 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 characters
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) | ||
); | ||
|
This file contains 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 characters
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: |
This file contains 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 characters
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" |
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Test file |
19 changes: 19 additions & 0 deletions
19
...environment/wiremock/mappings/users-api/mappings/default/error/get-user-with-timeout.json
This file contains 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 characters
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]" | ||
} | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
...ronment/wiremock/mappings/users-api/mappings/default/success/delete-users-no-content.json
This file contains 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 characters
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 | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
...opment-environment/wiremock/mappings/users-api/mappings/default/success/delete-users.json
This file contains 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 characters
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]" | ||
} | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
development-environment/wiremock/mappings/users-api/mappings/default/success/get-user.json
This file contains 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 characters
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]" | ||
} | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
development-environment/wiremock/mappings/users-api/mappings/default/success/get-users.json
This file contains 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 characters
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]" | ||
} | ||
] | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
development-environment/wiremock/mappings/users-api/mappings/default/success/post-users.json
This file contains 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 characters
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]" | ||
} | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
development-environment/wiremock/mappings/users-api/mappings/default/success/put-users.json
This file contains 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 characters
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]" | ||
} | ||
} | ||
} |
Oops, something went wrong.