Optional - Set format on save and any global prettier options
npm i -D eslint prettier eslint-plugin-prettier eslint-config-prettier eslint-plugin-node eslint-plugin-html eslint-config-node
import { user } from './store.js' | |
user.set(window__SK__USER__) |
<script setup lang="ts"> | |
import { io } from 'socket.io-client' | |
const connected = ref(false) | |
onMounted(() => { | |
const socket = io(); | |
socket.on('connect', () => { | |
connected.value = socket.connected |
Optional - Set format on save and any global prettier options
npm i -D eslint prettier eslint-plugin-prettier eslint-config-prettier eslint-plugin-node eslint-plugin-html eslint-config-node
import { defineStore } from 'pinia' | |
export const useAuthStore = defineStore({ | |
id: 'auth', | |
state: () => ({ | |
isAuthenticated: false, | |
user: null | |
}), | |
actions: { | |
async nuxtServerInit() { |
<script lang="ts"> | |
import { defineComponent, toRaw } from 'vue' | |
import { | |
QueryObserver, | |
type QueryKey, | |
type QueryObserverResult, | |
type QueryClient, | |
} from '@tanstack/query-core' | |
type Todo = { | |
userId: number |
// ~/server/middleware/proxy.ts | |
import { defineEventHandler } from 'h3' | |
import { createProxyMiddleware } from 'http-proxy-middleware'; // npm install http-proxy-middleware@beta | |
const apiProxyMiddleware = createProxyMiddleware({ | |
target: 'https://jsonplaceholder.typicode.com', | |
changeOrigin: true, | |
ws: true, | |
pathRewrite: { | |
'^/api/todos': '/todos', |
const util = require('util'); | |
const exec = util.promisify(require('child_process').exec); | |
async function deployOnlyChangedFunctions() { | |
const { stdout: shaOfLostCommit } = await exec('git rev-parse HEAD'); | |
const { stdout: changedFiles } = await exec(`git log -m -1 --name-only --pretty="format:" ${shaOfLostCommit}`); | |
const functionsFolder = 'functions/modules/' | |
const filenames = changedFiles.split('\n') | |
.filter((line) => line.startsWith(functionsFolder)) | |
.map((line) => line.split('/')[2]) |
<template> | |
<div v-frag> | |
<slot /> | |
<v-snackbar v-model="show" :timeout="options.timeout" bottom right> | |
{{ text }} | |
<template v-if="options.showCloseButton" #action="{ attrs }"> | |
<v-btn | |
:color="options.closeButtonColor" | |
text | |
v-bind="attrs" |
import { AllowedComponentProps, Component, defineComponent, VNodeProps } from 'vue' | |
export type ExtractComponentProps<TComponent> = | |
TComponent extends new () => { | |
$props: infer P; | |
} | |
? Omit<P, keyof VNodeProps | keyof AllowedComponentProps> | |
: never; | |
const TestComponent = defineComponent({ |
/* Ultra lightweight Github REST Client */ | |
// original inspiration via https://gist.github.com/v1vendi/75d5e5dad7a2d1ef3fcb48234e4528cb | |
const token = 'github-token-here' | |
const githubClient = generateAPI('https://api.github.com', { | |
headers: { | |
'User-Agent': 'xyz', | |
'Authorization': `bearer ${token}` | |
} | |
}) |