24- Stores the first 1000 digits of Pi
25- Runs as an HTTP-triggered Val on Val Town
26- No external dependencies or API calls required
2728## Future Improvements
15app.use("*", cors());
1617// API routes
18app.get("/api/products", async (c) => {
19try {
20const products = await getProducts();
26});
2728app.get("/api/products/:id", async (c) => {
29try {
30const id = c.req.param("id");
yyyCartSidebar.tsx1 match
21const handleCheckout = () => {
22// In a real implementation, this would redirect to Shopify checkout
23// or integrate with their Checkout API
24alert("In a real implementation, this would redirect to Shopify checkout.");
25};
52setSelectedProduct(existingProduct);
53} else {
54// Fetch product details from API
55const response = await fetch(`/api/products/${productId}`);
56if (!response.ok) {
57throw new Error("Failed to fetch product details");
yyyshopify.ts13 matches
1import { Product, ProductVariant } from "../shared/types";
23// Shopify API credentials from environment variables
4const SHOPIFY_API_KEY = Deno.env.get("SHOPIFY_API_KEY");
5const SHOPIFY_API_SECRET = Deno.env.get("SHOPIFY_API_SECRET");
6const SHOPIFY_STORE_URL = Deno.env.get("SHOPIFY_STORE_URL");
78// Check if credentials are available
9const hasCredentials = SHOPIFY_API_KEY && SHOPIFY_API_SECRET && SHOPIFY_STORE_URL;
1011// Sample poster products data for development/demo
112113/**
114* Fetches products from Shopify API or returns sample data if credentials are not available
115*/
116export async function getProducts(): Promise<Product[]> {
121
122try {
123// Shopify GraphQL API query to fetch products
124const query = `
125{
165`;
166
167const response = await fetch(`${SHOPIFY_STORE_URL}/api/2023-10/graphql.json`, {
168method: "POST",
169headers: {
170"Content-Type": "application/json",
171"X-Shopify-Access-Token": SHOPIFY_API_SECRET!
172},
173body: JSON.stringify({ query })
175
176if (!response.ok) {
177throw new Error(`Shopify API error: ${response.status} ${response.statusText}`);
178}
179
218
219try {
220// Shopify GraphQL API query to fetch a single product
221const query = `
222{
258`;
259
260const response = await fetch(`${SHOPIFY_STORE_URL}/api/2023-10/graphql.json`, {
261method: "POST",
262headers: {
263"Content-Type": "application/json",
264"X-Shopify-Access-Token": SHOPIFY_API_SECRET!
265},
266body: JSON.stringify({ query })
268
269if (!response.ok) {
270throw new Error(`Shopify API error: ${response.status} ${response.statusText}`);
271}
272
7```
8โโโ backend/
9โ โโโ index.ts # Main API entry point with Hono
10โ โโโ shopify.ts # Shopify API integration
11โ โโโ routes/ # API route handlers
12โโโ frontend/
13โ โโโ components/ # React components
31- Backend: Hono framework on Val Town
32- Frontend: React with Tailwind CSS
33- Data: Shopify API integration
34- Deployment: Val Town HTTP trigger
3536## Setup
37381. Set up your Shopify store and obtain API credentials
392. Add your Shopify API key and secret as environment variables in Val Town
403. Deploy the Val and access your store!
spreadchatapp.js6 matches
22setupEventListeners(spreadsheet);
23
24// Expose spreadsheet API to parent window
25exposeSpreadsheetAPI(spreadsheet);
26});
27140confirmImportBtn.disabled = true;
141
142const response = await fetch('/api/import-sheets', {
143method: 'POST',
144headers: {
228229/**
230* Expose spreadsheet API to parent window
231* This allows external code to interact with the spreadsheet
232*/
233function exposeSpreadsheetAPI(spreadsheet) {
234// Create API object
235window.valSpreadsheet = {
236// Get current spreadsheet data
spreadchatsheets-import.ts3 matches
1// This file would contain the actual Google Sheets import functionality
2// For a complete implementation, we would need to:
3// 1. Use the Google Sheets API to fetch sheet data
4// 2. Convert the data to a format compatible with x-spreadsheet
5// 3. Return the formatted data
67// For now, this is a placeholder that would be expanded with actual implementation
8// using the Google Sheets API and SheetJS for data conversion
910export async function importFromGoogleSheets(sheetUrl: string) {
18
19// In a real implementation, we would:
20// 1. Call the Google Sheets API using the sheet ID
21// 2. Process the response with SheetJS
22// 3. Convert to x-spreadsheet format
spreadchatindex.ts2 matches
34app.get("/frontend/*", c => serveFile(c.req.path, import.meta.url));
3536// API endpoint to import from Google Sheets
37app.post("/api/import-sheets", async (c) => {
38try {
39const body = await c.req.json();
spreadchatREADME.md1 match
252. Use the spreadsheet interface to create, edit, and manage data
263. Import data from Google Sheets using the import button
274. Access selected cell data via the exposed JavaScript API
2829## Technical Details