Skip to main content
Module

x/opine/docs/index.html

Fast, minimalist web framework for Deno ported from ExpressJS.
Go to Latest
File
<!doctype html><html class="default no-js"><head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <title>opine</title> <meta name="description" content="Documentation for opine"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="assets/css/main.css"></head><body><header> <div class="tsd-page-toolbar"> <div class="container"> <div class="table-wrap"> <div class="table-cell" id="tsd-search" data-index="assets/js/search.json" data-base="."> <div class="field"> <label for="tsd-search-field" class="tsd-widget search no-caption">Search</label> <input id="tsd-search-field" type="text" /> </div> <ul class="results"> <li class="state loading">Preparing search index...</li> <li class="state failure">The search index is not available</li> </ul> <a href="index.html" class="title">opine</a> </div> <div class="table-cell" id="tsd-widgets"> <div id="tsd-filter"> <a href="#" class="tsd-widget options no-caption" data-toggle="options">Options</a> <div class="tsd-filter-group"> <div class="tsd-select" id="tsd-filter-visibility"> <span class="tsd-select-label">All</span> <ul class="tsd-select-list"> <li data-value="public">Public</li> <li data-value="protected">Public/Protected</li> <li data-value="private" class="selected">All</li> </ul> </div> <input type="checkbox" id="tsd-filter-inherited" checked /> <label class="tsd-widget" for="tsd-filter-inherited">Inherited</label> <input type="checkbox" id="tsd-filter-only-exported" /> <label class="tsd-widget" for="tsd-filter-only-exported">Only exported</label> </div> </div> <a href="#" class="tsd-widget menu no-caption" data-toggle="menu">Menu</a> </div> </div> </div> </div> <div class="tsd-page-title"> <div class="container"> <ul class="tsd-breadcrumb"> <li> <a href="globals.html">Globals</a> </li> </ul> <h1>opine</h1> </div> </div></header><div class="container container-main"> <div class="row"> <div class="col-8 col-content"> <div class="tsd-panel tsd-typography"> <p align="center"> <a href="https://www.linkedin.com/in/hannah-morten-b1218017a/"><img height="200" style="height:200px;" src="https://github.com/asos-craigmorten/opine/raw/main/.github/icon.png" alt="Deno reading an opinionated book"></a> <h1 align="center">Opine</h1> </p> <p align="center"> Fast, minimalist web framework for <a href="https://deno.land/">Deno</a> ported from <a href="https://github.com/expressjs/express">ExpressJS</a>.</p> <p align="center"> <a href="https://github.com/asos-craigmorten/opine/tags/"><img src="https://img.shields.io/github/tag/asos-craigmorten/opine" alt="Current version" /></a> <img src="https://github.com/asos-craigmorten/opine/workflows/Test/badge.svg" alt="Current test status" /> <a href="https://doc.deno.land/https/deno.land/x/opine/mod.ts"><img src="https://doc.deno.land/badge.svg" alt="Deno docs" /></a> <a href="http://makeapullrequest.com"><img src="https://img.shields.io/badge/PRs-welcome-brightgreen.svg" alt="PRs are welcome" /></a> <a href="https://github.com/asos-craigmorten/opine/issues/"><img src="https://img.shields.io/github/issues/asos-craigmorten/opine" alt="Opine issues" /></a> <img src="https://img.shields.io/github/stars/asos-craigmorten/opine" alt="Opine stars" /> <img src="https://img.shields.io/github/forks/asos-craigmorten/opine" alt="Opine forks" /> <img src="https://img.shields.io/github/license/asos-craigmorten/opine" alt="Opine license" /> <a href="https://GitHub.com/asos-craigmorten/opine/graphs/commit-activity"><img src="https://img.shields.io/badge/Maintained%3F-yes-green.svg" alt="Opine is maintained" /></a> <a href="http://hits.dwyl.com/asos-craigmorten/opine"><img src="http://hits.dwyl.com/asos-craigmorten/opine.svg" alt="Opine repository visit count" /></a> <a href="https://nest.land/package/opine"><img src="https://nest.land/badge.svg" alt="Published on nest.land" /></a> </p> <hr> <a href="#table-of-contents" id="table-of-contents" style="color: inherit; text-decoration: none;"> <h2>Table of Contents</h2> </a> <ul> <li><a href="#getting-started">Getting Started</a></li> <li><a href="#installation">Installation</a></li> <li><a href="#features">Features</a></li> <li><a href="#documentation">Documentation</a></li> <li><a href="#philosophy">Philosophy</a></li> <li><a href="#examples">Examples</a></li> <li><a href="#contributing">Contributing</a></li> <li><a href="#license">License</a></li> </ul> <a href="#getting-started" id="getting-started" style="color: inherit; text-decoration: none;"> <h2>Getting Started</h2> </a> <pre><code class="language-ts"><span class="hljs-keyword">import</span> { opine } <span class="hljs-keyword">from</span> <span class="hljs-string">&quot;https://deno.land/x/opine@main/mod.ts&quot;</span>;
<span class="hljs-keyword">const</span> app = opine();
app.use(<span class="hljs-function">(<span class="hljs-params">req, res</span>) =&gt;</span> { res.send(<span class="hljs-string">&quot;Hello World&quot;</span>);});
app.listen(<span class="hljs-number">3000</span>);</code></pre> <a href="#installation" id="installation" style="color: inherit; text-decoration: none;"> <h2>Installation</h2> </a> <p>This is a <a href="https://deno.land/">Deno</a> module available to import direct from this repo and via the <a href="https://deno.land/x">Deno Registry</a>.</p> <p>Before importing, <a href="https://deno.land/#installation">download and install Deno</a>.</p> <p>You can then import Opine straight into your project:</p> <pre><code class="language-ts"><span class="hljs-keyword">import</span> { opine } <span class="hljs-keyword">from</span> <span class="hljs-string">&quot;https://deno.land/x/opine@main/mod.ts&quot;</span>;</code></pre> <p>If you want to use a specific version of Opine, just modify the import url to contain the version:</p> <pre><code class="language-ts"><span class="hljs-keyword">import</span> { opine } <span class="hljs-keyword">from</span> <span class="hljs-string">&quot;https://deno.land/x/opine@0.14.0/mod.ts&quot;</span>;</code></pre> <p>Or if you want to use a specific commit of Opine, just modify the import url to contain the commit hash:</p> <pre><code class="language-ts"><span class="hljs-keyword">import</span> { opine } <span class="hljs-keyword">from</span> <span class="hljs-string">&quot;https://deno.land/x/opine@c21f8d6/mod.ts&quot;</span>;</code></pre> <p>Opine is also available on <a href="https://nest.land/package/opine">nest.land</a>, a package registry for Deno on the Blockchain.</p> <pre><code class="language-ts"><span class="hljs-keyword">import</span> { opine } <span class="hljs-keyword">from</span> <span class="hljs-string">&quot;https://x.nest.land/opine@0.14.0/mod.ts&quot;</span>;</code></pre> <a href="#features" id="features" style="color: inherit; text-decoration: none;"> <h2>Features</h2> </a> <ul> <li>Robust routing</li> <li>Focus on high performance</li> <li>Large selection of HTTP helpers including support for downloading / sending files, etags, Content-Disposition, cookies, JSONP etc.</li> <li>Support for static serving of assets</li> <li>View system supporting template engines</li> <li>Content negotiation</li> <li>Compatible with <a href="https://github.com/asos-craigmorten/superdeno">SuperDeno</a> for easy server testing</li> <li>Supports HTTP proxy middleware with <a href="https://github.com/asos-craigmorten/opine-http-proxy">opine-http-proxy</a></li> </ul> <p>And more to come as we achieve feature parity with <a href="https://github.com/expressjs/express">ExpressJS</a>.</p> <a href="#documentation" id="documentation" style="color: inherit; text-decoration: none;"> <h2>Documentation</h2> </a> <ul> <li><a href="https://github.com/asos-craigmorten/opine/blob/main/.github/API/api.md">Opine Docs</a> - usually the best place when getting started ✨</li> <li><del><a href="https://asos-craigmorten.github.io/opine/">Opine Type Docs</a></del> - Unavailable while awaiting GitHub&#39;s support of alternatively named default branches.</li> <li><a href="https://doc.deno.land/https/deno.land/x/opine/mod.ts">Opine Deno Docs</a></li> <li><a href="https://expressjs.com/en/4x/api.html">ExpressJS API Docs</a></li> <li><a href="https://github.com/asos-craigmorten/opine/blob/main/LICENSE.md">License</a></li> <li><a href="https://github.com/asos-craigmorten/opine/blob/main/EXPRESS_LICENSE.md">ExpressJS License</a></li> <li><a href="https://github.com/asos-craigmorten/opine/blob/main/.github/CHANGELOG.md">Changelog</a></li> </ul> <a href="#philosophy" id="philosophy" style="color: inherit; text-decoration: none;"> <h2>Philosophy</h2> </a> <p>The Express philosophy is to provide small, robust tooling for HTTP servers, making it a great solution for single page applications, web sites, hybrids, or public HTTP APIs.</p> <p>Opine will aim to achieve these same great goals, focussing first on developing robust tooling and features before moving onto accelerating performance and becoming super lightweight.</p> <p>As time passes, Opine&#39;s goals may naturally diverge from <a href="https://github.com/expressjs/express">ExpressJS</a> and this will be reflected here.</p> <a href="#examples" id="examples" style="color: inherit; text-decoration: none;"> <h2>Examples</h2> </a> <p>To run the <a href="./examples">examples</a>, you have two choices:</p> <ol> <li><p>Run the example using Deno directly from GitHub, for example:</p> <pre><code class="language-bash">deno run --allow-net --allow-read https://raw.githubusercontent.com/asos-craigmorten/opine/main/examples/hello-world/index.ts</code></pre> </li> <li><p>Clone the Opine repo locally:</p> <pre><code class="language-bash">git <span class="hljs-built_in">clone</span> git://github.com/asos-craigmorten/opine.git --depth 1<span class="hljs-built_in">cd</span> opine</code></pre> <p>Then run the example you want:</p> <pre><code class="language-bash">deno --allow-net --allow-read ./example/hello-world/index.ts</code></pre> </li> </ol> <p>All the <a href="./examples">examples</a> contain example commands in their READMEs to help get you started for either of the above methods.</p> <a href="#contributing" id="contributing" style="color: inherit; text-decoration: none;"> <h2>Contributing</h2> </a> <p><a href="https://github.com/asos-craigmorten/opine/blob/main/.github/CONTRIBUTING.md">Contributing guide</a></p> <hr> <a href="#license" id="license" style="color: inherit; text-decoration: none;"> <h2>License</h2> </a> <p>There are several third party modules that have been ported into this module. Each third party module has maintained it&#39;s license and copyrights. The only exception is for Express, from which this entire module has been ported, whose license and copyrights are available at <a href="./EXPRESS_LICENSE.md">EXPRESS_LICENSE</a> in the root of this repository, and cover all files within the <a href="./src">source</a> directory which not been explicitly licensed otherwise.</p> <p>All modules adapted into this module are licensed under the MIT License.</p> <p>Opine is licensed under the <a href="./LICENSE.md">MIT License</a>.</p> <p>Icon designed and created by <a href="https://www.linkedin.com/in/hannah-morten-b1218017a/">Hannah Morten</a>.</p> </div> </div> <div class="col-4 col-menu menu-sticky-wrap menu-highlight"> <nav class="tsd-navigation primary"> <ul> <li class="globals "> <a href="globals.html"><em>Globals</em></a> </li> <li class=" tsd-kind-module"> <a href="modules/_application_.html">&quot;application&quot;</a> </li> <li class=" tsd-kind-module"> <a href="modules/_methods_.html">&quot;methods&quot;</a> </li> <li class=" tsd-kind-module"> <a href="modules/_middleware_bodyparser_getcharset_.html">&quot;middleware/body<wbr>Parser/get<wbr>Charset&quot;</a> </li> <li class=" tsd-kind-module"> <a href="modules/_middleware_bodyparser_json_.html">&quot;middleware/body<wbr>Parser/json&quot;</a> </li> <li class=" tsd-kind-module"> <a href="modules/_middleware_bodyparser_raw_.html">&quot;middleware/body<wbr>Parser/raw&quot;</a> </li> <li class=" tsd-kind-module"> <a href="modules/_middleware_bodyparser_read_.html">&quot;middleware/body<wbr>Parser/read&quot;</a> </li> <li class=" tsd-kind-module"> <a href="modules/_middleware_bodyparser_text_.html">&quot;middleware/body<wbr>Parser/text&quot;</a> </li> <li class=" tsd-kind-module"> <a href="modules/_middleware_bodyparser_typechecker_.html">&quot;middleware/body<wbr>Parser/type<wbr>Checker&quot;</a> </li> <li class=" tsd-kind-module"> <a href="modules/_middleware_bodyparser_urlencoded_.html">&quot;middleware/body<wbr>Parser/urlencoded&quot;</a> </li> <li class=" tsd-kind-module"> <a href="modules/_middleware_init_.html">&quot;middleware/init&quot;</a> </li> <li class=" tsd-kind-module"> <a href="modules/_middleware_query_.html">&quot;middleware/query&quot;</a> </li> <li class=" tsd-kind-module"> <a href="modules/_middleware_servestatic_.html">&quot;middleware/serve<wbr>Static&quot;</a> </li> <li class=" tsd-kind-module"> <a href="modules/_opine_.html">&quot;opine&quot;</a> </li> <li class=" tsd-kind-module"> <a href="modules/_request_.html">&quot;request&quot;</a> </li> <li class=" tsd-kind-module"> <a href="modules/_response_.html">&quot;response&quot;</a> </li> <li class=" tsd-kind-module"> <a href="modules/_router_index_.html">&quot;router/index&quot;</a> </li> <li class=" tsd-kind-module"> <a href="modules/_router_layer_.html">&quot;router/layer&quot;</a> </li> <li class=" tsd-kind-module"> <a href="modules/_router_route_.html">&quot;router/route&quot;</a> </li> <li class=" tsd-kind-module"> <a href="modules/_types_.html">&quot;types&quot;</a> </li> <li class=" tsd-kind-module"> <a href="modules/_utils_compileetag_.html">&quot;utils/compileETag&quot;</a> </li> <li class=" tsd-kind-module"> <a href="modules/_utils_contentdisposition_.html">&quot;utils/content<wbr>Disposition&quot;</a> </li> <li class=" tsd-kind-module"> <a href="modules/_utils_definegetter_.html">&quot;utils/define<wbr>Getter&quot;</a> </li> <li class=" tsd-kind-module"> <a href="modules/_utils_etag_.html">&quot;utils/etag&quot;</a> </li> <li class=" tsd-kind-module"> <a href="modules/_utils_finalhandler_.html">&quot;utils/final<wbr>Handler&quot;</a> </li> <li class=" tsd-kind-module"> <a href="modules/_utils_fresh_.html">&quot;utils/fresh&quot;</a> </li> <li class=" tsd-kind-module"> <a href="modules/_utils_frommap_.html">&quot;utils/from<wbr>Map&quot;</a> </li> <li class=" tsd-kind-module"> <a href="modules/_utils_merge_.html">&quot;utils/merge&quot;</a> </li> <li class=" tsd-kind-module"> <a href="modules/_utils_mergedescriptors_.html">&quot;utils/merge<wbr>Descriptors&quot;</a> </li> <li class=" tsd-kind-module"> <a href="modules/_utils_normalizetype_.html">&quot;utils/normalize<wbr>Type&quot;</a> </li> <li class=" tsd-kind-module"> <a href="modules/_utils_parseurl_.html">&quot;utils/parse<wbr>Url&quot;</a> </li> <li class=" tsd-kind-module"> <a href="modules/_utils_pathtoregex_.html">&quot;utils/path<wbr>ToRegex&quot;</a> </li> <li class=" tsd-kind-module"> <a href="modules/_utils_stringify_.html">&quot;utils/stringify&quot;</a> </li> <li class=" tsd-kind-module"> <a href="modules/_view_.html">&quot;view&quot;</a> </li> </ul> </nav> <nav class="tsd-navigation secondary menu-sticky"> <ul class="before-current"> </ul> </nav> </div> </div></div><footer class="with-border-bottom"> <div class="container"> <h2>Legend</h2> <div class="tsd-legend-group"> <ul class="tsd-legend"> <li class="tsd-kind-namespace"><span class="tsd-kind-icon">Namespace</span></li> <li class="tsd-kind-variable"><span class="tsd-kind-icon">Variable</span></li> <li class="tsd-kind-function"><span class="tsd-kind-icon">Function</span></li> <li class="tsd-kind-type-alias"><span class="tsd-kind-icon">Type alias</span></li> <li class="tsd-kind-type-alias tsd-has-type-parameter"><span class="tsd-kind-icon">Type alias with type parameter</span></li> </ul> <ul class="tsd-legend"> <li class="tsd-kind-interface"><span class="tsd-kind-icon">Interface</span></li> <li class="tsd-kind-interface tsd-has-type-parameter"><span class="tsd-kind-icon">Interface with type parameter</span></li> </ul> <ul class="tsd-legend"> <li class="tsd-kind-class"><span class="tsd-kind-icon">Class</span></li> </ul> </div> </div></footer><div class="container tsd-generator"> <p>Generated using <a href="https://typedoc.org/" target="_blank">TypeDoc</a></p></div><div class="overlay"></div><script src="assets/js/main.js"></script></body></html>