Posted by Arjun Arjun on Friday 24th July 2020, 1 minute read

How to develop REST API with Deno

In this tutorial, we gonna use Attain to create REST API with Deno. Attain is a middleware web framework for Deno which is using http standard library inspired by express and Oak and it is Fast and stable with proper memory usage.

import { App, logger, parser, security, staticServe } from "";

const app = new App();

// Set Extra Security setting

// Logging response method status path time

// Parsing the request body and save it to request.params
// Also, updated to parse the queries from search params

// Serve static files
// This path must be started from your command line path.
app.use(staticServe("./public", {maxAge: 1000}));

app.use("/", (req, res) => {

app.use("/google", (req, res) => {

app.use("/:id", (req, res) => {
  // This data has parsed by the embedded URL parser.
  res.status(200).send(`id: ${}`);
})"/submit", (req, res) => {
  // By the parser middleware, the body and search query get parsed and saved.
  res.status(200).send({ data: "has received" });

app.listen({ port: 3000 });
console.log("Start listening on http://localhost:3000");

Let's try to run our server! Now, with Deno, we are going to need network access in order for this to work. So, we are going to run our server like this

deno run --allow-net server.js

Once the server is up, you can access the application at https://localhost:3000


I am Arjun from Hyderabad (India). I have been working as a software engineer from the last 7+ years, and it is my passion to learn new things and implement them as a practice. Aside from work, I like gardening and spending time with pets.