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
board = { | |
"1": " ", | |
"2": " ", | |
"3": " ", | |
"4": " ", | |
"5": " ", | |
"6": " ", | |
"7": " ", | |
"8": " ", | |
"9": " " |
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
taquiza_menu = { | |
:name => "Taquiza", | |
:sections => [ | |
{ | |
:name => "Tacos", | |
:description => "Freshly made blue corn tortillas", | |
:items => [ | |
{ | |
:name => "Al Pastor", | |
:description => "pork, achiote, pineapple", |
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 UsersController < ApplicationController | |
before_action :set_user, only: [:show, :edit, :update, :destroy] | |
after_action :slack_notif, only: [:create, :update, :destroy] | |
def index | |
@users = User.all | |
end | |
def show | |
end |
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
if (eventType === 'DISCONNECT') { | |
// Get all subscribers | |
const subscriptions = mapper.query(Subscription, { | |
connectionId: equals(connectionId) | |
}); | |
// Remove subscriptions | |
for await (const subscription of subscriptions) { | |
const sub = Object.assign(new Subscription(), { | |
id: `${connectionId}|${subscription.subscription.id}` | |
}); |
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
if (eventType === 'CONNECT') { | |
return { | |
statusCode: 200, | |
headers: { | |
'Sec-WebSocket-Protocol': 'graphql-transport-ws' | |
}, | |
body: '' | |
}; | |
} |
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
export const handler: Handler<APIGatewayEvent> = async (event, context, callback) => { | |
if (!event.requestContext) { | |
return { | |
statusCode: 500, | |
body: '' | |
}; | |
} | |
const { eventType, connectionId } = event.requestContext; | |
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 { ApolloLink, Operation, FetchResult, Observable } from 'apollo-boost'; | |
import { print, GraphQLError } from 'graphql'; | |
import { createClient, ClientOptions, Client } from 'graphql-ws'; | |
// See example taken from https://github.com/enisdenjo/graphql-ws#apollo-client | |
class WebSocketLink extends ApolloLink { | |
private client: Client; | |
constructor(options: ClientOptions) { | |
super(); |
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 React, { FC } from 'react'; | |
import { ApolloProvider } from '@apollo/react-hooks'; | |
import { | |
InMemoryCache, | |
ApolloClient, | |
HttpLink, | |
split, | |
} from 'apollo-boost'; | |
// WS link from example here - https://github.com/enisdenjo/graphql-ws#apollo-client |
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 { ApiGatewayManagementApi } from 'aws-sdk'; | |
export const createGateway = (requestContext: any) => | |
new ApiGatewayManagementApi({ | |
apiVersion: 'latest', | |
endpoint: `https://${requestContext.apiId} | |
.execute-api.us-east-1.amazonaws.com/${requestContext.stage}` | |
}); |
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
resources: | |
Resources: | |
connectionsTable: | |
Type: AWS::DynamoDB::Table | |
Properties: | |
TableName: CONNECTION_TABLE | |
AttributeDefinitions: | |
- AttributeName: id | |
AttributeType: S | |
KeySchema: |
OlderNewer