Which is better? YOU DECIDE
# toml
[build]
command = "npm run build" |
[Settings] | |
ID = "Your_Site_ID" | |
# Settings in the [build] context are global and are applied to all contexts unless otherwise overridden by more specific contexts. | |
[build] | |
# This is the directory to change to before starting a build. | |
base = "project/" | |
# NOTE: This is where we will look for package.json/.nvmrc/etc, not root. | |
# This is the directory that you are publishing from (relative to root of your repo) |
exports.handler = (event, context, callback) => { | |
const response = { | |
statusCode: 301, | |
headers: { | |
Location: 'https://google.com', | |
} | |
}; | |
return callback(null, response); | |
} |
<?php | |
/* | |
Plugin Name: Homepage Settings for BigBang | |
Plugin URI: http://www.inboundnow.com/ | |
Description: Adds additional functionality to the big bang theme. | |
Author: David Wells | |
Author URI: http://www.inboundnow.com | |
*/ | |
// Specify Hooks/Filters |
/* Using a JavaScript proxy for a super low code REST client */ | |
// via https://dev.to/dipsaus9/javascript-lets-create-aproxy-19hg | |
// also see https://towardsdatascience.com/why-to-use-javascript-proxy-5cdc69d943e3 | |
// also see https://github.com/fastify/manifetch | |
// also see https://github.com/flash-oss/allserver | |
// and https://gist.github.com/v1vendi/75d5e5dad7a2d1ef3fcb48234e4528cb | |
const createApi = (url) => { | |
return new Proxy({}, { | |
get(target, key) { |
function removeAccessTokenFromUrl() { | |
const { history, location } = window | |
const { search } = location | |
if (search && search.indexOf('access_token') !== -1 && history && history.replaceState) { | |
// remove access_token from url | |
const cleanSearch = search.replace(/(\&|\?)access_token([_A-Za-z0-9=\.%]+)/g, '').replace(/^&/, '?') | |
// replace search params with clean params | |
const cleanURL = location.toString().replace(search, cleanSearch) | |
// use browser history API to clean the params | |
history.replaceState({}, '', cleanURL) |
const props = { | |
text: 'hello', | |
boolean: true, | |
array: ['hi', 'there', true], | |
object: { | |
cool: true, | |
nice: 'awesome' | |
}, | |
func: () => {}, |
Which is better? YOU DECIDE
# toml
[build]
command = "npm run build" |
/* Helper buddy for removing async/await try/catch litter 🗑 */ | |
function O_o(promise) { | |
return promise.then(data => { | |
if (data instanceof Error) return [data] | |
return [null, data] | |
}).catch(err => [err]) | |
} | |
/* Look ma, no try/catch */ | |
async function usageExample(params) { |
/* Native Error types https://mzl.la/2Veh3TR */ | |
const nativeExceptions = [ | |
EvalError, RangeError, ReferenceError, SyntaxError, TypeError, URIError | |
].filter((except) => typeof except === 'function') | |
/* Throw native errors. ref: https://bit.ly/2VsoCGE */ | |
function throwNative(error) { | |
for (const Exception of nativeExceptions) { | |
if (error instanceof Exception) throw error | |
} |
module.exports = (event, context, callback) => { | |
let name | |
if (event.pathParameters && event.pathParameters.name) { | |
name = event.pathParameters.name | |
} | |
/* generate the hello paragraph */ | |
const helloParagraph = greetPerson(name) | |
// callback is sending HTML back |