generated from fis-g4/sample-microservice
-
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
Showing
42 changed files
with
13,826 additions
and
798 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,67 @@ | ||
name: Deploy to GCE | ||
|
||
on: | ||
push: | ||
branches: | ||
- "main" | ||
|
||
env: | ||
ENV_CONFIGURATION: ${{ secrets.ENV_CONFIGURATION }} | ||
TERRAFORM_VARS: ${{ secrets.TERRAFORM_VARS }} | ||
GCP_CREDENTIALS: ${{ secrets.ENCODED_GCP_CREDENTIALS }} | ||
|
||
jobs: | ||
deploy-flatter-to-gce: | ||
name: Users Microservice Deployment to GCE | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Setup Terraform | ||
uses: hashicorp/setup-terraform@v2 | ||
with: | ||
terraform_version: 1.4.6 | ||
cli_config_credentials_token: ${{ secrets.TF_API_TOKEN }} | ||
terraform_wrapper: false | ||
|
||
- name: Populate terraform variables | ||
working-directory: ./terraform | ||
run: |- | ||
mkdir .ssh | ||
ssh-keygen -f .ssh/usersMicroservice -t rsa -N "" | ||
echo "$GCP_CREDENTIALS" | base64 --decode > GoogleCloudKey.json | ||
echo "$TERRAFORM_VARS" | base64 --decode > terraform.tfvars | ||
echo "$ENV_CONFIGURATION" | base64 --decode > .env.prod | ||
- name: Terraform Format | ||
id: fmt | ||
run: terraform fmt | ||
continue-on-error: true | ||
working-directory: ./terraform | ||
|
||
- name: Terraform Init | ||
id: init | ||
run: terraform init | ||
working-directory: ./terraform | ||
|
||
- name: Terraform Validate | ||
id: validate | ||
run: terraform validate -no-color | ||
working-directory: ./terraform | ||
|
||
- name: Terraform Destroy | ||
id: destroy | ||
run: terraform destroy -target=google_compute_instance.users_service_instance -auto-approve -input=false -no-color | ||
working-directory: ./terraform | ||
continue-on-error: true | ||
|
||
- name: Terraform Plan | ||
id: plan | ||
run: | | ||
terraform plan -input=false -no-color | ||
working-directory: ./terraform | ||
|
||
- name: Terraform Apply | ||
run: terraform apply -auto-approve -input=false -no-color | ||
working-directory: ./terraform |
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,81 @@ | ||
name: Tests | ||
|
||
on: [pull_request] | ||
|
||
jobs: | ||
build: | ||
name: Test | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Use Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: '20.x' | ||
|
||
- name: Decrypt Google credentials.json | ||
env: | ||
GOOGLE_API_PW: ${{ secrets.GCP_CREDENTIALS_PK }} | ||
run: | | ||
gpg --quiet --batch --yes --decrypt --passphrase="$GOOGLE_API_PW" \ | ||
--output $GITHUB_WORKSPACE/GoogleCloudKey.json GoogleCloudKey.json.gpg | ||
- name: Make envfile | ||
uses: SpicyPizza/[email protected] | ||
with: | ||
envkey_DB_URI: ${{ vars.CI_MONGODB_URI }} | ||
envkey_DB_NAME: ${{ vars.CI_MONGODB_NAME }} | ||
envkey_DB_USER: ${{ vars.CI_MONGODB_USER }} | ||
envkey_DB_PASS: ${{ secrets.CI_MONGODB_PASSWORD }} | ||
envkey_PORT: ${{ vars.CI_PORT }} | ||
envkey_NODE_ENV: ${{ vars.CI_NODE_ENV }} | ||
envkey_AUTH_DB: ${{ vars.CI_AUTH_DB }} | ||
envkey_JWT_SECRET: ${{ secrets.CI_JWT_SECRET }} | ||
envkey_JWT_EXPIRATION_TIME: ${{ vars.CI_JWT_EXPIRATION_TIME }} | ||
envkey_SALT_ROUNDS: ${{ secrets.CI_SALT_ROUNDS }} | ||
envkey_RESET_DB_ON_EACH_RELOAD: ${{ vars.CI_RESET_DB_ON_EACH_RELOAD }} | ||
envkey_ADMIN_USERNAME: ${{ secrets.CI_ADMIN_USERNAME }} | ||
envkey_ADMIN_PASSWORD: ${{ secrets.CI_ADMIN_PASSWORD }} | ||
envkey_ADMIN_EMAIL: ${{ secrets.CI_ADMIN_EMAIL }} | ||
envkey_TESTING_API_BASE_URL: ${{ vars.CI_TESTING_API_BASE_URL }} | ||
envkey_BASE_URL: ${{ vars.CI_BASE_URL }} | ||
envkey_DB_TEST_NAME: ${{ vars.CI_MONGODB_TEST_NAME }} | ||
envkey_GCS_PROJECT_NAME: ${{ vars.CI_GCS_PROJECT_NAME }} | ||
envkey_GCS_BUCKET_NAME: ${{ vars.CI_GCS_BUCKET_NAME }} | ||
envkey_GCS_BUCKET_URL: ${{ vars.CI_GCS_BUCKET_URL }} | ||
envkey_GCF_GENERATE_TOKEN_ENDPOINT: ${{ vars.GCF_GENERATE_TOKEN_ENDPOINT }} | ||
envkey_GCF_VERIFY_TOKEN_ENDPOINT: ${{ vars.GCF_VERIFY_TOKEN_ENDPOINT }} | ||
envkey_GCF_GET_PAYLOAD_FROM_TOKEN_ENDPOINT: ${{ vars.GCF_GET_PAYLOAD_FROM_TOKEN_ENDPOINT }} | ||
envkey_SENDINBLUE_API_KEY: ${{ secrets.CI_SENDINBLUE_API_KEY }} | ||
directory: ./server | ||
file_name: .env | ||
fail_on_empty: false | ||
sort_keys: false | ||
|
||
- name: Start MongoDB | ||
uses: supercharge/[email protected] | ||
with: | ||
mongodb-version: ${{ vars.CI_MONGODB_VERSION }} | ||
mongodb-username: ${{ vars.CI_MONGODB_USER }} | ||
mongodb-password: ${{ secrets.CI_MONGODB_PASSWORD }} | ||
mongodb-db: ${{ vars.CI_MONGODB_NAME }} | ||
mongodb-port: ${{ vars.CI_MONGODB_PORT }} | ||
|
||
- name: Install dependencies | ||
working-directory: ./server | ||
run: npm ci | ||
|
||
- name: Build project | ||
working-directory: ./server | ||
run: npm run build | ||
|
||
- name: Start server | ||
working-directory: ./server | ||
run: npm run start --run-tests& | ||
|
||
- name: Run tests | ||
working-directory: ./server | ||
run: npm test |
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
Binary file not shown.
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 |
---|---|---|
@@ -1,2 +1,6 @@ | ||
# sample-microservice | ||
This is a base project to create a microservice using the following set of technologies: MongoDB, ExpressJS, ReactJS and NodeJS | ||
# FISG G4 Users Microservice | ||
|
||
![Deployment](https://github.com/fis-g4/users-microservice/actions/workflows/cd.yml/badge.svg) | ||
![Tests](https://github.com/fis-g4/users-microservice/actions/workflows/test.yml/badge.svg) | ||
|
||
This microservice is in charge of authenticating users and managing their data. |
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 |
---|---|---|
@@ -1,6 +1,41 @@ | ||
DB_URI=mongodb://localhost:27017 | ||
DB_DATABASE=example-db | ||
DB_USER=root | ||
DB_PASS=password | ||
PORT=8000 | ||
NODE_ENV=development | ||
# MONGODB CONFIGURATION | ||
DB_URI=mongodb://localhost:27017 # or your mongodb uri | ||
DB_NAME=example-db # or your mongodb database name | ||
DB_USER=root # or your mongodb user | ||
DB_PASS=password # or your mongodb password | ||
AUTH_DB=admin # or your mongodb auth db | ||
|
||
# ADMIN CONFIGURATION | ||
ADMIN_USERNAME=admin # or your admin username | ||
ADMIN_PASSWORD=password # or your admin password | ||
ADMIN_EMAIL=[email protected] # or your admin email | ||
|
||
# JWT CONFIGURATION | ||
JWT_SECRET=secret # or your jwt secret | ||
JWT_EXPIRATION_TIME=24h # or your jwt expiration time | ||
SALT_ROUNDS=10 # or your salt rounds for bcrypt | ||
|
||
# SERVER CONFIGURATION | ||
RESET_DB_ON_EACH_RELOAD=true # or false if you don't want to reset db on each reload | ||
PORT=8000 # or your port | ||
NODE_ENV=development # or production if you want to run in production mode | ||
|
||
# TESTING CONFIGURATION | ||
TESTING_API_BASE_URL=http://localhost:8000/v1 # or your testing api base url | ||
DB_TEST_NAME=example-db-test # or your mongodb test database name | ||
|
||
# SWAGGER CONFIGURATION | ||
BASE_URL=http://localhost:8000/v1/users # or your custom base url | ||
|
||
# SENDINBLUE CONFIGURATION | ||
SENDINBLUE_API_KEY=xkeysib-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX-XXXXXXXX # or your sendinblue api key | ||
|
||
# GOOGLE STORAGE CONFIGURATION | ||
GCS_PROJECT_NAME="FIS G4" | ||
GCS_BUCKET_NAME="test-user-images-bucket" | ||
GCS_BUCKET_URL="https://storage.googleapis.com" | ||
|
||
# CLOUD FUNCTION CONFIGURATION | ||
GCF_GENERATE_TOKEN_ENDPOINT="https://europe-southwest1-liquid-layout-406710.cloudfunctions.net/fis-g4-jwt-generate" | ||
GCF_VERIFY_TOKEN_ENDPOINT="https://europe-southwest1-liquid-layout-406710.cloudfunctions.net/fis-g4-jwt-verify" | ||
GCF_GET_PAYLOAD_FROM_TOKEN_ENDPOINT="https://europe-southwest1-liquid-layout-406710.cloudfunctions.net/fis-g4-jwt-payload" |
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 |
---|---|---|
@@ -1,7 +1,41 @@ | ||
# DB_URI=mongodb://mongo-db:27017 | ||
DB_DATABASE=sample-db | ||
DB_USER=root | ||
DB_PASS=password | ||
AUTH_DB=admin | ||
PORT=8000 | ||
NODE_ENV=production | ||
# MONGODB CONFIGURATION | ||
DB_URI=mongodb://localhost:27017 # or your mongodb uri | ||
DB_NAME=example-db # or your mongodb database name | ||
DB_USER=root # or your mongodb user | ||
DB_PASS=password # or your mongodb password | ||
AUTH_DB=admin # or your mongodb auth db | ||
|
||
# ADMIN CONFIGURATION | ||
ADMIN_USERNAME=admin # or your admin username | ||
ADMIN_PASSWORD=password # or your admin password | ||
ADMIN_EMAIL=[email protected] # or your admin email | ||
|
||
# JWT CONFIGURATION | ||
JWT_SECRET=secret # or your jwt secret | ||
JWT_EXPIRATION_TIME=24h # or your jwt expiration time | ||
SALT_ROUNDS=10 # or your salt rounds for bcrypt | ||
|
||
# SERVER CONFIGURATION | ||
RESET_DB_ON_EACH_RELOAD=true # or false if you don't want to reset db on each reload | ||
PORT=8000 # or your port | ||
NODE_ENV=development # or production if you want to run in production mode | ||
|
||
# TESTING CONFIGURATION | ||
TESTING_API_BASE_URL=http://localhost # or your testing api base url | ||
DB_TEST_NAME=example-db-test # or your mongodb test database name | ||
|
||
# SWAGGER CONFIGURATION | ||
BASE_URL=http://localhost/users # or your custom base url | ||
|
||
# SENDINBLUE CONFIGURATION | ||
SENDINBLUE_API_KEY=xkeysib-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX-XXXXXXXX # or your sendinblue api key | ||
|
||
# GOOGLE STORAGE CONFIGURATION | ||
GCS_PROJECT_NAME="FIS G4" | ||
GCS_BUCKET_NAME="test-user-images-bucket" | ||
GCS_BUCKET_URL="https://storage.googleapis.com" | ||
|
||
# CLOUD FUNCTION CONFIGURATION | ||
GCF_GENERATE_TOKEN_ENDPOINT="https://europe-southwest1-liquid-layout-406710.cloudfunctions.net/fis-g4-jwt-generate" | ||
GCF_VERIFY_TOKEN_ENDPOINT="https://europe-southwest1-liquid-layout-406710.cloudfunctions.net/fis-g4-jwt-verify" | ||
GCF_GET_PAYLOAD_FROM_TOKEN_ENDPOINT="https://europe-southwest1-liquid-layout-406710.cloudfunctions.net/fis-g4-jwt-payload" |
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,38 @@ | ||
# MONGODB CONFIGURATION | ||
DB_URI=mongodb://localhost:27017 # or your mongodb uri | ||
DB_NAME=test-db # or your mongodb database name | ||
DB_USER=root # or your mongodb user | ||
DB_PASS=${{ secrets.CI_MONGODB_PASSWORD }} # or your mongodb password | ||
AUTH_DB=admin # or your mongodb auth db | ||
|
||
# ADMIN CONFIGURATION | ||
ADMIN_USERNAME=${{ secrets.CI_ADMIN_USERNAME }} # or your admin username | ||
ADMIN_PASSWORD=${{ secrets.CI_ADMIN_PASSWORD }} # or your admin password | ||
ADMIN_EMAIL=${{ secrets.CI_ADMIN_EMAIL }} # or your admin email | ||
|
||
# JWT CONFIGURATION | ||
JWT_SECRET=${{ secrets.CI_JWT_SECRET }} # or your jwt secret | ||
JWT_EXPIRATION_TIME=24h # or your jwt expiration time | ||
SALT_ROUNDS=${{ secrets.CI_SALT_ROUNDS }} # or your salt rounds for bcrypt | ||
|
||
# SERVER CONFIGURATION | ||
RESET_DB_ON_EACH_RELOAD=true # or false if you don't want to reset db on each reload | ||
PORT=8000 # or your port | ||
NODE_ENV=development # or production if you want to run in production mode | ||
|
||
# TESTING CONFIGURATION | ||
TESTING_API_BASE_URL=http://localhost:8000/v1 # or your testing api base url | ||
DB_TEST_NAME=example-db-test # or your mongodb test database name | ||
|
||
# SWAGGER CONFIGURATION | ||
BASE_URL=http://localhost:8000/v1/users # or your custom base url | ||
|
||
# GOOGLE STORAGE CONFIGURATION | ||
GCS_PROJECT_NAME="FIS G4" | ||
GCS_BUCKET_NAME="test-user-images-bucket" | ||
GCS_BUCKET_URL="https://storage.cloud.google.com" | ||
|
||
# CLOUD FUNCTION CONFIGURATION | ||
GCF_GENERATE_TOKEN_ENDPOINT="https://europe-southwest1-liquid-layout-406710.cloudfunctions.net/fis-g4-jwt-generate" | ||
GCF_VERIFY_TOKEN_ENDPOINT="https://europe-southwest1-liquid-layout-406710.cloudfunctions.net/fis-g4-jwt-verify" | ||
GCF_GET_PAYLOAD_FROM_TOKEN_ENDPOINT="https://europe-southwest1-liquid-layout-406710.cloudfunctions.net/fis-g4-jwt-payload" |
Oops, something went wrong.