Skip to content

Instantly share code, notes, and snippets.

@behnamonline
behnamonline / prompt.txt
Created November 13, 2026 03:56
create shop template example
یک فروشگاه اینترنتی برام بساز با html/javascript
تمش نارنجی قرمز دارک مود دکمه نئونی شیشه ای مدرن باشه
برای فروشگاه کفش و لباس میخوام
محصولات
عنوان/توضیحات/قیمت/تصویر
سبد خرید داشته باشه
@behnamonline
behnamonline / prompt.txt
Created November 13, 2026 03:38
create php shop using prompt
این پروژه php ببین
یک فروشگاهه
یک فایل html هم برات فرستادم
یک فروشگاه اینترنتی برای کیف و کفش میخوام
طبق منطق اون پروژه php فروشگاه کیف و کفشمو بسازش
و درنهایت فایل کل پروژه رو به صورت فایل zip بهم بده
سورس از: https://github.com/behnamonline/php-simple-shop
@behnamonline
behnamonline / nuxt.config.snippet.ts
Created November 6, 2026 07:29
Nuxt config snippet that loads the Telegram Mini App SDK (telegram-web-app.js) globally via app.head.script, exposing window.Telegram.WebApp.
app: {
head: {
script: [
{ src: "https://telegram.org/js/telegram-web-app.js?64" }
]
}
}
@behnamonline
behnamonline / tgRequest.ts
Created November 6, 2026 07:27
Tiny $fetch wrapper for Telegram Mini Apps (Nuxt) that automatically attaches the WebApp initData as an Authorization: tma <initData> header on every request.
export function req<T = any>(url: string, options: any = {}): Promise<T> {
return $fetch<T>(url, {
...options,
headers: {
...options.headers,
Authorization: `tma ${window.Telegram?.WebApp?.initData || ''}`,
},
})
}
@behnamonline
behnamonline / tgAuth.ts
Created November 6, 2026 07:23
Validate Telegram Mini App (WebApp) initData in a Nuxt/Nitro server handler: HMAC-SHA256 signature check, timing-safe comparison, and auth_date expiry.
import { createHmac, timingSafeEqual } from 'node:crypto'
export function tgAuth(event: any, maxAge = 86400) {
const auth = getHeader(event, 'authorization') || ''
const initData = auth.startsWith('tma ') ? auth.slice(4) : ''
const telegramBotToken = "YOUR_BOT_TOKEN"
const fail = () => {
throw createError({ statusCode: 403, statusMessage: 'Forbidden' })
}
@behnamonline
behnamonline / wrangler.jsonc
Created November 5, 2026 03:18
nuxt db cloudflare wrangler.jsonc
{
"d1_databases":[
{
"database_name": "your_database_name",
"database_id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"binding": "db_link"
}
]
}
@behnamonline
behnamonline / initdb.ts
Created November 3, 2026 23:51
nuxt create table example
import { myDB } from "./db";
export default defineEventHandler(async (e) => {
const db = myDB();
return await db.sql`
create table if not exists messages (
id integer primary key autoincrement,
message text
)
`
@behnamonline
behnamonline / useapi.vue
Created November 2, 2026 21:51
nuxt use api example
<script setup lang="ts">
const { data } = await useFetch('/api/hello');
</script>
<template>
<h1>Use API</h1>
@behnamonline
behnamonline / hello.ts
Created November 2, 2026 21:47
nuxt api example
export default defineEventHandler(async (event) => {
return {
message: "hello I am api",
status: 'ok',
}
});
@behnamonline
behnamonline / db.ts
Created November 2, 2026 21:31
Dynamic database selector for Nuxt 3 (Nitro) to automatically switch between local SQLite in development and Cloudflare D1 in production
export const myDB = () => {
if (import.meta.dev) {
return useDatabase('mainDB_local');
}
return useDatabase('mainDB_cf');
};