Server
Integration & Deployment
Deno

Integration with Deno

Deno is a simple, modern and secure runtime for JavaScript and TypeScript that uses V8 and is built in Rust. We will use fets which has an agnostic HTTP handler using Fetch API’s Request and Response objects.

Example

Create a deno-fets.ts file:

deno-fets.ts
import { createRouter, Response } from 'npm:fets'
 
const router = createRouter().route({
  method: 'GET',
  path: '/greetings',
  schemas: {
    responses: {
      200: {
        type: 'object',
        properties: {
          message: {
            type: 'string'
          }
        },
        required: ['message'],
        additionalProperties: false
      }
    }
  },
  handler: () => Response.json({ message: 'Hello World!' })
})
 
Deno.serve(router)

And run it:

deno run --allow-net index.ts