Skip to content

Instantly share code, notes, and snippets.

View wenindoubt's full-sized avatar
🎯
Focusing

Jeffrey Wen wenindoubt

🎯
Focusing
  • Autodesk, Inc.
  • Irvine, CA
View GitHub Profile
@wenindoubt
wenindoubt / postman-pre-request.js
Created October 1, 2021 18:18 — forked from bcnzer/postman-pre-request.js
Postman pre-request script to automatically get a bearer token from Auth0 and save it for reuse
const echoPostRequest = {
url: 'https://<my url>.auth0.com/oauth/token',
method: 'POST',
header: 'Content-Type:application/json',
body: {
mode: 'application/json',
raw: JSON.stringify(
{
client_id:'<your client ID>',
client_secret:'<your client secret>',
import { mocked } from 'ts-jest/utils';
import { Handler } from 'aws-lambda';
import { middyfy } from '@libs/lambda';
jest.mock('@libs/lambda');
describe('hello', () => {
let main;
let mockedMiddyfy: jest.MockedFunction<typeof middyfy>;
import middy from '@middy/core';
import { APIGatewayProxyEvent, APIGatewayProxyResult } from 'aws-lambda';
import { formatJSONResponse } from './apiGateway';
import { AppError } from './appError';
import MiddlewareFunction = middy.MiddlewareFunction;
export const apiGatewayResponseMiddleware = (options: { enableErrorLogger?: boolean } = {}) => {
const after: MiddlewareFunction<APIGatewayProxyEvent, any> = async (request) => {
@wenindoubt
wenindoubt / create.ts
Created June 30, 2021 19:27 — forked from fredericbarthelet/create.ts
Lamba create.ts with intrinsic service
import { DynamoDB } from 'aws-sdk';
import { ref } from './intrinsic';
import cloudformationResources, { MyTable } from './resources';
export default {
handler:'create.main',
environment: {
TABLE_NAME: ref(cloudformationResources, MyTable)
},
@wenindoubt
wenindoubt / intrinsic.ts
Created June 30, 2021 19:27 — forked from fredericbarthelet/intrinsic.ts
AWS intrinsic function resolution
import {
CloudFormationResource,
CloudFormationResources,
} from 'serverless/aws';
import { findKey } from 'lodash';
interface CloudFormationReference {
Ref: string;
}
@wenindoubt
wenindoubt / create.ts
Created June 30, 2021 19:27 — forked from fredericbarthelet/create.ts
lambda with dynamo
import { DynamoDB } from 'aws-sdk';
export default {
handler:'create.main',
environment: {
TABLE_NAME: {
Ref: 'MyTable'
}
},
events: [
@wenindoubt
wenindoubt / functions.ts
Created June 30, 2021 19:27 — forked from fredericbarthelet/functions.ts
Serverless.ts complex project imports
export { default as hello } from './hello';
export { default as goodbye } from './goodbye';
@wenindoubt
wenindoubt / functions.ts
Created June 30, 2021 19:14 — forked from fredericbarthelet/functions.ts
Serverless.ts splitting
export default {
hello: {
handler: 'index.hello'
},
goodbye: {
handler: 'index.goodbye'
}
};
@wenindoubt
wenindoubt / curl.md
Created November 22, 2017 18:58 — forked from btoone/curl.md
A curl tutorial using GitHub's API

Introduction

An introduction to curl using GitHub's API.

The Basics

Makes a basic GET request to the specifed URI

curl https://api.github.com/users/caspyin
@wenindoubt
wenindoubt / bash-template
Created January 21, 2017 16:57 — forked from renzok/bash-template
A template bash script based on google style guide with little improvements
#!/bin/bash
# Here short description of this script
# This is just a template to be used for writing new bash scripts
###
# Based on Google Style Guide: https://google-styleguide.googlecode.com/svn/trunk/shell.xml
# General remarks
# * Executables should have no extension (strongly preferred) or a .sh extension.
# * Libraries must have a .sh extension and should not be executable