1// Chat functionality
23// Fetch chat messages
4export async function fetchChatMessages(limit = 50) {
5try {
6const response = await fetch(`/api/chat?limit=${limit}`);
1617// Send a new chat message
18export async function sendChatMessage(userName, message) {
19try {
20const response = await fetch('/api/chat', {
4243// Format date for display
44function formatDate(dateString) {
45const date = new Date(dateString);
46return date.toLocaleString();
4849// Render chat messages
50export function renderChatMessages(messages, container) {
51if (!messages || messages.length === 0) {
52container.innerHTML = '<div class="text-center text-gray-500">No messages yet. Start the conversation!</div>';
8788// Initialize chat form submission
89export function initChatForm(formElement, userNameInput, onSuccess) {
90const chatSubmitButton = document.getElementById('chat-submit-button');
91const usernameWarning = document.getElementById('username-warning');
92const usernameRequired = document.getElementById('username-required');
93
94// Function to check if username is provided
95function checkUsername() {
96const userName = userNameInput.value.trim();
97const hasUsername = !!userName;
153154// Poll for new messages
155export function startChatPolling(interval, callback) {
156// Initial fetch
157callback();
1// Job posting related functionality
23// Fetch all job postings
4export async function fetchJobs() {
5try {
6const response = await fetch('/api/jobs');
1617// Create a new job posting
18export async function createJob(jobData) {
19try {
20const response = await fetch('/api/jobs', {
3940// Format date for display
41function formatDate(dateString) {
42const date = new Date(dateString);
43return date.toLocaleString();
4546// Render job listings
47export function renderJobs(jobs, container) {
48if (!jobs || jobs.length === 0) {
49container.innerHTML = '<li class="px-4 py-4 sm:px-6 text-gray-500">No job postings available.</li>';
6970// Initialize job form submission
71export function initJobForm(formElement, onSuccess) {
72formElement.addEventListener('submit', async (event) => {
73event.preventDefault();
17}
1819// Helper function to format dates
20export function formatDate(dateString: string): string {
21const date = new Date(dateString);
22return date.toLocaleString();
Jobsqueries.ts4 matches
2021// Job posting queries
22export async function getAllJobs(): Promise<JobPosting[]> {
23const result = await sqlite.execute(
24`SELECT * FROM ${JOB_POSTINGS_TABLE} ORDER BY created_at DESC`
27}
2829export async function createJob(job: Omit<JobPosting, "id" | "created_at">): Promise<JobPosting> {
30const created_at = new Date().toISOString();
31
4142// Chat message queries
43export async function getChatMessages(limit = 50): Promise<ChatMessage[]> {
44const result = await sqlite.execute(
45`SELECT * FROM ${CHAT_MESSAGES_TABLE}
51}
5253export async function createChatMessage(message: Omit<ChatMessage, "id" | "created_at">): Promise<ChatMessage> {
54const created_at = new Date().toISOString();
55
Jobsmigrations.ts1 match
5export const CHAT_MESSAGES_TABLE = "chat_messages_v1";
67export async function runMigrations() {
8// Create job postings table
9await sqlite.execute(`
25โ โโโ database/
26โ โ โโโ migrations.ts # Schema definitions
27โ โ โโโ queries.ts # DB query functions
28โ โโโ routes/ # Route modules
29โ โ โโโ jobs.ts # Job posting endpoints
WaitTimeProxymain.tsx1 match
1export async function main() {
2let res = await fetch("https://queue-times.com/parks.json");
3let data = await res.json();
Landing-Pageindex.ts4 matches
1export default async function (req: Request) {
2const html = `<!DOCTYPE html>
3<html lang="en">
463<script>
464// Mobile menu toggle
465document.getElementById('mobile-menu-button').addEventListener('click', function() {
466const mobileMenu = document.getElementById('mobile-menu');
467mobileMenu.classList.toggle('hidden');
470// Smooth scrolling for anchor links
471document.querySelectorAll('a[href^="#"]').forEach(anchor => {
472anchor.addEventListener('click', function (e) {
473e.preventDefault();
474
494// Add to cart animation
495document.querySelectorAll('.product-card button').forEach(button => {
496button.addEventListener('click', function() {
497this.innerHTML = '<i class="fas fa-check"></i>';
498setTimeout(() => {
Demostripe-to-discord.ts8 matches
35* Main handler for Stripe webhook events
36*/
37export default async function(req: Request): Promise<Response> {
38// Only allow POST requests
39if (req.method !== 'POST') {
96* Format a Stripe event into a Discord message
97*/
98function formatStripeEventForDiscord(event: Stripe.Event): any {
99// Base embed structure
100const embed: any = {
162* Send a formatted message to Discord
163*/
164async function sendToDiscord(webhookUrl: string, message: any): Promise<void> {
165const response = await fetch(webhookUrl, {
166method: 'POST',
180* Format a human-readable title from an event type
181*/
182function formatEventTitle(eventType: string): string {
183const parts = eventType.split('.');
184const entity = parts[0];
211* Get the appropriate color for an event type
212*/
213function getColorForEvent(eventType: string): number {
214if (eventType.includes('succeeded') || eventType.includes('created') || eventType.includes('paid')) {
215return COLORS.success;
228* Format a currency amount
229*/
230function formatAmount(amount: number, currency: string): string {
231const formatter = new Intl.NumberFormat('en-US', {
232style: 'currency',
242* Format a date range
243*/
244function formatDateRange(startTimestamp: number, endTimestamp: number): string {
245const start = new Date(startTimestamp * 1000);
246const end = new Date(endTimestamp * 1000);
260* Get subscription plan name
261*/
262function getSubscriptionPlanName(subscription: Stripe.Subscription): string {
263if (!subscription.items?.data?.length) {
264return 'N/A';
automate-workflowsREADME.md1 match
67- `types.ts` - TypeScript interfaces and types
8- `utils.ts` - Utility functions for parsing commits and generating markdown
910## Key Components