Skip to content

Instantly share code, notes, and snippets.

View nadeesha's full-sized avatar

Nadeesha Cabral nadeesha

View GitHub Profile
import { graphql } from 'graphql';
import * as fetch from 'isomorphic-fetch';
interface IResponse<T> {
data: T;
}
export default class GraphqlClient {
private static clientInstance: GraphqlClient;
await sendWelcomeEmail(...);
client.doOperation('mutation', 'mutation editUser ($welcomeEmailSent: true) { ... }');
{
"listings" : [
{
"highlights" : [
"857 SQM WITH 60M FRONTAGE",
"60K HOLDING INCOME",
"ENORMOUS POTENTIAL"
],
"price" : 859000,
"mainPhoto" : {
{
"compilerOptions": {
"outDir": "./lib/",
"module": "commonjs",
"target": "es5",
"jsx": "react",
"typeRoots": [
"custom-types/**/*"
],
"types": [
functions:
heartbeat:
handler: lib/endpoints/heartbeat.heartbeat
events:
- http:
path: heartbeat
method: get
...
import Utils from 'utils';
import { expect } from 'chai';
import { myFunc, myOtherFunctionWhichCallsUtl } from 'myModule';
describe('My awesome suite', () => {
it('should produce proper output', () => {
const actual = myFunc(arg1, arg2, arg3);
const expected = { foo: 'bar' }
expect(actual).to.eql(expected);
// @t "produces output" myFunc('foo', 'bar', 'baz') ~equals {'foo': 'bar'}
export function myFunc(arg1, arg2, arg3) {
/* ... function content ... */
}
// @t "calls util" myOtherFunctionWhichCallsUtil(spy('util')) ~expect spy('util').calledOnce
export function myOtherFunctionWhichCallsUtil(utilFn = Utils.utilFunction) {
/* ... function content ... */
utilFn();
}
// @t "foo" foo(1) ~does-my-domain-specific-stuff
export function foo(arg) {
// does something domain specific
}
// @t "foo" foo(1) ~does-my-domain-specific-stuff
export function bar(arg) {
// does something domain specific, similar to foo()
}
export const Person = props =>
<div>
<span>{props.firstName}</span>
<span>{props.lastName}</span>
{
props.age > 18 ?
'Adult' : 'NotAdult'
}
</div>
import * as AWS from "aws-sdk";
const configureBucketLifecycle = (s3, bucketName): Promise<void> => {
return new Promise((resolve, reject) => {
s3.putBucketLifecycleConfiguration({
Bucket: bucketName,
LifecycleConfiguration: {
Rules: [
{
ID: "Purge if older than 30 days",