Skip to content

Instantly share code, notes, and snippets.

Avatar

Alessandro Giordo bovas85

View GitHub Profile
@bovas85
bovas85 / axios.js plugin
Last active Feb 12, 2021
NuxtServerInit caching mechanism
View axios.js plugin
import { cacheAdapterEnhancer } from 'axios-extensions'
import LRUCache from 'lru-cache'
const ONE_HOUR = 1000 * 60 * 60
const defaultCache = new LRUCache({ maxAge: ONE_HOUR })
export default function ({ $axios }) {
const defaults = $axios.defaults
// https://github.com/kuitos/axios-extensions
defaults.adapter = cacheAdapterEnhancer(defaults.adapter, {
View gist:83a06f4dd899caa4a6d3faa566c8a2a5
import Vuex from "vuex";
import Config from "~/assets/config.js";
let arr = [];
let count = 0;
const createStore = () => {
return new Vuex.Store({
...
actions: {
async nuxtServerInit ({ commit }, { app }) {
@bovas85
bovas85 / store.js
Created Apr 10, 2018
Cache API calls in Vuex on nuxtServerInit
View store.js
import Vuex from "vuex";
import axios from "axios";
import Config from "~/assets/config.js";
const api = axios.create();
let arr = [];
let count = 0;
/**
* This is the secret sauce.
* If the data being requested is cached, subsequent API calls will not be made
* During a nuxt generate, nuxtServerInit will be called for every page
View LetsEncrypt.ps1
Import-Module -Name D:\Temp\ACME-posh\ACMEPowerShell.psd1
$domain = "mydomain.com"
$certificiatePassword = "abcd1234"
$email = "letsencrypt@mydomain.com"
$vault = "D:\Vault\{0}\{1}" -f $domain, [guid]::NewGuid()
mkdir $vault
cd $vault
Initialize-ACMEVault -BaseURI https://acme-v01.api.letsencrypt.org/
New-ACMERegistration -Contacts mailto:$email