A Pen by Massimo Cassandro on CodePen.
This file contains hidden or 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
| { | |
| "type": "service_account", | |
| "project_id": "XXXX", | |
| "private_key_id": "XXXXXX", | |
| "private_key": "-----BEGIN PRIVATE KEY-----\n+XXXXX-----END PRIVATE KEY-----\n", | |
| "client_email": "<name of the service accnt>@<project-name>.iam.gserviceaccount.com", | |
| "client_id": "1CXXXX", | |
| "auth_uri": "https://accounts.google.com/o/oauth2/auth", | |
| "token_uri": "https://oauth2.googleapis.com/token", | |
| "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs", |
This file contains hidden or 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
| export interface AuthenticationModel { | |
| keyFile?: string; | |
| keyFilename?: string; | |
| autoRetry?: boolean; | |
| projectId?: string; | |
| apiEndpoint?: string; | |
| maxRetries?: number; | |
| client_id?: string; | |
| client_secret?: string; | |
| scope?: string[]; |
This file contains hidden or 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
| import {Storage} from '@google-cloud/storage'; | |
| import { AuthenticationModel } from '../models/authentication.model'; | |
| import { AppUtilServiceInstance } from './app.util.service'; | |
| import * as pino from 'pino'; | |
| import { PinoLoggerServiceInstance } from './pino.logger.service'; | |
| export class GcloudAuthentication { | |
| private gcloudAuthModel: AuthenticationModel; | |
| private LOGGER: pino.Logger; | |
| constructor() { |
This file contains hidden or 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
| getGcloudAuthModel(): AuthenticationModel { | |
| const authModel: GcloudAuthenticationModel = new GcloudAuthenticationModel(); | |
| authModel.autoRetry = true; | |
| authModel.keyFilename = GCLOUD_KEY_FILE; | |
| authModel.projectId = GCLOUD_PRJ_ID; | |
| authModel.scope = GCLOUD_STROAGE_SCOPE; | |
| authModel.maxRetries = GCLOUD_CONN_MAX_RETRIES; | |
| return authModel; | |
| } |
This file contains hidden or 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
| export async function uploadEnvFiles(env_name: string) { | |
| const LOGGER: pino.Logger = PinoLoggerServiceInstance.getLogger(__filename); | |
| return new Promise(async (res, rej) => { | |
| // Get the storage bucket | |
| const str = GcloudAuthenticationInstance.createGcloudAuthenticationBucket(); | |
| // get the bucket name | |
| const bucketToUpload = GCLOUD_ENV_STR_BUCKET_NAME; | |
| let uploadLocalFilePath; |
This file contains hidden or 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
| export async function downloadEnvFiles(env_name): Promise<any> { | |
| const LOGGER: pino.Logger = PinoLoggerServiceInstance.getLogger(__filename); | |
| return new Promise(async (res, rej) => { | |
| // Get the storage | |
| const str = GcloudAuthenticationInstance.createGcloudAuthenticationBucket(); | |
| try { | |
| // get the file list from the storage and the bucket | |
| const [files] = await str.bucket(GCLOUD_ENV_STR_BUCKET_NAME).getFiles(); | |
| // filter the req file |
This file contains hidden or 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
| { | |
| "name": "@feedback/cloud-storage-app", | |
| "description": "This is the default storage app used by feedback", | |
| "version": "1.0.12", | |
| "author": "VijayKumar <vijay.psg587@gmail.com>", | |
| "keywords": [ | |
| "feedback-gcloud-storate", | |
| "feedback-storage", | |
| "feedback-cloud-storage" | |
| ], |
This file contains hidden or 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
| Node parameters: --require ts-node/register -r ts-node -r dotenv/config -r tsconfig-paths/register src/main.ts dotenv_config_path=./config/development/.env | |
| // baiscally we need -require ts-node/register <things in nodemon exec> | |
| NODE_ENV=dev |
System: Debian/Ubuntu/Fedora. Might work for others as well.
As mentioned here, to update a go version you will first need to uninstall the original version.
To uninstall, delete the /usr/local/go directory by: