Developing with Deno: Rest API

Pushkar Thakur
May 21 · 5 min read
Image for post
Image for post
  • Create an API to manage products.
  • Provide GET, POST, PUT, and DELETE routes.
  • Save created/updated users to a local JSON file.
$ curl -fsSL https://deno.land/x/install/install.sh | sh
$ deno --version
deno 1.0.0
v8 8.4.300
typescript 3.9.2

$ deno run https://deno.land/std/examples/welcome.ts
Download https://deno.land/std/examples/welcome.ts
Warning Implicitly using master branch https://deno.land/std/examples/welcome.ts
Compile https://deno.land/std/examples/welcome.ts
Welcome to Deno 🦕
  • — allow-hrtime: Allow high-resolution time measurement.
  • — allow-net: Allow network access.
  • — allow-plugin: Allow loading plugins.
  • — allow-read: Allow file system read access.
  • — allow-run: Allow running subprocesses.
  • — allow-write: Allow file system write access.
  • — allow-all:: Give all access.

Image for post
Image for post
  • Routes.ts: containing API routes.
  • Server.ts: code to run localhost server.
  • Types.ts: contain the model definition.
Image for post
Image for post
Image for post
Image for post
Product Found
Image for post
Image for post
Error: Product is not found
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Data to update the name
Image for post
Image for post
Name updated of Id: 2
Image for post
Image for post
export { getProducts, getProduct, addProduct, updateProduct, deleteProduct }



The Startup

Medium's largest active publication, followed by +682K people. Follow to join our community.

Sign up for Top Stories

By The Startup

A newsletter that delivers The Startup's most popular stories to your inbox once a month. Take a look

By signing up, you will create a Medium account if you don’t already have one. Review our Privacy Policy for more information about our privacy practices.

Check your inbox
Medium sent you an email at to complete your subscription.

Pushkar Thakur

Written by

Web Developer 👨‍💻 | Love to explore 🔍 new stuff

The Startup

Medium's largest active publication, followed by +682K people. Follow to join our community.

Pushkar Thakur

Written by

Web Developer 👨‍💻 | Love to explore 🔍 new stuff

The Startup

Medium's largest active publication, followed by +682K people. Follow to join our community.