-
Create a .gitignore file in the git repository if it does not contain one
-
Open up the .gitignore and add the following line to the file
node_modules
- Remove the node_modules folder from the git repository
| PLEASE CHECK THIS REPO WITH THE EXAMPLES THAT YOU CAN RUN: | |
| https://github.com/apieceofbart/async-testing-with-jest-fake-timers-and-promises | |
| // Let's say you have a function that does some async operation inside setTimeout (think of polling for data) | |
| function runInterval(callback, interval = 1000) { | |
| setInterval(async () => { | |
| const results = await Promise.resolve(42) // this might fetch some data from server | |
| callback(results) | |
| }, interval) |
| // somewhere on top | |
| import _ from 'lodash'; | |
| jest.unmock('lodash'); | |
| // then | |
| _.debounce = jest.fn((fn) => fn); |
| // EXAMPLE 1 | |
| // Let's say you want to create a function that returns different types based on argument passed. Contrived example: | |
| function returnNumberOrString(returnString: boolean) { | |
| if (returnString) { | |
| return "42" as string // cast to string to avoid literal type | |
| } | |
| return 42 as number // cast to number to avoid literal type | |
| } |
| import { AsyncAction, AsyncFulfilledAction } from '.../redux-thunk-promise'; | |
| export const FETCH = '.../FETCH'; | |
| export const FETCH_PENDING = '.../FETCH_PENDING'; | |
| export const FETCH_FULFILLED = '.../FETCH_FULFILLED'; | |
| export const FETCH_REJECTED = '.../FETCH_REJECTED'; | |
| export interface FetchAction extends AsyncAction<ApiResult> { | |
| type: typeof FETCH; | |
| } |
| declare module 'react-base-table' { | |
| import React from 'react' | |
| export interface ColumnProps<T> { | |
| key: string | |
| className?: string | ((obj: CallbackObject<T>) => string) | |
| /** Class name for the column header, could be a callback to return the class name The callback is of the shape of ({ columns, column, columnIndex, headerIndex }) => string */ | |
| headerClassName?: string | ((obj: CallbackObject<T>) => string) | |
| /** Custom style for the column cell, including the header cells */ | |
| style?: React.CSSProperties |
While a lot of Node.js guides recommend using JWT as an alternative to session cookies (sometimes even mistakenly calling it "more secure than cookies"), this is a terrible idea. JWTs are absolutely not a secure way to deal with user authentication/sessions, and this article goes into more detail about that.
Secure user authentication requires the use of session cookies.
Cookies are small key/value pairs that are usually sent by a server, and stored on the client (often a browser). The client then sends this key/value pair back with every request, in a HTTP header. This way, unique clients can be identified between requests, and client-side settings can be stored and used by the server.
Session cookies are cookies containing a unique session ID that is generated by the server. This session ID is used by the server to identify the client whenever it makes a request, and to associate session data with that request.
*S
| #!/bin/bash | |
| # This way you can customize which branches should be skipped when | |
| # prepending commit message. | |
| if [ -z "$BRANCHES_TO_SKIP" ]; then | |
| BRANCHES_TO_SKIP=(master develop test) | |
| fi | |
| BRANCH_NAME=$(git symbolic-ref --short HEAD) | |
| BRANCH_NAME="${BRANCH_NAME##*/}" |
| /* | |
| * Handling Errors using async/await | |
| * Has to be used inside an async function | |
| */ | |
| try { | |
| const response = await axios.get('https://your.site/api/v1/bla/ble/bli'); | |
| // Success 🎉 | |
| console.log(response); | |
| } catch (error) { | |
| // Error 😨 |
| import AsyncComponent from './path/to/component'; | |
| import request from 'your-request-library'; | |
| import React from 'react'; | |
| import {shallow} from 'enzyme'; | |
| import Chance from 'chance'; | |
| import chai, {expect} from 'chai'; | |
| import sinon from 'sinon'; | |
| import sinonChai from 'sinon-chai'; |