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
// Here's the original article for function composition and piping: https://blog.logrocket.com/how-to-create-compose-function-typescript/ | |
interface Context { | |
user: string; | |
content: string; | |
} | |
// And this is how to implement the same method using Promises: | |
const compose = <T>(fn1: (a: T) => Promise<T>, ...fns: Array<(a: T) => Promise<T>>) => | |
fns.reduce((prevFn, nextFn) => async (value) => await prevFn(value).then(nextFn), fn1); |
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 layout = ['inline', 'stacked'] as const; | |
export type Layout = typeof layout[number]; | |
// Then it can be used in React props | |
interface Props { | |
layout: Layout; | |
} | |
const Component = ({ layout }: Props) => ( |
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, { Fragment, useEffect, useRef } from 'react'; | |
import { useQuery, useMutation } from '@apollo/client'; | |
import { List, Typography } from 'antd'; | |
import PageLoader from '../PageLoader/PageLoader'; | |
import ChatInput from './components/ChatInput'; | |
import ChatComment from './components/ChatComment'; | |
import { ADD_MESSAGE, CHAT_ROOM, COMMENTS_SUBSCRIPTION } from './Chat.graphql'; | |
import { AddResponse, ChatRequest, ChatResponse, MessageInput, NewMessage, Props } from './Chat.types'; | |
import styles from './Chat.less'; |
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 axios, { AxiosInstance, AxiosRequestConfig } from 'axios'; | |
import tracingLogger from '../../logging/tracingLogger'; | |
interface RequestConfig extends AxiosRequestConfig { | |
metadata: { | |
startTime: number; | |
}; | |
} | |
const createHttpClient = (baseURL: string, defaultHeaders: any = {}): AxiosInstance => { |
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
/// <reference types="cypress" /> | |
context('Invite Client', () => { | |
after(() => { | |
cy.logout().then(() => { | |
cy.url().should('contains', Cypress.env('base_login_url')); | |
}); | |
}); | |
it('should display the profile page with confirmed email', () => { |
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 * as dateService from './dateService'; | |
const nowMock = dateService.now as jest.MockedFunction<typeof dateService.now>; | |
describe('some service', () => { | |
const mockNow = 'now'; | |
beforeEach(() => { | |
nowMock.mockReturnedValue(mockNow); | |
}); |
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
{ | |
"diff": true, | |
"extension": ["ts", "js"], | |
"package": "./package.json", | |
"reporter": "spec", | |
"slow": 75, | |
"timeout": 2000, | |
"watch-files": ["src/**/*.js", "src/**/*.ts"], | |
"watch-extensions": ["ts", "js"], | |
"require": ["ts-node/register"] |
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 from 'react'; | |
import { Avatar } from 'antd'; | |
import { shallow, ShallowWrapper } from 'enzyme'; | |
import ColourAvatar from './ColourAvatar'; | |
describe('ColourAvatar', () => { | |
let wrapper: ShallowWrapper; | |
const defaultProps: any = { |
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
public static IAppBuilder ConfigureSerilog(this IAppBuilder app, HttpConfiguration config) | |
{ | |
config.Services.Add(typeof(IExceptionLogger), new SerilogExceptionLogger()); | |
var assembly = typeof(SerilogConfig).Assembly.GetName(); | |
var configurationProvider = new ConfigurationProvider(AppSettingKey.Prefix); | |
var logEventLevel = configurationProvider.Get(AppSettingKey.SerilogLoggingLevel, LogEventLevel.Error); | |
const string logFileName = "talentsearch-api.json"; | |
var logFilePath = Path.Combine(configurationProvider.Get(AppSettingKey.SerilogFilePath), logFileName); |
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
################################################################################################### | |
#### Copyright 2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. | |
#### | |
#### Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file | |
#### except in compliance with the License. A copy of the License is located at | |
#### | |
#### http://aws.amazon.com/apache2.0/ | |
#### | |
#### or in the "license" file accompanying this file. This file is distributed on an "AS IS" | |
#### BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
NewerOlder