[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"content:legacy:page:\u002Finterviews\u002Fnodejs-api":3,"content:legacy:navigation":229,"content:legacy:surround:\u002Finterviews\u002Fnodejs-api":557},{"id":4,"title":5,"body":6,"description":216,"extension":217,"icon":218,"meta":219,"modifiedAt":220,"navigation":221,"path":222,"publishedAt":223,"seo":224,"sitemap":225,"stem":226,"updatedAt":227,"__hash__":228},"interviews\u002Finterviews\u002Fnodejs-api.md","Node.js and API Design",{"type":7,"value":8,"toc":214},"minimark",[9,32,50,84,102,120,138,156,178,196],[10,11,12,23],"collapsible",{},[13,14,16],"template",{"v-slot:title":15},"",[17,18,19],"ol",{},[20,21,22],"li",{},"How can Node.js handle many concurrent connections with a JavaScript thread?",[13,24,25,29],{"v-slot:content":15},[26,27,28],"p",{},"Node.js delegates many I\u002FO operations to the operating system or its worker pool and receives completion events through the event loop. JavaScript callbacks run on the main thread, so the process can coordinate many waiting connections without one thread per request.",[26,30,31],{},"CPU-heavy JavaScript still blocks that thread. Move expensive computation to worker threads, separate services, or background jobs, and keep request handlers bounded.",[10,33,34,42],{},[13,35,36],{"v-slot:title":15},[17,37,39],{"start":38},2,[20,40,41],{},"What work uses the Node.js worker pool, and why can that matter?",[13,43,44,47],{"v-slot:content":15},[26,45,46],{},"Some filesystem, DNS, compression, and cryptographic operations use a shared worker pool. Slow or excessive work can saturate it and delay unrelated requests.",[26,48,49],{},"Measure queueing and latency, stream large data, avoid unbounded parallelism, and do not assume that every asynchronous API has unlimited independent capacity.",[10,51,52,60],{},[13,53,54],{"v-slot:title":15},[17,55,57],{"start":56},3,[20,58,59],{},"How do you design consistent REST resource URLs and methods?",[13,61,62,81],{"v-slot:content":15},[26,63,64,65,69,70,69,73,76,77,80],{},"Model URLs as nouns and use HTTP methods for actions: ",[66,67,68],"code",{},"GET \u002Forders\u002F:id",", ",[66,71,72],{},"POST \u002Forders",[66,74,75],{},"PATCH \u002Forders\u002F:id",", and ",[66,78,79],{},"DELETE \u002Forders\u002F:id",". Use nested resources only when the parent relationship is meaningful.",[26,82,83],{},"Return consistent status codes and error shapes, support filtering and pagination explicitly, and avoid encoding every business operation as an arbitrary verb in the path.",[10,85,86,94],{},[13,87,88],{"v-slot:title":15},[17,89,91],{"start":90},4,[20,92,93],{},"What makes an API operation idempotent?",[13,95,96,99],{"v-slot:content":15},[26,97,98],{},"Repeating an idempotent operation has the same intended effect as performing it once. Reads, replacements, and deletes are commonly designed this way, while creation often needs an idempotency key.",[26,100,101],{},"Store the key with the request fingerprint and result under a suitable uniqueness constraint so retries cannot create duplicate payments, orders, or jobs.",[10,103,104,112],{},[13,105,106],{"v-slot:title":15},[17,107,109],{"start":108},5,[20,110,111],{},"Where should request validation happen?",[13,113,114,117],{"v-slot:content":15},[26,115,116],{},"Validate syntax and shape at the transport boundary, then enforce domain invariants and authorization in the application or domain layer. Database constraints provide a final defense for uniqueness and relational integrity.",[26,118,119],{},"Return stable field-level errors without leaking internals. Validation does not replace output encoding, parameterized queries, or authorization.",[10,121,122,130],{},[13,123,124],{"v-slot:title":15},[17,125,127],{"start":126},6,[20,128,129],{},"How should an API implement pagination?",[13,131,132,135],{"v-slot:content":15},[26,133,134],{},"Offset pagination is simple and supports arbitrary page jumps, but becomes expensive at large offsets and can shift when rows are inserted. Cursor pagination uses a stable ordered key and performs better for changing feeds.",[26,136,137],{},"Define a deterministic sort with a unique tie-breaker, validate limits, and return an opaque next cursor rather than exposing implementation details.",[10,139,140,148],{},[13,141,142],{"v-slot:title":15},[17,143,145],{"start":144},7,[20,146,147],{},"How do timeouts, retries, and circuit breakers work together?",[13,149,150,153],{"v-slot:content":15},[26,151,152],{},"A timeout limits how long an operation may consume resources. Retries can recover transient failures but need a strict attempt budget, backoff, jitter, and idempotency. A circuit breaker temporarily stops calls when a dependency is consistently failing.",[26,154,155],{},"Coordinate all three under an end-to-end deadline; layered retries can otherwise multiply traffic during an outage.",[10,157,158,166],{},[13,159,160],{"v-slot:title":15},[17,161,163],{"start":162},8,[20,164,165],{},"What is backpressure, and how do streams help?",[13,167,168,171],{"v-slot:content":15},[26,169,170],{},"Backpressure prevents a fast producer from overwhelming a slower consumer. Node streams signal when writes should pause and when production can resume.",[26,172,173,174,177],{},"Respect stream return values or use ",[66,175,176],{},"pipeline"," so errors and cleanup propagate correctly. Buffering an entire upload or export defeats the memory benefits of streaming.",[10,179,180,188],{},[13,181,182],{"v-slot:title":15},[17,183,185],{"start":184},9,[20,186,187],{},"What should structured application logs contain?",[13,189,190,193],{"v-slot:content":15},[26,191,192],{},"Use machine-readable fields such as timestamp, severity, service, environment, request or trace ID, operation, duration, outcome, and a stable error code. Add context without logging secrets, credentials, or unnecessary personal data.",[26,194,195],{},"Logs explain individual events; metrics reveal trends; traces connect work across services. Production diagnosis benefits from all three.",[10,197,198,206],{},[13,199,200],{"v-slot:title":15},[17,201,203],{"start":202},10,[20,204,205],{},"How should graceful shutdown work?",[13,207,208,211],{"v-slot:content":15},[26,209,210],{},"On a termination signal, stop accepting new traffic, mark the instance unready, allow in-flight requests a bounded drain period, stop consumers, flush essential telemetry, and close database or network resources.",[26,212,213],{},"Use a final deadline so shutdown cannot hang forever, and make startup\u002Fshutdown paths testable rather than relying on process exit alone.",{"title":15,"searchDepth":38,"depth":38,"links":215},[],"Backend interview questions about Node.js concurrency, API contracts, reliability, validation, and observability.","md","logos:nodejs-icon",{},null,true,"\u002Finterviews\u002Fnodejs-api","2026-09-21",{"title":5,"description":216},{"loc":222,"lastmod":223},"interviews\u002Fnodejs-api","2026-09-21T22:49:35+07:00","8_T-jAGMHeZmGuzoHrobElYbu-UnBV1Rcs3Fs31tUtg",[230,381,489,504],{"title":231,"icon":232,"path":233,"stem":234,"children":235,"page":246},"Posts","fluent-color:data-bar-vertical-ascending-24","\u002Fposts","posts",[236,247,265,291,301,315,325,335,345,371],{"title":237,"icon":238,"redirect":239,"path":240,"stem":241,"children":242,"page":246},"Database","material-icon-theme:database","\u002Fposts\u002Fdatabase\u002Freplication-strategy","\u002Fposts\u002Fdatabase","posts\u002Fdatabase",[243],{"title":244,"path":239,"stem":245,"icon":220},"Database Replication strategy in large systems","posts\u002Fdatabase\u002Freplication-strategy",false,{"title":248,"icon":249,"redirect":250,"path":251,"stem":252,"children":253,"page":246},"Docker","vscode-icons:file-type-docker2","\u002Fposts\u002Fdocker\u002Fdocker-commands","\u002Fposts\u002Fdocker","posts\u002Fdocker",[254,257,261],{"title":255,"path":250,"stem":256,"icon":220},"Docker commands essentials","posts\u002Fdocker\u002Fdocker-commands",{"title":258,"path":259,"stem":260,"icon":220},"Some useful Dockerfile templates","\u002Fposts\u002Fdocker\u002Fdockerfile-templates","posts\u002Fdocker\u002Fdockerfile-templates",{"title":262,"path":263,"stem":264,"icon":220},"Setup Docker environment on Windows","\u002Fposts\u002Fdocker\u002Fsetup-docker-on-window","posts\u002Fdocker\u002Fsetup-docker-on-window",{"title":266,"icon":267,"redirect":268,"path":269,"stem":270,"children":271,"page":246},"Git & GitHub","material-icon-theme:git","\u002Fposts\u002Fgit\u002Fbrightly-decorate-graph","\u002Fposts\u002Fgit","posts\u002Fgit",[272,275,279,283,287],{"title":273,"path":268,"stem":274,"icon":220},"Brightly decorate your GitHub Graph","posts\u002Fgit\u002Fbrightly-decorate-graph",{"title":276,"path":277,"stem":278,"icon":220},"Download a specific folder on GitHub repository","\u002Fposts\u002Fgit\u002Fdownload-specific-folder","posts\u002Fgit\u002Fdownload-specific-folder",{"title":280,"path":281,"stem":282,"icon":220},"Syncing Git Tags across to other repositories","\u002Fposts\u002Fgit\u002Fsyncing-tags-across-repositories","posts\u002Fgit\u002Fsyncing-tags-across-repositories",{"title":284,"path":285,"stem":286,"icon":220},"Unlocking GitHub Achievement badges","\u002Fposts\u002Fgit\u002Funlocking-achievement-badges","posts\u002Fgit\u002Funlocking-achievement-badges",{"title":288,"path":289,"stem":290,"icon":220},"Essential Git commands every developer should master","\u002Fposts\u002Fgit\u002Fuseful-commands-like-pro","posts\u002Fgit\u002Fuseful-commands-like-pro",{"title":292,"icon":293,"redirect":294,"path":295,"stem":296,"children":297,"page":246},"Golang","material-icon-theme:go","\u002Fposts\u002Fgolang\u002Foptimizing-performance-with-pgo","\u002Fposts\u002Fgolang","posts\u002Fgolang",[298],{"title":299,"path":294,"stem":300,"icon":220},"Optimizing Performance in Go Applications with PGO","posts\u002Fgolang\u002Foptimizing-performance-with-pgo",{"title":302,"icon":303,"redirect":304,"path":305,"stem":306,"children":307,"page":246},"JavaScript","vscode-icons:file-type-js","\u002Fposts\u002Fjavascript\u002F9-lines-of-tips","\u002Fposts\u002Fjavascript","posts\u002Fjavascript",[308,311],{"title":309,"path":304,"stem":310,"icon":220},"9 lines of JavaScript replace 50 lines of code","posts\u002Fjavascript\u002F9-lines-of-tips",{"title":312,"path":313,"stem":314,"icon":220},"Javascript Promises - Specific functions and use cases","\u002Fposts\u002Fjavascript\u002Fpromises-cheatsheet","posts\u002Fjavascript\u002Fpromises-cheatsheet",{"title":316,"icon":317,"redirect":318,"path":319,"stem":320,"children":321,"page":246},"Node","material-icon-theme:nodejs-alt","\u002Fposts\u002Fnodejs\u002Fevent-loop","\u002Fposts\u002Fnodejs","posts\u002Fnodejs",[322],{"title":323,"path":318,"stem":324,"icon":220},"Secret about Event Loop flow in Nodejs","posts\u002Fnodejs\u002Fevent-loop",{"title":326,"icon":327,"redirect":328,"path":329,"stem":330,"children":331,"page":246},"Nuxt","vscode-icons:file-type-nuxt","\u002Fposts\u002Fnuxt\u002Fenable-pwa-in-nuxt","\u002Fposts\u002Fnuxt","posts\u002Fnuxt",[332],{"title":333,"path":328,"stem":334,"icon":220},"Enable PWA and Service Worker in Nuxt","posts\u002Fnuxt\u002Fenable-pwa-in-nuxt",{"title":336,"icon":337,"redirect":338,"path":339,"stem":340,"children":341,"page":246},"Performance","emojione:rocket","\u002Fposts\u002Fperformance\u002Fbackground-image-injection-problem","\u002Fposts\u002Fperformance","posts\u002Fperformance",[342],{"title":343,"path":338,"stem":344,"icon":220},"Background-Image injection problem in UX","posts\u002Fperformance\u002Fbackground-image-injection-problem",{"title":346,"icon":347,"redirect":348,"path":349,"stem":350,"children":351,"page":246},"Tutorial","fluent-color:book-open-lightbulb-24","\u002Fposts\u002Ftutorial\u002Fclassification-and-functionality-of-the-servers","\u002Fposts\u002Ftutorial","posts\u002Ftutorial",[352,355,359,363,367],{"title":353,"path":348,"stem":354,"icon":220},"Classification and functionality of the servers","posts\u002Ftutorial\u002Fclassification-and-functionality-of-the-servers",{"title":356,"path":357,"stem":358,"icon":220},"What is the difference between localhost and 127.0.0.1?","\u002Fposts\u002Ftutorial\u002Fdifferent-between-localhost-and-127-0-0-1","posts\u002Ftutorial\u002Fdifferent-between-localhost-and-127-0-0-1",{"title":360,"path":361,"stem":362,"icon":220},"8 essential network protocols every programmer should know","\u002Fposts\u002Ftutorial\u002Fessential-network-protocols","posts\u002Ftutorial\u002Fessential-network-protocols",{"title":364,"path":365,"stem":366,"icon":220},"Pre rels in header link tag - SEO technique enhancement","\u002Fposts\u002Ftutorial\u002Fpre-rels-in-header-link-tag","posts\u002Ftutorial\u002Fpre-rels-in-header-link-tag",{"title":368,"path":369,"stem":370,"icon":220},"Better code with SOLID principles","\u002Fposts\u002Ftutorial\u002Fwhat-is-solid","posts\u002Ftutorial\u002Fwhat-is-solid",{"title":372,"icon":373,"redirect":374,"path":375,"stem":376,"children":377,"page":246},"UI\u002FUX","devicon:figma","\u002Fposts\u002Fuiux\u002Fcommon-button-mistake","\u002Fposts\u002Fuiux","posts\u002Fuiux",[378],{"title":379,"path":374,"stem":380,"icon":220},"Common Button Mistake in UI\u002FUX","posts\u002Fuiux\u002Fcommon-button-mistake",{"title":382,"icon":383,"path":384,"stem":385,"children":386,"page":246},"Cheatsheets","fluent-color:paw-16","\u002Fcheatsheets","cheatsheets",[387,392,397,400,405,408,413,417,422,427,432,437,442,447,451,455,460,465,469,474,479,484],{"title":388,"path":389,"stem":390,"icon":391},"Bash","\u002Fcheatsheets\u002Fbash","cheatsheets\u002Fbash","material-icon-theme:powershell",{"title":393,"path":394,"stem":395,"icon":396},"CSS","\u002Fcheatsheets\u002Fcss","cheatsheets\u002Fcss","vscode-icons:file-type-css2",{"title":248,"path":398,"stem":399,"icon":249},"\u002Fcheatsheets\u002Fdocker","cheatsheets\u002Fdocker",{"title":401,"path":402,"stem":403,"icon":404},"Git","\u002Fcheatsheets\u002Fgit","cheatsheets\u002Fgit","devicon:git",{"title":292,"path":406,"stem":407,"icon":293},"\u002Fcheatsheets\u002Fgo","cheatsheets\u002Fgo",{"title":409,"path":410,"stem":411,"icon":412},"HTML","\u002Fcheatsheets\u002Fhtml","cheatsheets\u002Fhtml","material-icon-theme:html",{"title":302,"path":414,"stem":415,"icon":416},"\u002Fcheatsheets\u002Fjavascript","cheatsheets\u002Fjavascript","material-icon-theme:javascript",{"title":418,"path":419,"stem":420,"icon":421},"Latex","\u002Fcheatsheets\u002Flatex","cheatsheets\u002Flatex","material-icon-theme:latexmk",{"title":423,"path":424,"stem":425,"icon":426},"Linux","\u002Fcheatsheets\u002Flinux","cheatsheets\u002Flinux","devicon:linux",{"title":428,"path":429,"stem":430,"icon":431},"Markdown","\u002Fcheatsheets\u002Fmarkdown","cheatsheets\u002Fmarkdown","material-icon-theme:markdown",{"title":433,"path":434,"stem":435,"icon":436},"Mongo","\u002Fcheatsheets\u002Fmongo","cheatsheets\u002Fmongo","devicon:mongodb",{"title":438,"path":439,"stem":440,"icon":441},"Nest","\u002Fcheatsheets\u002Fnest","cheatsheets\u002Fnest","material-icon-theme:nest",{"title":443,"path":444,"stem":445,"icon":446},"Next","\u002Fcheatsheets\u002Fnext","cheatsheets\u002Fnext","logos:nextjs-icon",{"title":316,"path":448,"stem":449,"icon":450},"\u002Fcheatsheets\u002Fnode","cheatsheets\u002Fnode","material-icon-theme:nodejs",{"title":326,"path":452,"stem":453,"icon":454},"\u002Fcheatsheets\u002Fnuxt","cheatsheets\u002Fnuxt","material-icon-theme:nuxt",{"title":456,"path":457,"stem":458,"icon":459},"React","\u002Fcheatsheets\u002Freact","cheatsheets\u002Freact","material-icon-theme:react",{"title":461,"path":462,"stem":463,"icon":464},"Redis","\u002Fcheatsheets\u002Fredis","cheatsheets\u002Fredis","vscode-icons:folder-type-redis-opened",{"title":466,"path":467,"stem":468,"icon":238},"SQL","\u002Fcheatsheets\u002Fsql","cheatsheets\u002Fsql",{"title":470,"path":471,"stem":472,"icon":473},"Typescript","\u002Fcheatsheets\u002Ftypescript","cheatsheets\u002Ftypescript","material-icon-theme:typescript",{"title":475,"path":476,"stem":477,"icon":478},"Vercel","\u002Fcheatsheets\u002Fvercel","cheatsheets\u002Fvercel","vscode-icons:file-type-light-vercel",{"title":480,"path":481,"stem":482,"icon":483},"Vue","\u002Fcheatsheets\u002Fvue","cheatsheets\u002Fvue","material-icon-theme:vue",{"title":485,"path":486,"stem":487,"icon":488},"Windows","\u002Fcheatsheets\u002Fwindow","cheatsheets\u002Fwindow","material-icon-theme:folder-windows",{"title":490,"icon":491,"path":492,"stem":493,"children":494,"page":246},"Prompts","fluent-color:bot-sparkle-24","\u002Fprompts","prompts",[495],{"title":496,"path":497,"stem":498,"children":499,"page":246},"Image Generation","\u002Fprompts\u002Fimage-generation","prompts\u002Fimage-generation",[500],{"title":501,"path":502,"stem":503,"icon":491},"Futuristic Cloud Workspace","\u002Fprompts\u002Fimage-generation\u002Ffuturistic-cloud-workspace","prompts\u002Fimage-generation\u002Ffuturistic-cloud-workspace",{"title":505,"icon":506,"path":507,"stem":508,"children":509,"page":246},"Interviews","lucide:messages-square","\u002Finterviews","interviews",[510,514,519,522,526,527,532,537,542,547,552],{"title":511,"path":512,"stem":513,"icon":506},"Behavioral Engineering","\u002Finterviews\u002Fbehavioral-engineering","interviews\u002Fbehavioral-engineering",{"title":515,"path":516,"stem":517,"icon":518},"DevOps and Cloud","\u002Finterviews\u002Fdevops-cloud","interviews\u002Fdevops-cloud","logos:docker-icon",{"title":409,"path":520,"stem":521,"icon":412},"\u002Finterviews\u002Fhtml","interviews\u002Fhtml",{"title":302,"path":523,"stem":524,"icon":525},"\u002Finterviews\u002Fjavascript","interviews\u002Fjavascript","logos:javascript",{"title":5,"path":222,"stem":226,"icon":218},{"title":528,"path":529,"stem":530,"icon":531},"Software Testing","\u002Finterviews\u002Fsoftware-testing","interviews\u002Fsoftware-testing","lucide:flask-conical",{"title":533,"path":534,"stem":535,"icon":536},"SQL and Databases","\u002Finterviews\u002Fsql-databases","interviews\u002Fsql-databases","lucide:database",{"title":538,"path":539,"stem":540,"icon":541},"System Design","\u002Finterviews\u002Fsystem-design","interviews\u002Fsystem-design","lucide:network",{"title":543,"path":544,"stem":545,"icon":546},"TypeScript","\u002Finterviews\u002Ftypescript","interviews\u002Ftypescript","logos:typescript-icon",{"title":548,"path":549,"stem":550,"icon":551},"Vue and Nuxt","\u002Finterviews\u002Fvue-nuxt","interviews\u002Fvue-nuxt","logos:nuxt-icon",{"title":553,"path":554,"stem":555,"icon":556},"Web Security","\u002Finterviews\u002Fweb-security","interviews\u002Fweb-security","lucide:shield-check",[558,559],{"title":302,"path":523,"stem":524,"children":-1},{"title":528,"path":529,"stem":530,"children":-1}]