Skip to content

Instantly share code, notes, and snippets.

View mikaelvesavuori's full-sized avatar

Mikael Vesavuori mikaelvesavuori

View GitHub Profile
@mikaelvesavuori
mikaelvesavuori / mikrometric-example.ts
Last active October 26, 2022 05:30
Example of emitting an AWS Embedded Metric Format-compatible log with MikroMetric.
import { MikroMetric } from 'mikrometric';
const mikroMetric = MikroMetric.start({
namespace: 'AWS EMF demo: Device data',
serviceName: 'DemoService'
});
mikroMetric.putDimension('User', 'Sam Person');
mikroMetric.putMetric('Duration', Math.ceil(Math.random() * 100), 'Milliseconds');
mikroMetric.setProperty('CorrelationId', 'abc123-qwerty-asdf');
mikroMetric.setProperty('AccountId', '123456789012');
@mikaelvesavuori
mikaelvesavuori / asyncapi.yml
Created October 5, 2022 07:51
Using a shared data model with AsyncAPI
asyncapi: 2.5.0
info:
title: Using a shared data model
version: 1.0.0
channels:
demo:
publish:
message:
name: Demo
payload: #/components/messages/demoMessage
@mikaelvesavuori
mikaelvesavuori / asyncapi.json
Last active October 5, 2022 07:34
EventBridge metadata object as shareable AsyncAPI resource
{
"asyncapi": "2.5.0",
"info": {
"title": "Common data structures",
"version": "1.0.0",
"contact": {
"name": "Sam Person",
"url": "https://acmecorp.xyz/docs#owner",
"email": "[email protected]"
},
@mikaelvesavuori
mikaelvesavuori / asyncapi.yml
Last active October 4, 2022 06:27
Basic example of referencing from an online source with AsyncAPI
asyncapi: 2.5.0
info:
title: Hello world application
version: 0.1.0
channels:
hello:
publish:
message:
payload:
operationId: asdf
@mikaelvesavuori
mikaelvesavuori / asyncapi.json
Created September 10, 2022 10:13
AsyncAPI example for REST API use-cases
{
"asyncapi": "2.4.0",
"info": {
"title": "User Service",
"version": "1.0.0",
"contact": {
"name": "Sam Person",
"url": "https://acmecorp.com/docs#owner",
"email": "[email protected]"
},
@mikaelvesavuori
mikaelvesavuori / asyncapi.json
Created August 30, 2022 09:41
AsyncAPI JSON demo
{
"asyncapi": "2.4.0",
"info": {
"title": "User Service",
"version": "1.0.0",
"contact": {
"name": "Sam Person",
"url": "https://acmecorp.com/docs#owner",
"email": "[email protected]"
},
@mikaelvesavuori
mikaelvesavuori / product-documentation-template.md
Last active July 7, 2022 20:24
Product documentation template (technical docs in Markdown)

Product name

Product name  Team  Owner  Tech lead  Some link  Lifecycle stage  Tags
 My product ThatTeam  Cassie Cash  Someguy Someguyson  https://company.com/asdf  Production  backend

Quickstart

Write an easy-to-follow guide or onboarding material for new users to help them quickly do something with the software.

@mikaelvesavuori
mikaelvesavuori / localmodule.eventbridge.ts
Created May 7, 2022 16:27
Simplified local module implementation for EventBridge
//
// File and context where you use the implementation.
//
async function localModule() {
const eventbridge = createNewEventBridge();
eventbridge.emit({
source: 'commerce.order.createOrder',
type: 'OrderCreated',
metadata: {
@mikaelvesavuori
mikaelvesavuori / minimal.eventbridge.js
Created May 7, 2022 16:15
Basic minimal EventBridge implementation in JavaScript
import { EventBridgeClient, PutEventsCommand } from '@aws-sdk/client-eventbridge';
async function minimalImplementation() {
const eventBridge = new EventBridgeClient({ region: 'eu-north-1' });
const event = new PutEventsCommand({
Entries: [
{
EventBusName: 'TODO',
Source: 'dataplatformdemo.insert',
@mikaelvesavuori
mikaelvesavuori / slamax-original-poc.js
Created April 27, 2022 18:34
SlaMax original coded POC.
/**
* @description Calculates maximum composite SLA for a list of sequentially provided AWS services.
* Also, testing with custom-defined services/dependencies.
*
* @see https://aws.amazon.com/legal/service-level-agreements/
* @see https://alexewerlof.medium.com/calculating-composite-sla-d855eaf2c655
*/
/**
* @description Service SLAs.