In this post, I will show you how to create a small API using Deno - the newest runtime to run Javascript and Typescript, created by the author of ...
For further actions, you may consider blocking this person and/or reporting abuse
I'm a bit of mixed that Deno doesn't have some kind of package manager, if you import module from master your code will break so soon... if you import using version number you must replace it in all places when you want to update the dependency.
I remember that golang decided to implement dep & modules due former problem.
I think more and more people with use some kind of workaround like this:
github.com/crookse/deno-drash/blob...
github.com/oakserver/oak/blob/mast...
Hello Deli,
thank you for your comment. I understand your doubts. In my examples I import dependencies directly from master for simplicity, but there is a solution for the problem you described:
Step 1. Import a specific version instead of master (don't forget to add "v" before the version number):
Step 2. Put this import and all external dependencies into a separate file and re-export them (change "import" from the code above to "export"):
imports.ts
3. Import from imports.ts and not directly from the internet:
Advantages:
great answer, I think it should be added to the article
I already know your method beforehand, but it would be great if there's cli tool to manage deps.ts to keep things standard.
I think a separate tool like npm won't be added because as the deno docs state: "Deno explicitly takes on the role of both runtime and package manager"
Another solution supported by Deno are file maps: [deno.land/std/manual.md#import-maps]
Easy management from the perspective of the person authoring the code, but how is this easily manageable from the perspective of a monorepo where dependencies need to be updated en masse?
im yet to test it, but you can make a import map.
deno.land/std/manual.md#import-maps
Hi Kryz! The services/createId.ts wasn't working for me I added a function call after uuid
export default () => uuid.generate();
this resolved the sittuation, is this right what I did?
Regards, Denis
Hello,
yes, thank you! I updated the source code and my example.
Thank you for the article was very interesting!
Regards, Denis.
If you need a web server framework for Deno, please give Pogo a try. It is well documented and tested.
github.com/sholladay/pogo
TS7031 [ERROR]: Binding element 'response' implicitly has an 'any' type.
export default async ({ params, request, response }) => {
~~~~~~~~
at file:///C:/Users/DHARM/deno-js/deno-practice/handlers/updateUser.ts:3:42
I had the same issue. It's an issue that happens after newer updates at Deno's TS compiler. You should explicitly type those variables. I did this way and it worked for me:
So in march of 2020 this tutorial no longer works on mac catalina I get 15 errors first starting with
error TS7031: Binding element 'request' implicitly has an 'any' type.
► file:///~/dev/personalProject/denoStarterApi/handlers/createUser.ts:3:25
3 export default async ({ request, response }) => {
Can we update tutorial or maybe I'm just wrong? literally followed verbatim though
Thanks for this article.
I like its use of ES6 module. I want to give it a try, at least for learning.
But I see the following statement in its site :
"A word of caution: Deno is very much under development.
We encourage brave early adopters, but expect bugs large and small."
So we can expect you become one of those brave early adopters. :)
I am waiting for its stable release. For now, I want to enjoy using Node, although I am still relatively new to this javascript web server/run time platform. Currently for my real project, I use PHP + Laravel.
Excellent tutorial, thanks a lot. It looks like deno web framework are somehow in it's infancy stage (which is logical, of course). It seems like there are still many missing pieces (db drivers, orms, testing frameworks, etc...)
I wonder if any of the full-featured framework's authors are working on a deno port (feathers, nestjs, foalts, etc...)
Thank you for the great little tutorial on deno, I managed to complete it and its working great.
Is there a decent HTTP Library yet?
Thanks, I'll take a closer look.
I truly hope this Anagram pattern continues as an ecosystem trope for Deno (Node) Koa (Oak), it's hilarious.
Great article it's helping me to grok and implement some of my own Deno mini-projects :)
I'd be interested to see some benchmarks comparing this API with an equivalent one in Node.
So that we can see what's the latency, throughput and resource usage differences.
deno.land/benchmarks
I've been visiting that page every time a new minor comes out. I'd love to see some high-level implementation performance comparisons against modern node versions; the current benchmarks pit deno against Node 8
I was referring more to handling HTTP requests. I don't know much about Deno, but I had read it was lacking that. Maybe that was old information