deno.land / x / opine@2.3.4 / docs / index.html

<!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/cmorten/opine/raw/main/.github/icon.png" alt="Deno reading an opinionated book"></a> <h1 align="center">Opine</h1> </p> <p align="center"> A 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/cmorten/opine/tags/"><img src="https://img.shields.io/github/tag/cmorten/opine" alt="Current version" /></a> <img src="https://github.com/cmorten/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/cmorten/opine/issues/"><img src="https://img.shields.io/github/issues/cmorten/opine" alt="Opine issues" /></a> <img src="https://img.shields.io/github/stars/cmorten/opine" alt="Opine stars" /> <img src="https://img.shields.io/github/forks/cmorten/opine" alt="Opine forks" /> <img src="https://img.shields.io/github/license/cmorten/opine" alt="Opine license" /> <a href="https://GitHub.com/cmorten/opine/graphs/commit-activity"><img src="https://img.shields.io/badge/Maintained%3F-no-green.svg" alt="Opine is not maintained" /></a> <a href="https://nest.land/package/opine"><img src="https://nest.land/badge.svg" alt="Published on nest.land" /></a> </p> <p align="center"> <a href="https://deno.land/x/opine"><img src="https://img.shields.io/endpoint?url=https%3A%2F%2Fdeno-visualizer.danopia.net%2Fshields%2Flatest-version%2Fx%2Fopine%2Fmod.ts" alt="Opine latest /x/ version" /></a> <a href="https://github.com/denoland/deno/blob/main/Releases.md"><img src="https://img.shields.io/badge/deno-1.32.4-brightgreen?logo=deno" alt="Minimum supported Deno version" /></a> <a href="https://deno-visualizer.danopia.net/dependencies-of/https/deno.land/x/opine/mod.ts"><img src="https://img.shields.io/endpoint?url=https%3A%2F%2Fdeno-visualizer.danopia.net%2Fshields%2Fdep-count%2Fx%2Fopine%2Fmod.ts" alt="Opine dependency count" /></a> <a href="https://deno-visualizer.danopia.net/dependencies-of/https/deno.land/x/opine/mod.ts"><img src="https://img.shields.io/endpoint?url=https%3A%2F%2Fdeno-visualizer.danopia.net%2Fshields%2Fupdates%2Fx%2Fopine%2Fmod.ts" alt="Opine dependency outdatedness" /></a> <a href="https://deno-visualizer.danopia.net/dependencies-of/https/deno.land/x/opine/mod.ts"><img src="https://img.shields.io/endpoint?url=https%3A%2F%2Fdeno-visualizer.danopia.net%2Fshields%2Fcache-size%2Fx%2Fopine%2Fmod.ts" alt="Opine cached size" /></a> </p> <hr> <p><em><strong>Now in maintenance mode:</strong> Deno has introduced Node and NPM compat, <a href="https://deno.com/blog/v1.25#experimental-npm-support">considering using Express itself in Deno</a>!</em></p> <pre><code class="language-ts"><span class="hljs-keyword">import</span> express <span class="hljs-keyword">from</span> <span class="hljs-string">&quot;npm:express&quot;</span>; </code></pre> <p>Express not working for you? <a href="https://github.com/denoland/deno/issues">Raise an issue on Deno</a> and keep reading for Opine usage :tada:</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="#quick-start">Quick Start</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@2.3.4/mod.ts&quot;</span>; <span class="hljs-keyword">const</span> app = opine(); app.get(<span class="hljs-string">&quot;/&quot;</span>, <span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params">req, res</span>) </span>{ res.send(<span class="hljs-string">&quot;Hello World&quot;</span>); }); app.listen(<span class="hljs-number">3000</span>, <span class="hljs-function">() =&gt;</span> <span class="hljs-built_in">console</span>.log(<span class="hljs-string">&quot;server has started on http://localhost:3000 🚀&quot;</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@2.3.4/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@2.3.4/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>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> </ul> <a href="#documentation" id="documentation" style="color: inherit; text-decoration: none;"> <h2>Documentation</h2> </a> <ul> <li><a href="https://github.com/cmorten/opine/blob/main/.github/API/api.md">Opine Docs</a> - usually the best place when getting started ✨</li> <li><a href="https://cmorten.github.io/opine/">Opine Type Docs</a></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/cmorten/opine/blob/main/LICENSE.md">License</a></li> <li><a href="https://github.com/cmorten/opine/blob/main/EXPRESS_LICENSE.md">ExpressJS License</a></li> <li><a href="https://github.com/cmorten/opine/blob/main/.github/CHANGELOG.md">Changelog</a></li> </ul> <a href="#quick-start" id="quick-start" style="color: inherit; text-decoration: none;"> <h2>Quick Start</h2> </a> <p>The quickest way to get started with Opine is to utilize the <a href="https://github.com/cmorten/opine-cli">Opine CLI</a> to generate an application as shown below:</p> <p>Install the executable. The executable&#39;s major version will match Opine&#39;s:</p> <pre><code class="language-bash">deno install -f -q --allow-read --allow-write --allow-net --unstable https://deno.land/x/opinecli@2.0.0/opine-cli.ts </code></pre> <p>And follow any suggestions to update your <code>PATH</code> environment variable.</p> <p>Create the app:</p> <pre><code class="language-bash">opine-cli --view=ejs hello-deno &amp;&amp; <span class="hljs-built_in">cd</span> hello-deno </code></pre> <p>Start your Opine app at <code>http://localhost:3000/</code>:</p> <pre><code class="language-bash">deno run --allow-net --allow-read --allow-env mod.ts </code></pre> <a href="#philosophy" id="philosophy" style="color: inherit; text-decoration: none;"> <h2>Philosophy</h2> </a> <p>The <a href="https://github.com/expressjs/express">Express</a> 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 aimed to achieve these same great goals, focussing on providing equivalent robust tooling and features for Deno uses.</p> <p>Now Deno&#39;s <a href="https://deno.land/std/node/README.md">Node compatibility layer</a> is maturing sufficiently to support Express out of the box, Opine is operating maintenance mode.</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/cmorten/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/cmorten/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 run --allow-net --allow-read ./examples/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/cmorten/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_compilequeryparser_.html">&quot;utils/compile<wbr>Query<wbr>Parser&quot;</a> </li> <li class=" tsd-kind-module"> <a href="modules/_utils_compiletrust_.html">&quot;utils/compile<wbr>Trust&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_cookies_.html">&quot;utils/cookies&quot;</a> </li> <li class=" tsd-kind-module"> <a href="modules/_utils_createerror_.html">&quot;utils/create<wbr>Error&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_forwarded_.html">&quot;utils/forwarded&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_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_proxyaddr_.html">&quot;utils/proxy<wbr>Addr&quot;</a> </li> <li class=" tsd-kind-module"> <a href="modules/_utils_send_.html">&quot;utils/send&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-function tsd-has-type-parameter"><span class="tsd-kind-icon">Function with type parameter</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>
opine

Version Info

Tagged at
a year ago