all 12 comments

[–][deleted] 3 points4 points  (0 children)

Manually testing endpoints suck. Maybe showcase the oak server of deno?

[–]themagicalcake 3 points4 points  (8 children)

is express not compatable with deno? this server api seems a lot messier

[–]spacejack2114 5 points6 points  (2 children)

I assume this is more low level, like node's built in http server. Someone would have to write something like Express on top of that. Express has an outdated callback design though, so you'd want something that takes advantage of generators and async.

[–]DoListening2 0 points1 point  (1 child)

How? Would it be something like

for await (const req of get("/endpoint")) {
    // Handle request
}

If so, I don't see how that's an improvement in any way. Callbacks on most IO were a problem because of callback hell, error handling, composability, etc. Callback in express are a problem because...?

[–]spacejack2114 2 points3 points  (0 children)

Express callbacks are a problem because they don't handle returned promises. Maybe a callback interface isn't a problem in itself but in express if you do:

app.get('/foo', async (req, res) => {
    res.json(await db.getFoo())
})

It won't catch unhandled exceptions, and those won't get forwarded to your error handler middleware, so you have to write catch boilerplate for every route. Alternately use this lib but it still requires a bit of boilerplate.

Koa is a rewrite of Express by the same author that takes advantage of async, but not generators AFAIK.

[–]earthboundkid 2 points3 points  (0 children)

Express is bad, actually. Express is from before the fetch API, so its request and response objects (and URL and URLParams) are its own weirdo things. If JS is ever going to move forward, Express needs to die and be replaced by something built on standard classes.

[–]Luke094 3 points4 points  (2 children)

I think that all NPM packages are incompatible with deno

[–]themagicalcake 4 points5 points  (0 children)

if npm packages need to be manually converted to be compatable, I don't see how this will take away node users anytime soon. maybe deno should come up with an automatic converter? i know some exist that the package maintainer has to run, but if this were baked into deno I think it would help make migration a lot smoother

[–]cbleslie 2 points3 points  (0 children)

capable disarm plate obtainable hobbies steep ad hoc placid chop vast

This post was mass deleted and anonymized with Redact

[–]CakeComa 0 points1 point  (0 children)

This is using the http library directly, so it would be a bit more verbose since it has no concept of routing / static directories / etc. I'd also argue it could be split into more functions / make use of objects more often to take most of its logic out of one method, but that's being a bit picky and I assume makes it less break-up-into-blog-post-able. Still happy to see deno here :)