@@ -4,127 +4,40 @@ import { isStorageHealthy } from "../utils/storage";
44export default defineEventHandler ( async ( event ) => {
55 const baseUrl = getRequestURL ( event ) . origin ;
66
7- // Get system information
8- const memoryUsage = process . memoryUsage ( ) ;
9- const startTime = Date . now ( ) - process . uptime ( ) * 1000 ;
10-
11- // Get adaptive storage health
12- const storageHealth = await isStorageHealthy ( ) ;
7+ // Parallel execution for better performance
8+ const [ storageHealth , memoryUsage ] = await Promise . all ( [
9+ isStorageHealthy ( ) ,
10+ Promise . resolve ( process . memoryUsage ( ) ) ,
11+ ] ) ;
1312
1413 const serviceStatus = {
15- name : "Lens Multimedia API Platform" ,
16- description :
17- "High-performance multimedia API service for images, fonts, favicons, and web content" ,
18- status : "running" ,
14+ name : "Lens API" ,
1915 version : pkg . version ,
16+ status : "healthy" ,
2017 timestamp : new Date ( ) . toISOString ( ) ,
21- uptime : {
22- seconds : Math . floor ( process . uptime ( ) ) ,
23- human : new Date ( process . uptime ( ) * 1000 ) . toISOString ( ) . substr ( 11 , 8 ) ,
24- startTime : new Date ( startTime ) . toISOString ( ) ,
25- } ,
26- system : {
27- nodeVersion : process . version ,
28- platform : process . platform ,
29- arch : process . arch ,
30- environment : process . env . NODE_ENV || "development" ,
31- memory : {
32- rss : `${ Math . round ( memoryUsage . rss / 1024 / 1024 ) } MB` ,
33- heapUsed : `${ Math . round ( memoryUsage . heapUsed / 1024 / 1024 ) } MB` ,
34- heapTotal : `${ Math . round ( memoryUsage . heapTotal / 1024 / 1024 ) } MB` ,
35- external : `${ Math . round ( memoryUsage . external / 1024 / 1024 ) } MB` ,
36- } ,
18+ uptime : Math . floor ( process . uptime ( ) ) ,
19+ environment : process . env . NODE_ENV || "development" ,
20+ health : {
21+ storage : storageHealth ? "ok" : "degraded" ,
22+ memory : `${ Math . round ( memoryUsage . heapUsed / 1024 / 1024 ) } MB` ,
3723 } ,
38- endpoints : {
39- "Core Services" : {
40- "/favicon" : "Favicon extraction and optimization" ,
41- "/css" : "Google Fonts CSS v1 API compatible" ,
42- "/css2" : "Google Fonts CSS v2 API compatible" ,
43- "/fonts/*" : "Font file proxy service" ,
44- "/webfonts" : "Google Fonts metadata API" ,
45- "/og" : "Open Graph image generation" ,
46- "/img/*" : "IPX-compatible image proxy and processing" ,
47- "/screenshot" : "Website screenshot capture service" ,
48- description :
49- "All endpoints work without authentication. Authenticated users get higher rate limits." ,
50- authentication :
51- "Optional: Session token or API key (x-api-key header / api_key query parameter)" ,
52- examples : [
53- `${ baseUrl } /favicon?url=https://github.com&size=64` ,
54- `${ baseUrl } /css2?family=Inter:wght@400;700&display=swap` ,
55- `${ baseUrl } /og?title=Hello World&description=My App&theme=blue` ,
56- `${ baseUrl } /img/w_300,f_webp/https%3A//example.com/image.jpg` ,
57- `${ baseUrl } /screenshot?url=https://example.com&width=1920&height=1080` ,
58- ] ,
59- } ,
60- } ,
61- features : [
62- "🖼️ Website screenshot capture with Playwright" ,
63- "🎨 Dynamic OG image generation" ,
64- "🌐 Self-hosted Google Fonts replacement" ,
65- "🖼️ IPX-compatible image proxy and optimization" ,
66- "🚀 Platform compatibility validation" ,
67- "💾 Multi-layer adaptive caching (Redis + FileSystem + Memory)" ,
68- "🗄️ Adaptive database support (Turso/PostgreSQL/MySQL/SQLite)" ,
69- "🔒 Flexible authentication with better-auth" ,
70- "⚡ Rate limiting with unified plugin-level management" ,
71- "📱 Mobile viewport and dark mode support" ,
72- "🎯 CORS support and security headers" ,
24+ services : [ "favicon" , "fonts" , "og" , "img" , "screenshot" ] ,
25+ examples : [
26+ `${ baseUrl } /favicon?url=github.com` ,
27+ `${ baseUrl } /og?title=Hello&theme=blue` ,
28+ `${ baseUrl } /img/w_300/example.com/image.jpg` ,
7329 ] ,
74- configuration : {
75- storage : {
76- status : storageHealth ? "Healthy" : "Unhealthy" ,
77- layers : storageHealth ? "Multi-layer adaptive" : "Memory fallback" ,
78- responsive : storageHealth ? "Yes" : "No" ,
79- drivers : {
80- redis : process . env . REDIS_URL ? "Available" : "Not configured" ,
81- filesystem : "Available (fallback)" ,
82- memory : "Available" ,
83- } ,
84- ttl : {
85- screenshots : "1 hour" ,
86- ogImages : "1 day" ,
87- favicons : "7 days" ,
88- fonts : "30 days" ,
89- metadata : "1 day" ,
90- } ,
91- } ,
92- database : {
93- type : process . env . TURSO_DATABASE_URL
94- ? "Turso"
95- : process . env . DATABASE_URL ?. startsWith ( "postgres" )
96- ? "PostgreSQL"
97- : process . env . DATABASE_URL ?. startsWith ( "mysql" )
98- ? "MySQL"
99- : "SQLite (fallback)" ,
100- status : "Connected" ,
101- features : [ "Kysely ORM" , "Auto-migration" , "TypeScript support" ] ,
102- } ,
103- browser : {
104- playwright : "Installed" ,
105- config : process . env . PLAYWRIGHT_BROWSER_CONFIG || "auto" ,
106- runtime : "Persistent Node.js Runtime" ,
107- } ,
108- auth : {
109- github : process . env . GITHUB_CLIENT_ID ? "Configured" : "Not configured" ,
110- emailPassword : "Enabled" ,
111- sessionStorage : "Adaptive (secondary storage)" ,
112- } ,
113- domains : {
114- allowed : process . env . ALLOWED_DOMAINS
115- ? process . env . ALLOWED_DOMAINS . split ( "," ) . length + " domains"
116- : "All domains allowed" ,
117- } ,
118- } ,
119- links : {
120- repository : "https://github.com/bysages/lens" ,
121- documentation : "https://github.com/bysages/lens#readme" ,
30+ features : [ "screenshots" , "og-images" , "fonts" , "image-proxy" , "caching" ] ,
31+ storage : {
32+ redis : ! ! process . env . REDIS_URL ,
33+ minio : ! ! ( process . env . MINIO_ENDPOINT && process . env . MINIO_ACCESS_KEY ) ,
34+ s3 : ! ! ( process . env . S3_ENDPOINT && process . env . S3_ACCESS_KEY_ID ) ,
12235 } ,
36+ docs : "https://github.com/bysages/lens#readme" ,
12337 } ;
12438
125- // Return JSON response with proper headers
126- setHeader ( event , "Content-Type" , "application/json" ) ;
127- setHeader ( event , "Cache-Control" , "no-cache" ) ;
39+ // Cache for 30 seconds to reduce load
40+ setHeader ( event , "Cache-Control" , "public, max-age=30" ) ;
12841
12942 return serviceStatus ;
13043} ) ;
0 commit comments