Skip to content

Instantly share code, notes, and snippets.

View zvekov's full-sized avatar
🚀
⚪🔴⚪

Yury Zvekau zvekov

🚀
⚪🔴⚪
View GitHub Profile
@zvekov
zvekov / generateTypes.mjs
Created November 7, 2024 09:04
generate openapi types
import { exec } from "child_process";
const apiUrl = process.env.VITE_API_URL;
const command = `npx openapi-typescript ${apiUrl}/docs/openapi.yaml -o ./src/app/api/v1.d.ts`;
exec(command, (error, stdout, stderr) => {
if (error) {
console.error(`error: ${error.message}`);
return;
}
@zvekov
zvekov / removeTrailingSlash.global.js
Created September 30, 2022 08:13
Remove trailing slash for Nuxt 3
// ~/middleware/removeTrailingSlash.global.js
export default defineNuxtRouteMiddleware((to) => {
if (to.path !== '/' && to.path.endsWith('/')) {
const { path, query, hash } = to;
const nextPath = path.replace(/\/+$/, '') || '/';
const nextRoute = { path: nextPath, query, hash };
return navigateTo(nextRoute, { redirectCode: 301 });
}
});
@zvekov
zvekov / addTrailingSlash.global.js
Created September 30, 2022 08:10
Add trailing slash for Nuxt 3
// ~/middleware/addTrailingSlash.global.js
export default defineNuxtRouteMiddleware((to) => {
if (to.path !== '/' && !to.path.endsWith('/')) {
const { path, query, hash } = to;
const nextRoute = { path: path + '/', query, hash };
return navigateTo(nextRoute, { redirectCode: 301 });
}
});
@zvekov
zvekov / yandex-map.vue
Last active January 14, 2024 22:24
Lazy Yandex Map
<template>
<div>
<div id="map"/>
</div>
</template>
<script>
export default {
mounted() {
this.load_yamap_obj('https://api-maps.yandex.ru/2.1/?lang=ru_RU&apikey=YOUR_KEY')
@zvekov
zvekov / auth.js
Last active February 21, 2020 22:25
Strapi Auth (store+register+login+reset+change password pages for Nuxt)
import axios from "axios";
const cookieparser = require("cookieparser");
import Cookie from "js-cookie";
export const state = () => ({
user: null,
token: null
});
export const mutations = {
@zvekov
zvekov / .dircolors
Last active December 25, 2018 23:35
UI colors for bash (terminal, linux console). Place this file to user's home directory. More: #
TERM Eterm
TERM ansi
TERM color-xterm
TERM con[0-9]*x[0-9]*
TERM cons25
TERM console
TERM cygwin
TERM dtterm
TERM eterm-color
TERM gnome