ExamplesThis directory contains a series of self-contained examples that you can use as
starting points for your app, or as snippets to pull into your existing
applications:
assigned-port - A basic example of starting an Opine server
with a port that is assigned for you.
content-negotiation - An example of how to perform
content negotiation using the res.format()
method.
cors - An example of using CORS with Opine.
dejs - Example of how to use Opine's template engine and rendering
capabilities with the dejs
module.
downloads - Dummy file index server using path matching
patterns and res.download()
to serve files to the user.
error - An example of how to use and write error middleware.
error-pages - Example of how to use Opine's template engine
and rendering capabilities for custom error pages.
eta - Example of how to use Opine's template engine and rendering
capabilities with the eta
template engine.
graphql - Example of how to use Opine with
gql for a simple GraphQL server.
hello-world - A basic example of how to configure and start
an Opine server.
json - An example of how to use the json
body-parser middleware in
your Opine applications.
location - An example of how set the Location
header using
res.location()
for a 301
redirect.
multi-router - An example of how to use the Opine Router
to mount several controllers onto a path within an application / API.
mvc - A basic MVC-style controllers example.
proxy - Example using opine-http-proxy
as a proxy middleware.
raw - An example of how to use the raw
body-parser middleware in
your Opine applications.
react - An example of how you can use Opine with React.
redirect - An example of how to redirect using res.redirect
.
static-files - An example of how to serve static files to a
user using the Opine serveStatic
middleware.
text - An example of how to use the text
body-parser middleware in
your Opine applications.
urlencoded - An example of how to use the urlencoded
body-parser middleware in your Opine applications.