[{"data":1,"prerenderedAt":363},["ShallowReactive",2],{"project-38021461":3},{"id":4,"name":5,"line":6,"line_source":7,"title":8,"url":9,"domain":10,"maker":11,"posted_at":12,"year":13,"points":14,"comments":15,"rank_in_year":16,"shown_in_year":17,"top":18,"tier":19,"category":20,"subcategory":21,"format":22,"keywords":23,"reception":29,"sentiment":30,"stance_mix":31,"scored_comments":35,"aspects":36,"strip":41,"post_text":45,"what":46,"said":89,"maker_in_thread":196,"shape":208,"grid":213,"attempts":325,"same_week":326,"maker_shows":33,"maker_hidden":355,"reader_version":356,"card":357},"38021461","API","Instant API – Build type-safe web APIs with JavaScript","title","Show HN: Instant API – Build type-safe web APIs with JavaScript","https:\u002F\u002Fgithub.com\u002Finstant-dev\u002Fapi","github.com","keithwhor",1698292822,2023,102,78,636,3109,21,"notable","dev_tools","api framework","library",[24,25,26,27,28],"javascript api framework","jsdoc validation","openapi generation","serverless api","runtime validation","mixed",-0.076,{"positive":32,"neutral":33,"mixed":34,"critical":33},4,7,1,19,{"idea":37,"docs":40},{"positive":38,"critical":39},2,6,{"positive":34,"critical":34},[42,43,42,34,43,44,42,34,43,42,44,43,43,43,43,43,43,43,44,42,43,42,44,34,43,43,34,42,43,43,43,43,43,34,43,42,34,43,43,34],3,0,5,"Hey there HN! I just wrapped up an all-day documentation spree for Instant API, a JavaScript framework for easily building web APIs that implements type safety at the HTTP interface. It uses a function-as-a-service approach combined with a slightly modified JSDoc spec to automatically enforce parameter and schema validation before HTTP requests make it through to your code. You just write comments above your endpoint functions and voila, enforced type safety contracts between your API endpoints and your developers. OpenAPI specifications are generated automatically as a byproduct of simply bui",{"problem":47,"audience":53,"pricing":58,"motivation":59,"time_to_build":63,"stack":67,"openness":86,"stage":87,"team_size":88},{"value":48,"source":49,"evidence":50},"Enforcing input validation and generating OpenAPI specs for web APIs without separate schema libraries","maker",[51],{"id":52},"post",{"value":54,"source":55,"evidence":56},"JavaScript developers building web APIs","inferred",[57],{"id":52},null,{"value":60,"source":49,"evidence":61},"Built as a side effect of building the maker's own serverless API platform",[62],{"id":52},{"value":64,"source":49,"evidence":65},"about six years of development as proprietary software",[66],{"id":52},[68,72,76,80],{"value":69,"source":49,"evidence":70},"JavaScript",[71],{"id":52},{"value":73,"source":49,"evidence":74},"JSDoc",[75],{"id":52},{"value":77,"source":49,"evidence":78},"Postgres",[79],{"id":52},{"value":81,"source":49,"evidence":82},"Redis",[83],{"id":84,"by":11,"text":85},"38021835","@stream is actually straightforward in Node; it’s just part of the http request. Typically Instant API waits until the full request is processed to return headers and body as the…","unknown","beta","team",{"praise":90,"objections":106,"requests":141,"questions":161,"alternatives":170},[91,99],{"value":92,"source":93,"evidence":94},"Clean, efficient validation approach","commenter",[95],{"id":96,"by":97,"text":98},"38021749","mlmilleratmit","Neat. I like the fresh take on validation. It’s not necessarily unique, but it may be cleaner \u002F more efficient than previous attempts. The mixing of backend processing and the…",{"value":100,"source":93,"evidence":101},"Good use of OpenAPI generation",[102],{"id":103,"by":104,"text":105},"38023011","TheFragenTaken","Happy to see more projects embrace OpenAPI.",[107,120,134],{"value":108,"source":93,"evidence":109},"Calling it type-safe is misleading; it is runtime validation, not type safety",[110,114,117],{"id":111,"by":112,"text":113},"38022346","stagas","Type Safety != Runtime Type Validation. Something being Type Safe means that I, the programmer, am Safe from making type mistakes while developing and maintaining the software.…",{"id":115,"by":112,"text":116},"38022457","It's not pedantry, you're using the term wrong. I understand why it can be confusing if you are just using JavaScript and you haven't had the experience of type-safe codebases.…",{"id":118,"by":112,"text":119},"38022609","For this software to be appealing it would need to really be type-safe, meaning you'd need to use TypeScript. Type-safe means I can change an interface in project B and project A…",{"value":121,"source":93,"evidence":122},"TypeScript would be a better approach",[123,127,131],{"id":124,"by":125,"text":126},"38022761","tsergiu","We tried for years to do things like this, and in the end an approach using typescript is way, way better than anything else I've seen attempted. In my latest project[1], we set…",{"id":128,"by":129,"text":130},"38022919","flashback2199","Nice, this should help all zero businesses building APIs in JS \u002Fs Start using TS.",{"id":132,"by":129,"text":133},"38027752","I can definitely comprehend it. What I can't comprehend is wanting types and building a custom special snowflake library instead of using the right tool \"I needed a screwdriver,…",{"value":135,"source":93,"evidence":136},"Documentation error in the README longitude range",[137],{"id":138,"by":139,"text":140},"38023853","mkl","I spotted a bug in the README's first example: ``` @param {number {-90,90}} coords.lng Longitude ``` The range for longitude is incorrect, and only covers half the globe. How and…",[142,151],{"value":143,"source":93,"evidence":144},"Add TypeScript support",[145,148],{"id":146,"by":11,"text":147},"38022637","That’s good feedback! We can probably do both; if you think it’s cool would you be interested in contributing to TypeScript support to circle the square?",{"id":149,"by":11,"text":150},"38022788","Our approach doesn’t preclude TypeScript! In fact I think it would integrate well with it. If you’re interested in a TS approach could you email me at keith@instant.dev ?",{"value":152,"source":93,"evidence":153},"Content negotiation and header-based routing",[154,158],{"id":155,"by":156,"text":157},"38022688","mstade","Neat! Does this framework have any tools for content negotiation? I get that you could do this in the handlers themselves, but in my experience different representations are…",{"id":159,"by":156,"text":160},"38022797","Here's a simple use case: human friendly and machine friendly representations at the same path. For example, let's say I have an api at `\u002Fweather` which when requested with the…",[162,166],{"value":163,"source":93,"evidence":164},"How and when are types checked, only at runtime?",[165],{"id":138,"by":139,"text":140},{"value":167,"source":93,"evidence":168},"Performance and scalability in production?",[169],{"id":96,"by":97,"text":98},[171,178,185,189],{"value":172,"source":93,"evidence":173},"Zod",[174],{"id":175,"by":176,"text":177},"38023401","Loeffelmann","Zod[1] is probably the closest 1: https:\u002F\u002Fwww.npmjs.com\u002Fpackage\u002Fzod 1: https:\u002F\u002Fgithub.com\u002Fcolinhacks\u002Fzod",{"value":179,"source":93,"evidence":180},"FastAPI",[181],{"id":182,"by":183,"text":184},"38022601","whinvik","Both the name and intent seem highly inspired from FastAPI!",{"value":186,"source":93,"evidence":187},"TypeScript",[188],{"id":124,"by":125,"text":126},{"value":190,"source":93,"evidence":191},"Swagger\u002FOpenAPI tooling",[192],{"id":193,"by":194,"text":195},"38023077","KronisLV","> But OpenAPI is the “gold standard” machine readable API specification format I remember when that would have been WSDL, with something like SoapUI - where you'd feed in the…",{"comments":197,"answered":33,"key":198},18,[199,202,205],{"id":200,"text":201},"38022701","I’m not quite sure I grok the use case, can you give a more precise example? Either way, if you’re interested in the approach I *very welcome* issues, PRs and contributors. I…",{"id":203,"text":204},"38022828","Entirely possible! I mean right now we restrict endpoint definitions to HTTP methods but in theory you could define unique endpoints for any combination of parameters. What I…",{"id":206,"text":207},"38026763","Thanks for the tip! Fixed this; just missed this when writing the example. This error would only be found if you wrote a test for it. The framework doesn't have an AI integration…",{"commenters":209,"max_depth":210,"maker_replies":197,"first_comment_mins":211,"lifespan_hours":212},24,8,54,29,[214,216,218,219,220,222,224,228,230,232,236,239,242,245,248,252,254,255,258,261,263,265,267,269,272,275,277,278,281,283,285,287,289,290,291,293,295,298,300,302,305,307,309,310,312,314,316,318,321,324],[155,43,42,215,156,43],"project\u002Fneutral\u002Fidea",[200,43,43,217,11,34],"maker\u002Fneutral\u002Fnone",[159,43,42,215,156,43],[203,43,43,215,11,34],[138,34,34,221,139,43],"project\u002Fcritical\u002Fdocs",[206,34,43,223,11,34],"project\u002Fneutral\u002Fdocs",[225,34,44,226,227,43],"38027274","project\u002Fpositive\u002Fidea","ebalit",[96,38,42,229,97,43],"project\u002Fmixed\u002Fnone",[84,38,43,231,11,34],"project\u002Fneutral\u002Fperformance",[233,42,34,234,235,43],"38022420","project\u002Fcritical\u002Fidea","firechickenbird",[237,42,43,238,11,34],"38022436","project\u002Fneutral\u002Fnone",[240,42,42,215,241,43],"38036301","jslakro",[243,32,44,226,244,43],"38022337","devjab",[246,32,43,247,11,34],"38022391","commenter\u002Fneutral\u002Fnone",[249,44,43,250,251,43],"38021895","other\u002Fneutral\u002Fnone","tppiotrowski",[253,44,43,250,11,34],"38021911",[193,44,43,250,194,43],[256,44,43,250,257,43],"38025289","theryan",[259,44,43,250,260,43],"38021923","mstibbard",[262,44,43,250,11,34],"38021932",[264,44,43,250,260,43],"38021984",[266,44,43,250,11,34],"38022002",[103,39,44,268,104,43],"project\u002Fpositive\u002Fdocs",[270,39,43,271,11,34],"38023068","maker\u002Fpositive\u002Fnone",[273,33,42,215,274,43],"38022997","sandGorgon",[276,33,43,215,11,34],"38023010",[175,33,42,215,176,43],[279,210,44,271,280,43],"38034388","ac360",[111,282,34,234,112,43],9,[284,282,43,215,11,34],"38022379",[115,282,43,286,112,43],"commenter\u002Fneutral\u002Fidea",[288,282,43,215,11,34],"38022475",[118,282,34,234,112,43],[146,282,43,238,11,34],[292,282,42,217,112,43],"38022700",[294,282,43,217,11,34],"38022892",[296,282,43,286,297,43],"38022617","deredede",[299,282,43,286,112,43],"38022651",[301,282,43,286,297,43],"38022776",[303,282,43,286,304,43],"38027938","beders",[306,282,43,286,112,43],"38032782",[124,308,34,234,125,43],10,[149,308,43,215,11,34],[182,311,42,215,183,43],11,[313,311,43,217,11,34],"38022664",[128,315,34,234,129,43],12,[317,315,43,247,11,34],"38022954",[319,315,43,247,320,43],"38023042","fintechie",[322,315,43,250,323,43],"38023329","dang",[132,315,34,234,129,43],[],[327,332,337,342,346,350],{"id":328,"name":329,"points":330,"category":331},"38052344","OpenSign",545,"web_saas",{"id":333,"name":334,"points":335,"category":336},"38044782","WireHole",298,"infrastructure",{"id":338,"name":339,"points":340,"category":341},"38038239","ScratchDB",261,"data",{"id":343,"name":344,"points":345,"category":20},"38084098","postgresql-event-sourcing",231,{"id":347,"name":348,"points":349,"category":336},"38086598","MicroTCP",204,{"id":351,"name":352,"points":353,"category":354},"38093083","Halloween game (snail terminal demo)",173,"games",false,"v2",{"id":358,"name":5,"line":6,"ai":355,"cat":20,"year":13,"points":14,"comments":15,"rec":29,"s":359,"top":18,"kw":360,"maker":11,"domain":10,"tier":19,"attempts":43,"strip":361,"url":9,"mix":362,"praise":92,"objection":108,"sub":21},38021461,-0.08,[24,25,26,27,28],"3031053103500000005303510013000001031001",[32,33,34,33],1794036643761]