This file contains hidden or 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 * as Stripe from "stripe"; | |
| /** Config */ | |
| const stripe = new Stripe('STRIPE_API_KEY'); // Stripe account secret key goes here | |
| export async function createCustomerAndSubscribeToPlan( | |
| stripeToken: string, | |
| email: string, | |
| productPlan: string | |
| ): Promise<any> { |
This file contains hidden or 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 { APIGatewayEvent, Callback, Context, Handler } from "aws-lambda"; | |
| import { createCustomerAndSubscribeToPlan } from "./stripe-api"; | |
| interface ICreateCustomer { | |
| stripeToken: string; | |
| email: string; | |
| productPlan: string; | |
| } | |
| export const respond = (fulfillmentText: any): any => { |
This file contains hidden or 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 { APIGatewayEvent, Callback, Context, Handler } from 'aws-lambda'; | |
| export const hello: Handler = (event: APIGatewayEvent, context: Context, cb: Callback) => { | |
| const response = { | |
| statusCode: 200, | |
| body: JSON.stringify({ | |
| message: 'Go Serverless Webpack (Typescript) v1.0! Your function executed successfully!', | |
| input: event, | |
| }), | |
| }; |
This file contains hidden or 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
| const getDaysOfWeekFromGivenDate = ( | |
| date: Date | null | |
| ) => { | |
| if (date) { | |
| const startOfWeek = moment(date).startOf('isoWeek'); | |
| const weekArray = moment.weekdays(); | |
| const daysOfWeekInSelectedDate = daysOfWeek.map((d, i) => { | |
| return startOfWeek | |
| .clone() | |
| .add(i, 'd') |
This file contains hidden or 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
| const getDaysOfWeekFromGivenDate = ( | |
| date: Date | null | |
| ) => { | |
| if (date) { | |
| const startOfWeek = moment(date).startOf('isoWeek'); | |
| const weekArray = moment.weekdays(); | |
| const daysOfWeekInSelectedDate = generateWeek( | |
| startOfWeek, | |
| weekArray | |
| ); |
This file contains hidden or 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
| const isTokenValid = (token: string | null): boolean => { | |
| if (!token) { | |
| return false; | |
| } | |
| try { | |
| const decodedJwt: any = decode(token); | |
| return decodedJwt.exp >= Date.now() / 1000; | |
| } catch (e) { | |
| return false; | |
| } |
This file contains hidden or 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
| const checkIfArrayOfStrings = (arrayToCheck: any): boolean => { | |
| if (arrayToCheck && arrayToCheck instanceof Array && arrayToCheck.length) { | |
| const arrayOfNonStringValues = arrayToCheck.filter((value: any) => { | |
| return typeof value !== 'string'; | |
| }); | |
| return arrayOfNonStringValues && arrayOfNonStringValues.length | |
| } | |
| return false; | |
| }; |
This file contains hidden or 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, { Component } from 'react' | |
| class MyComponent extends Component{ | |
| state = { | |
| superHero: '' | |
| } | |
| /** Update the state */ | |
| updateFavouriteSuperHero(e){ | |
| e.preventDefault() |
NewerOlder