create different ssh key according the article Mac Set-Up Git
$ ssh-keygen -t rsa -C "your_email@youremail.com"
create different ssh key according the article Mac Set-Up Git
$ ssh-keygen -t rsa -C "your_email@youremail.com"
const swName = `/my-application-service-worker.js` | |
navigator.serviceWorker.register(swName) |
if (`serviceWorker` in navigator) { | |
window.addEventListener(`load`, () => { | |
navigator.serviceWorker.register(`/my-application-service-worker.js`) | |
}) | |
} |
export default function(nuxtContext) { | |
const { req, error } = nuxtContext | |
if (process.client) return | |
// here we catch the error send by the server | |
if (!req.serverError) return | |
// calling the error function will render the error layout | |
error({ | |
statusCode: req.error.statusCode || 500, | |
message: req.error.message || `a fatal error as occurred`, | |
}) |
koa.use(async function handleErrors(ctx, next) { | |
try { | |
await next() | |
} catch (error) { | |
ctx.status = 500 | |
ctx.req.serverError = error | |
try { | |
// let Nuxt handle the response | |
await nuxtMiddleware(ctx) | |
} catch (nuxtError) { |
const sessionOptions = { | |
// don't autoCommit | |
// we will handle the header update ourself | |
autoCommit: false, | |
} | |
app.use(session(sessionOptions, app)) | |
router.post(`/my-action`, koaBody(), async ctx => { | |
const { body } = ctx.request | |
const isValid = isFormValid(body) |
app.use(async function passSessionToNuxt(ctx, next) { | |
ctx.req.serverData = { | |
validation: ctx.session.validation || {}, | |
} | |
// don't persist the validation on more than one page | |
delete ctx.session.validation | |
await next() | |
}) |
export const state = () => ({ | |
validation: {}, | |
}) | |
export const UPDATE_VALIDATION = `UPDATE_VALIDATION` | |
export const mutations = { | |
[UPDATE_VALIDATION](state, payload) { | |
state.validation = payload | |
}, |
// after setting up koa-session | |
router.post(`/my-action`, koaBody(), async ctx => { | |
const { body } = ctx.request | |
// assuming that we have defined `isFormValid` before | |
const isValid = isFormValid(body) | |
if (isValid) { | |
const result = await doSomethingAsync(body) | |
} else { | |
// assuming that we have defined `getValidation` before |
// koa app creation + middleware + router creation | |
koa.use(async function handleErrors(ctx, next) { | |
try { | |
await next() | |
} catch (error) { | |
ctx.status = 500 | |
ctx.body = error | |
} | |
}) |