TastkItqueries.ts19 matches
45// Função simples para hash de senha
6async function hashPassword(password: string): Promise<string> {
7// Em produção, use uma biblioteca de hash mais segura
8// Esta é uma implementação básica para demonstração
1516// Função para verificar senha
17async function verifyPasswordHash(password: string, hash: string): Promise<boolean> {
18const calculatedHash = await hashPassword(password);
19return calculatedHash === hash;
22// ==================== Funções de Usuário ====================
2324export async function createUser(input: CreateUserInput): Promise<User> {
25try {
26// Verificar novamente se o email ou username já existem (para evitar condições de corrida)
55}
5657export async function getUserByUsername(username: string): Promise<User | null> {
58const result = await sqlite.execute(
59`SELECT id, username, email, password_hash, created_at, updated_at
66}
6768export async function getUserByEmail(email: string): Promise<User | null> {
69const result = await sqlite.execute(
70`SELECT id, username, email, password_hash, created_at, updated_at
77}
7879export async function getUserById(id: number): Promise<User | null> {
80const result = await sqlite.execute(
81`SELECT id, username, email, created_at, updated_at
88}
8990export async function verifyPassword(plainPassword: string, hashedPassword: string): Promise<boolean> {
91return await verifyPasswordHash(plainPassword, hashedPassword);
92}
94// ==================== Funções de Projeto ====================
9596export async function createProject(input: CreateProjectInput): Promise<Project> {
97const result = await sqlite.execute(
98`INSERT INTO ${PROJECTS_TABLE} (name, color, user_id)
105}
106107export async function getProjectsByUserId(userId: number): Promise<Project[]> {
108const result = await sqlite.execute(
109`SELECT id, name, color, user_id, created_at, updated_at
117}
118119export async function getProjectById(id: number, userId: number): Promise<Project | null> {
120const result = await sqlite.execute(
121`SELECT id, name, color, user_id, created_at, updated_at
128}
129130export async function updateProject(id: number, userId: number, name: string, color?: string): Promise<Project | null> {
131const updateFields = [];
132const params = [];
162}
163164export async function deleteProject(id: number, userId: number): Promise<boolean> {
165const result = await sqlite.execute(
166`DELETE FROM ${PROJECTS_TABLE}
174// ==================== Funções de Tarefa ====================
175176export async function createTask(input: CreateTaskInput): Promise<Task> {
177const result = await sqlite.execute(
178`INSERT INTO ${TASKS_TABLE} (title, description, due_date, priority, project_id, user_id)
192}
193194export async function getTasksByProjectId(projectId: number, userId: number): Promise<Task[]> {
195const result = await sqlite.execute(
196`SELECT id, title, description, due_date, priority, completed, project_id, user_id, created_at, updated_at
211}
212213export async function getTasksByUserId(userId: number): Promise<Task[]> {
214const result = await sqlite.execute(
215`SELECT id, title, description, due_date, priority, completed, project_id, user_id, created_at, updated_at
230}
231232export async function getTaskById(id: number, userId: number): Promise<Task | null> {
233const result = await sqlite.execute(
234`SELECT id, title, description, due_date, priority, completed, project_id, user_id, created_at, updated_at
241}
242243export async function updateTask(id: number, userId: number, input: UpdateTaskInput): Promise<Task | null> {
244const updateFields = [];
245const params = [];
295}
296297export async function toggleTaskCompletion(id: number, userId: number): Promise<Task | null> {
298const result = await sqlite.execute(
299`UPDATE ${TASKS_TABLE}
308}
309310export async function deleteTask(id: number, userId: number): Promise<boolean> {
311const result = await sqlite.execute(
312`DELETE FROM ${TASKS_TABLE}
Oronet1101_script.tsx1 match
1// This script returns a random fun fact
2// You can run scripts manually in this view or call it from other vals.
3export default function getRandomFact() {
4const funFacts = [
5"Honey never spoils.",
1export default async function (req: Request): Promise<Response> {
2return Response.json({ ok: true })
3}
23// Fetch top cryptocurrencies data from CoinGecko API
4async function fetchCryptoData(limit = 50) {
5try {
6// CoinGecko has rate limits, so we need to add a delay and retry mechanism
2930// Mock data for testing when API fails
31function getMockCryptoData(limit = 10) {
32const mockCoins = [
33{
157158// Fetch detailed data for a specific cryptocurrency
159async function fetchCryptoDetails(id: string) {
160try {
161const response = await fetch(
183184// Mock data for testing when API fails
185function getMockCryptoDetails(id: string) {
186const mockDetails: Record<string, any> = {
187"bitcoin": {
259}
260261export default async function(req: Request) {
262const url = new URL(req.url);
263
Oroindex.html17 matches
143<script>
144// Format numbers with commas and appropriate decimal places
145function formatNumber(num, decimals = 2) {
146if (num === null || num === undefined) return 'N/A';
147return new Intl.NumberFormat('en-US', {
152153// Format currency with $ symbol
154function formatCurrency(num, decimals = 2) {
155if (num === null || num === undefined) return 'N/A';
156return '$' + formatNumber(num, decimals);
158159// Format large numbers with abbreviations (K, M, B, T)
160function formatLargeNumber(num) {
161if (num === null || num === undefined) return 'N/A';
162if (num < 1000) return formatNumber(num);
171172// Format percentage
173function formatPercentage(num) {
174if (num === null || num === undefined) return 'N/A';
175return formatNumber(num) + '%';
177178// Format date
179function formatDate(dateString) {
180if (!dateString) return 'N/A';
181const date = new Date(dateString);
184185// Get CSS class for price change
186function getPriceChangeClass(change) {
187return change >= 0 ? 'positive' : 'negative';
188}
189190// Get icon for price change
191function getPriceChangeIcon(change) {
192return change >= 0 ? 'fa-caret-up' : 'fa-caret-down';
193}
194195// Fetch cryptocurrency data
196async function fetchCryptoData() {
197try {
198const response = await fetch('/api/crypto');
209210// Fetch detailed data for a specific cryptocurrency
211async function fetchCryptoDetails(id) {
212try {
213const response = await fetch(`/api/crypto/${id}`);
223224// Populate the crypto table
225function populateCryptoTable(data) {
226const tableBody = document.getElementById('cryptoTableBody');
227tableBody.innerHTML = '';
266267// Filter cryptocurrencies based on search input
268function filterCryptoTable() {
269const searchInput = document.getElementById('searchInput');
270const filter = searchInput.value.toLowerCase();
283284// Open cryptocurrency detail modal
285async function openCryptoModal(id) {
286const modal = document.getElementById('cryptoModal');
287modal.classList.remove('hidden');
332333// Create a dummy price chart (in a real app, you'd use historical data)
334function createDummyPriceChart(currentPrice) {
335const ctx = document.getElementById('priceChart').getContext('2d');
336
374tooltip: {
375callbacks: {
376label: function(context) {
377return formatCurrency(context.raw);
378}
389y: {
390ticks: {
391callback: function(value) {
392return formatCurrency(value);
393}
400401// Close cryptocurrency detail modal
402function closeCryptoModal() {
403const modal = document.getElementById('cryptoModal');
404modal.classList.add('hidden');
406407// Initialize the app
408async function initApp() {
409// Set up view source link
410const viewSourceLink = document.getElementById('viewSourceLink');
Orocrypto-tracker.tsx1 match
2// Fetches and displays current prices for popular cryptocurrencies
34export default async function (req: Request) {
5try {
6// Fetch cryptocurrency data from CoinGecko API
Orocrypto-chance.tsx8 matches
1112// Initialize or get existing stats
13async function getStats(): Promise<GameStats> {
14try {
15const stats = await blob.getJSON("crypto_chance_stats") as GameStats;
2728// Update stats after a game
29async function updateStats(win: boolean): Promise<GameStats> {
30const stats = await getStats();
31stats.totalFlips++;
4142// Simulate a coin flip
43function flipCoin(): "heads" | "tails" {
44return Math.random() < 0.5 ? "heads" : "tails";
45}
4647// Get a crypto-themed message based on the result
48function getCryptoMessage(win: boolean): string {
49if (win) {
50const messages = [
68}
6970// Main handler function
71export default async function(req: Request): Promise<Response> {
72// Handle different HTTP methods
73if (req.method === "POST") {
195const losses = document.getElementById('losses');
196
197function disableButtons(disable) {
198headBtn.disabled = disable;
199tailsBtn.disabled = disable;
207}
208
209async function playGame(choice) {
210disableButtons(true);
211resultDiv.classList.add('hidden');
Oro04_email.tsx1 match
2// Click "Run", copy and paste the email address and send an email to it.
3// This example will log the email details received.
4export default async function emailHandler(email: Email){
5console.log("Email received!", email.from, email.subject, email.text);
6for (const file of email.attachments) {
Oro03_cron.tsx1 match
2// Configure the timer with the 🕒 icon in the top right.
3// This example just logs the current time.
4export function scheduledHandler() {
5const timestamp = new Date().toISOString();
6console.log(`Cron val executed at: ${timestamp}`);
Oro02_http.tsx1 match
2// Access it via its public URL (you can also pick a nicer subdomain).
3// Try adding ?name=YourName to the URL!
4export default function httpHandler(req: Request): Response {
5const url = new URL(req.url);
6const name = url.searchParams.get("name") || "Friend";