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
const express = require('express') | |
const serverless = require('serverless-http') | |
const bodyParser = require('body-parser') | |
const pool = require('./configs/dbConfig') | |
const app = express() | |
app.use(bodyParser.json()) | |
app.use(bodyParser.urlencoded({ extended: true })) |
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
const modulePath = './someFile.js'; // path of module | |
// dynamic import() module | |
import(modulePath).then(module => { | |
return module.default; // return default function of es module | |
}); |
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
# serverless.yml | |
service: pokemon-service | |
provider: | |
name: aws | |
runtime: nodejs8.10 | |
stage: dev | |
region: us-east-1 | |
memorySize: 512 |
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
# serverless.yml | |
service: pokemon-service | |
provider: | |
name: aws | |
runtime: nodejs8.10 | |
stage: dev | |
region: us-east-1 | |
memorySize: 512 |
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
# serverless.yml | |
service: pokemon-service | |
provider: | |
name: aws | |
runtime: nodejs8.10 | |
stage: dev | |
region: us-east-1 | |
memorySize: 512 |
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
// filename: asyncComponent.jsx | |
import React, { Component } from "react"; | |
const asyncComponent = (getComponent) => { | |
// return AsyncComponent class component | |
return class AsyncComponent extends Component { | |
static Component = null; | |
state = { | |
Component: AsyncComponent.Component // first time similar to static Component = null | |
}; |
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, { Component, Fragment } from "react" | |
class CommentList extends Component { | |
constructor() { | |
super() | |
this.state = { comments: [] } | |
} | |
componentDidMount() { | |
fetch("https://jsonplaceholder.typicode.com/comments") |
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, { useState, useEffect, useRef, } from "react"; | |
const useElementResizer = (ref) => { | |
const [contentRect, setContentRect] = useState(ref.current ? ref.current.getBoundingClientRect() : {}); | |
useEffect(() => { | |
if (!ref.current) return; | |
const observer = new window.ResizeObserver(entries => setContentRect(entries[0].contentRect)); | |
observer.observe(ref.current); |
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, { Suspense } from "react"; | |
import { createCache, createResource } from "simple-cache-provider"; | |
const cache = createCache(); | |
const readText = createResource((text) => { | |
return new Promise((resolve, reject) => { | |
setTimeout(() => { | |
resolve(text); | |
}, 1000); | |
}); |
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
{ | |
"editor.fontFamily": "'Source Code Pro', Menlo, Monaco, 'Courier New', monospace", | |
"terminal.integrated.fontFamily": "'Source Code Pro', 'Inconsolata for Powerline', monospace", | |
"editor.fontSize": 16, | |
"editor.fontWeight": "500", | |
"editor.lineHeight": 24.65, | |
"editor.letterSpacing": 0.5, | |
"files.trimTrailingWhitespace": true, | |
"prettier.eslintIntegration": true, | |
"editor.cursorStyle": "line", |