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 { reduceMap } from './reduce-map'; | |
describe('reduceMap', () => { | |
const sumValueAndSubtractKey = (result: number, value: number, key: number) => result + value - key; | |
it('should return initial value for empty map', () => { | |
expect( | |
reduceMap( | |
new Map(), | |
sumValueAndSubtractKey, |
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 { Controller, ControllerOptions } from '@nestjs/common'; | |
import { join } from 'path'; | |
import { AuthenticationGuard, AccessControlGuard } from 'app/guards'; | |
expose function AdminController(options: ControllerOptions) { | |
return function (target: Function) { | |
Controller(join('/admin', options.path))(target); | |
AuthenticationGuard()(target); | |
AccessControlGuard({ role: 'admin' })(target); | |
}; |
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
@AdminController(options) { | |
@Controller({ path: '/admin' + options.path }) | |
@AuthenticationGuard() | |
@AccessControlGuard({ role: 'admin' }) | |
} |
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 { Controller, Get } from '@nestjs/common'; | |
import { AdminController, AccessControlGuard } from 'app/decorators'; | |
@AdminController({ path: '/dashboard' }) | |
export class AdminDashboardController { | |
@Get() | |
index(): string { | |
return 'dashboard data for admin'; | |
} | |
} |
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 { Controller, Get } from '@nestjs/common'; | |
import { AuthenticationGuard, AccessControlGuard } from 'app/decorators'; | |
@Controller({ path: '/admin/dashboard' }) | |
@AuthenticationGuard() | |
@AccessControlGuard({ role: 'admin' }) | |
export class AdminDashboardController { | |
@Get() | |
index(): string { | |
return 'dashboard data for admin'; |
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 { Controller, Get } from '@nestjs/common'; | |
@Controller('/cats') | |
export class CatsController { | |
@Get() | |
findAll(): string { | |
return 'This action returns all cats'; | |
} | |
} |
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
resource "google_cloud_run_service_iam_binding" "binding" { | |
location = google_cloud_run_service.nodejs_app.location | |
service = google_cloud_run_service.nodejs_app.name | |
role = "roles/run.invoker" | |
members = [ | |
"allUsers", | |
] | |
} |
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
variable "app_name" { | |
type=string | |
} | |
variable "image_tag" { type=string } | |
resource "google_cloud_run_service" "nodejs_app" { | |
name = var.app_name | |
location = "us-central1" | |
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
variable "gcp_region" { | |
type=string | |
default="us-west3" | |
} | |
provider "template" { | |
version = "~> 2.0" | |
} | |
provider "google" { |
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
#!/usr/bin/env sh | |
set -eu | |
export GCP_PROJECT=my-gcp-project | |
export APP_NAME=cloudrun-node-app-demo | |
# Logging in to GCR using service account credentials placed on ./gcp-credentials.json | |
cat ./gcp-credentials.json | docker login -u _json_key --password-stdin https://gcr.io |
NewerOlder