ATlast — you'll never need to find your favorites on another platform again. Find your favs in the ATmosphere.
atproto
16
fork

Configure Feed

Select the types of activity you want to include in your feed.

add: hono server

byarielm.fyi 5fdc39be 2aaf6d54

verified
+80
+80
packages/api/src/server.ts
··· 1 + import { Hono } from "hono"; 2 + import { serve } from "@hono/node-server"; 3 + import { cors } from "hono/cors"; 4 + import { secureHeaders } from "hono/secure-headers"; 5 + import { logger } from "hono/logger"; 6 + import { errorHandler } from "./middleware/error"; 7 + 8 + const app = new Hono(); 9 + 10 + // Middleware stack 11 + app.use("*", logger()); 12 + app.use("*", secureHeaders()); 13 + app.use( 14 + "*", 15 + cors({ 16 + origin: (origin) => { 17 + // Allow localhost for development 18 + const allowedOrigins = [ 19 + "http://localhost:8888", 20 + "http://127.0.0.1:8888", 21 + "http://localhost:5173", 22 + "http://127.0.0.1:5173", 23 + "https://atlast.byarielm.fyi", 24 + ]; 25 + 26 + // Allow browser extensions 27 + if ( 28 + origin.startsWith("chrome-extension://") || 29 + origin.startsWith("moz-extension://") 30 + ) { 31 + return origin; 32 + } 33 + 34 + // Check if origin is in allowed list 35 + if (allowedOrigins.includes(origin)) { 36 + return origin; 37 + } 38 + 39 + // Default to allowing for backward compatibility 40 + return origin; 41 + }, 42 + credentials: true, 43 + }), 44 + ); 45 + 46 + // Health check endpoint 47 + app.get("/api/health", (c) => { 48 + return c.json({ 49 + success: true, 50 + data: { 51 + status: "ok", 52 + timestamp: new Date().toISOString(), 53 + service: "atlast-api", 54 + version: "1.0.0", 55 + }, 56 + }); 57 + }); 58 + 59 + // Error handling 60 + app.onError(errorHandler); 61 + 62 + // Start server 63 + const port = parseInt(process.env.PORT || "3000"); 64 + 65 + console.log(`🚀 ATlast API server starting...`); 66 + console.log(`📍 Port: ${port}`); 67 + console.log(`🌍 Environment: ${process.env.NODE_ENV || "development"}`); 68 + console.log(`━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━`); 69 + 70 + serve( 71 + { 72 + fetch: app.fetch, 73 + port, 74 + }, 75 + (info) => { 76 + console.log(`✅ Server is running on http://localhost:${info.port}`); 77 + }, 78 + ); 79 + 80 + export default app;