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
class EmailValidator | |
{ | |
/* dependencies */ | |
bool IsEmailValid(string email) | |
{ | |
if ((email?.Length ?? 0) < 3) return false; | |
if (!Regex.IsMatch(email, myPattern)) return false; | |
if (myBlacklistService.IsEmailBlacklisted(email)) return false; | |
return true; |
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
class MyService | |
{ | |
private readonly ISerialCodeValidator serialCodeValidator; | |
private readonly IExternalIdService externalIdService; | |
private readonly IDataService dataService; | |
private readonly IReportingService reportingService; | |
MyResult Process(MyParams params) | |
{ | |
if (!serialCodeValidator.IsSerialCodeValid(params.SerialCode)) return MyResult.InvalidSerialCode; |
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
class MyService | |
{ | |
/* ... dependencies ... */ | |
MyResult Process(MyParams params) | |
{ | |
if (!IsSerialCodeValid(params.SerialCode)) return MyResult.InvalidSerialCode; | |
var externalId = GetExternalId(params.SerialCode); | |
StoreData(params.SerialCode, externalId); | |
Report(params.SerialCode, externalId); |
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
class MyService | |
{ | |
/* ... dependencies ... */ | |
MyResult Process(MyParams params) | |
{ | |
if (!Regex.IsMatch(params.SerialCode, myPattern)) return MyResult.InvalidSerialCode; | |
var externalData = httpClient.Get<ExternalData>("...get external data from HTTP endpoint"); | |
db | |
.Execute("...insert data into database...") |
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
dashboard.addWidgets(invocationWidget); | |
dashboard.addWidgets(latencyWidget); |
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 { GraphWidget, IWidget, Metric } from "@aws-cdk/aws-cloudwatch"; | |
import { Construct, Duration } from "@aws-cdk/core"; | |
const latencyWidget = new GraphWidget({ | |
width: 24, | |
title: 'API Latency', | |
left: [new Metric({ | |
metricName: 'Latency', | |
namespace: 'AWS/ApiGateway', | |
dimensions: {'ApiName': 'apiName'}, |
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 { GraphWidget, IWidget, Metric } from "@aws-cdk/aws-cloudwatch"; | |
import { Construct, Duration } from "@aws-cdk/core"; | |
const invocationWidget = new GraphWidget({ | |
width: 24, | |
title: 'title', | |
left: [new Metric({ | |
metricName: 'Count', | |
namespace: 'AWS/ApiGateway', | |
dimensions: {'ApiName': 'apiName'}, |
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 { Dashboard } from "@aws-cdk/aws-cloudwatch"; | |
const dashboard = new Dashboard(scope, 'id', { | |
dashboardName: '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
const fn = new Function(this, 'id', { | |
..., | |
logRetention: RetentionDays.ONE_WEEK, | |
... | |
}); |
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
class SubscriptionParams | |
{ | |
User User; | |
BillingPeriod BillingPeriod; | |
PaymentMethod PaymentMethod; | |
} | |
interface ISubscriptionService | |
{ | |
SubscriptionResult Subscribe(SubscriptionParams params); |