version control api nodejs best practices

version control api nodejs best practices

//version taken out from header app.use(function(req, res, next) { req.version = req.headers[‘accept-version’]; console.log(req.version); next(); }); //version path defined app.use(‘/api’, versionRoutes({ “1.0.0”: respondV1, “2.0.0”: respondV2 })); function respondV1(req, res, next) { app.use(‘/api’,routeV1); next(); } function respondV2(req, res, next) { app.use(‘/api’,routeV2); next(); }* Here is what the above code is Doing: 1. We are using the versionRoutes…

WooCommerce Catalog Mode snippets

WooCommerce Catalog Mode snippets

function wdm_add_to_cart_checkout_redirect() { wp_safe_redirect( get_permalink( get_option( ‘woocommerce_checkout_page_id’ ) ) ); die(); } add_action( ‘woocommerce_add_to_cart’,  ‘wdm_add_to_cart_checkout_redirect’, 11 ); Here is what the above code is Doing: 1. It’s adding a new action to the woocommerce_add_to_cart hook. 2. It’s redirecting the user to the checkout page. 3. It’s using the wp_safe_redirect function to redirect the user. 4….

eact redux createSlice or createReducer

eact redux createSlice or createReducer

A good source of help is to read the Redux Toolkit docs, where it says: createSlice: A function that accepts an initial state, an object full of reducer functions, and a “slice name”, and automatically generates action creators and action types that correspond to the reducers and state. createReducer: A utility that simplifies creating Redux…