Skip to content

Instantly share code, notes, and snippets.

View daaru00's full-sized avatar
🐢

Fabio Gollinucci daaru00

🐢
View GitHub Profile
@daaru00
daaru00 / template.yaml
Created March 4, 2024 08:24
API Gateway mocked API example template
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: Mocked HTTP API
Parameters:
ThrottlingRateLimit:
Type: Number
Description: The rate limit for the mock API.
Default: 1
@daaru00
daaru00 / session.mjs
Created February 22, 2024 11:55
Session management using encrypted server-only cookie
import crypto from 'crypto'
const COOKIE_NAME = 'session'
const COOKIE_GET_HEADER = 'Cookie'
const COOKIE_SET_HEADER = 'Set-Cookie'
const ENCRYPTION_ALGORITHM = 'aes-256-cbc'
/**
* Decode session from cookie header
*
@daaru00
daaru00 / template.yaml
Last active October 3, 2022 19:24
Use EventBridge events to execute code when the CloudFormation stack itself is created
AWSTemplateFormatVersion: "2010-09-09"
Transform: "AWS::Serverless-2016-10-31"
Resources:
LogGroup:
Type: AWS::Logs::LogGroup
Properties:
LogGroupName: !Sub /aws/lambda/${StackCreatedFunction}
RetentionInDays: 7
@daaru00
daaru00 / index.js
Created August 5, 2022 14:01
X-Ray integration with Lambda
const AWSXRay = require('aws-xray-sdk')
AWSXRay.setLogger(console)
/**
* Lambda handler
*/
exports.handler = async (event) => {
console.log(JSON.stringify(event))
@daaru00
daaru00 / useEvents.js
Last active December 28, 2021 11:28
Vue 3 composition API events bus implementation
const eventBus = new Comment('global-event-bus');
const listeners = {};
export const EVENT_NAME = 'MyEventName';
export default function () {
/**
* @param {string} event
* @param {function} callback
* @returns {number} index
@daaru00
daaru00 / template.yml
Created July 8, 2021 14:51
A SAM template that describe an AWS CodeBuild pipeline that build a static website and deploy it to an S3 Bucket and invalidate the CloudFront distribution.
AWSTemplateFormatVersion: 2010-09-09
Transform:
- AWS::Serverless-2016-10-31
# Template Information
Description: "Personal Website Deploy Pipeline"
# Template Parameters
@daaru00
daaru00 / template.yml
Created July 8, 2021 14:44
A SAM template that describe an Amazon CloudFront distribution that serve a static website from an S3 Bucket.
AWSTemplateFormatVersion: 2010-09-09
Transform:
- AWS::Serverless-2016-10-31
# Template Information
Description: "Personal Website"
# Template Parameters
@daaru00
daaru00 / template.yml
Created June 15, 2021 08:47
A SAM template that describe an Amazon CloudFront distribution that redirect all request to a specific URL using a CloudFront Function
AWSTemplateFormatVersion: 2010-09-09
Transform:
- AWS::Serverless-2016-10-31
# Template Information
Description: "Website redirect"
# Template Parameters
@daaru00
daaru00 / lambda.js
Last active February 13, 2021 15:31
AWS CloudFormation manage secrets with System Manager Parameter
const axios = require('axios')
/**
* AWS clients
*/
const SSM = require('aws-sdk/clients/ssm')
const ssm = new SSM()
/**
* Lambda handler
@daaru00
daaru00 / App.vue
Last active November 21, 2020 22:54
Storyblok rich text render component
<template>
<div id="app">
<!-- get page data -->
<vs-rich-text :document="doc" />
</div>
</template>