/deno-api-stringify

🦕 A Simple Deno API rendering a message via JSON.stringify

Primary LanguageTypeScriptMIT LicenseMIT

Deno API Stringify

Get Started

Demo:

Clone the repository:

git clone git@github.com:Developerayo/deno-api-stringify.git && cd deno-api-stringify

Install the dependencies:

npm install or yarn install

To start the project run following command in your terminal:

yarn start

Now Open http://localhost:3333 to view it in the browser.

Current Response

{"body":{"message":"Welcome to Deno"}}

Resource

export async function handler (req: object) {
  return {
    statusCode: 201,
    headers: {
      'content-type': 'application/json; charset=utf8',
      'cache-control': 'no-cache, no-store, must-revalidate, max-age=0, s-maxage=0',
    },
    body: JSON.stringify({body}), 
  }
}

Creating a New Route

export async function handler (req: object) {
  return {
    statusCode: 302,
    headers: {
      'location': '/route',
      'cache-control': 'no-cache, no-store, must-revalidate, max-age=0, s-maxage=0'
    }
  }
}