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
import nodemailer from 'nodemailer'; | |
export class Emailer { | |
transporter: nodemailer.Transporter; | |
constructor() { | |
this.transporter = nodemailer.createTransport({ | |
host: 'mysmtpserver.com.br', | |
port: 25 | |
}); |
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
import { ConnectionPool } from 'mssql'; | |
export class DatabaseClient { | |
pool: ConnectionPool; | |
dbConfig: {redated}; | |
constructor() { | |
super(); | |
this.pool = new ConnectionPool(this.dbConfig); | |
} |
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
getUsers$ = (): Observable<any> => { | |
if (someCondition) { | |
return from(someAsyncOperation()) | |
} | |
else { | |
return from(someOtherAsyncOperation()) | |
} | |
} | |
getUsers2$ = (): Observable<any> => someCondition ? from(someAsyncOperation()) : from(someOtherAsyncOperation()) |
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
getUsers = async () => new Promise((resolve, reject) => { | |
if (someCondition) { | |
someAsyncOperation() | |
.then((result) => resolve(result)) | |
.catch((err) => reject(err)) | |
} | |
else { | |
someOtherAsyncOperation() | |
.then((result) => resolve(result)) | |
.catch((err) => reject(err)) |
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
const users$ = getUsers$(); | |
users$.pipe( | |
filter(user => user.isActive), | |
mergeMap(user => sendEmail$(user.email)) | |
).subscribe( | |
(success) => emailsSent++, | |
(err) => failedEmails++, | |
() = > console.log('Emails sent:'+emailsSent+' Emails failed:'+failedEmails) | |
) |
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
const EMAIL_PARALLELISM = 5; | |
const users$ = getUsers$(); | |
users$.pipe( | |
filter(user => user.isActive), | |
mergeMap(user => sendEmail$(user.email), EMAIL_PARALLELISM) | |
).subscribe( | |
(success) => emailsSent++, | |
(err) => failedEmails++, | |
() = > console.log('Emails sent:'+emailsSent+' Emails failed:'+failedEmails) |
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
let users$ = from(getUsers()); | |
users$.pipe( | |
filter(user => user.isActive), | |
concatMap(user => from(sendEmail(user.email))) | |
).subscribe( | |
(success) => emailsSent++, | |
(err) => failedEmails++, | |
() = > console.log('Emails sent:'+emailsSent+' Emails failed:'+failedEmails) | |
) | |
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
let someArray = []; | |
someArray = someOtherArray; | |
const streamOfItems$ = of(someArray).pipe( | |
mergeAll() | |
) | |
// streamOfItems$ will emit each item of the array as an observable through the stream |
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
data "http" "access_token" { | |
url = "https://${var.docker_registry.host}/oauth2/token?service=${var.docker_registry.host}&scope=repository:*:pull" | |
request_headers = { | |
Authorization = "Basic ${base64encode("${var.docker_registry.user}:${var.docker_registry.password}")}" | |
} | |
} | |
data "http" "tips-admin" { | |
url = "https://${var.docker_registry.host}/v2/tips-admin/manifests/${local.environment}" | |
request_headers = { |
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
resource "kubernetes_deployment" "tips-admin" { | |
metadata { | |
name = "tips-admin" | |
labels = { | |
app = "tips-admin" | |
} | |
} | |
spec { | |
replicas = 1 | |
selector { |
NewerOlder