Code Monkey home page Code Monkey logo

opine's Introduction

Deno reading an opinionated book

Opine

A minimalist web framework for Deno ported from ExpressJS.

Current version Current test status Deno docs PRs are welcome Opine issues Opine stars Opine forks Opine license Opine is not maintained Published on nest.land

Opine latest /x/ version Minimum supported Deno version Opine dependency count Opine dependency outdatedness Opine cached size


Now in maintenance mode: Deno has introduced Node and NPM compat, considering using Express itself in Deno!

import express from "npm:express";

Express not working for you? Raise an issue on Deno and keep reading for Opine usage πŸŽ‰


Table of Contents

Getting Started

import { opine } from "https://deno.land/x/[email protected]/mod.ts";

const app = opine();

app.get("/", function (req, res) {
  res.send("Hello World");
});

app.listen(3000, () =>
  console.log("server has started on http://localhost:3000 πŸš€")
);

Installation

This is a Deno module available to import direct from this repo and via the Deno Registry.

Before importing, download and install Deno.

You can then import Opine straight into your project:

import { opine } from "https://deno.land/x/[email protected]/mod.ts";

Opine is also available on nest.land, a package registry for Deno on the Blockchain.

import { opine } from "https://x.nest.land/[email protected]/mod.ts";

Features

  • Robust routing
  • Large selection of HTTP helpers including support for downloading / sending files, etags, Content-Disposition, cookies, JSONP etc.
  • Support for static serving of assets
  • View system supporting template engines
  • Content negotiation

Documentation

Quick Start

The quickest way to get started with Opine is to utilize the Opine CLI to generate an application as shown below:

Install the executable. The executable's major version will match Opine's:

deno install -f -q --allow-read --allow-write --allow-net --unstable https://deno.land/x/[email protected]/opine-cli.ts

And follow any suggestions to update your PATH environment variable.

Create the app:

opine-cli --view=ejs hello-deno && cd hello-deno

Start your Opine app at http://localhost:3000/:

deno run --allow-net --allow-read --allow-env mod.ts

Philosophy

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.

Opine aimed to achieve these same great goals, focussing on providing equivalent robust tooling and features for Deno uses.

Now Deno's Node compatibility layer is maturing sufficiently to support Express out of the box, Opine is operating maintenance mode.

Examples

To run the examples, you have two choices:

  1. Run the example using Deno directly from GitHub, for example:

    deno run --allow-net --allow-read https://raw.githubusercontent.com/cmorten/opine/main/examples/hello-world/index.ts
  2. Clone the Opine repo locally:

    git clone git://github.com/cmorten/opine.git --depth 1
    cd opine

    Then run the example you want:

    deno run --allow-net --allow-read ./examples/hello-world/index.ts

All the examples contain example commands in their READMEs to help get you started for either of the above methods.

Contributing

Contributing guide


License

There are several third party modules that have been ported into this module. Each third party module has maintained it'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 EXPRESS_LICENSE in the root of this repository, and cover all files within the source directory which not been explicitly licensed otherwise.

All modules adapted into this module are licensed under the MIT License.

Opine is licensed under the MIT License.

Icon designed and created by Hannah Morten.

opine's People

Contributors

0xtlt avatar abbasogaji avatar aetheve avatar asos-craigmorten avatar baw-appie avatar cmorten avatar fabervitale avatar fucksophie avatar gumberss avatar koddsson avatar michael-spengler avatar nebrelbug avatar njromano avatar owenoclee avatar ramonmedeiros avatar seitbekir-seidametov-codeit avatar srepollock avatar t8 avatar tanay-pingalkar avatar tillathehun0 avatar twilson63 avatar xyzshantaram avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

opine's Issues

[FEAT] Upgrade Opine to support Deno 1.4.0 and std 0.69.0

Issue

Setup:

  • Deno Version: 1.4.0

Details

Upgrade Opine to support Deno 1.4.0 and std 0.69.0

This will require several dependencies to be upgraded first before we can get Opine over the line. Please see the PR #70 for details - any help getting deps upgraded is much appreciated!

[BUG] Cannot read property 'req' of undefined when using serveStatic function

Issue

Setup:

  • Deno Version: 1.3.0
  • v8 Version: 8.6.334
  • Typescript Version: 3.9.7
  • Opine Version: 0.20.2

After following the tutorial for using Opine with dejs here I get an issue where when I try and load the site it gives an error

Not sure if this is relevant but I'm running Windows 10 2004 x64

Details

I installed deno using the following command in powershell: iwr https://deno.land/x/install/install.ps1 -useb | iex

I then followed the tutorial writing out all the code and went to run it using deno run --allow-net --allow-env --allow-read=./ ./entrypoint.ts however if I then try and load the page I get the following error displayed instead of my index page:
image

Exact code used

https://github.com/futurelucas4502/Opine-dejs

[FEATURE] Automate typedoc updates using GitHub actions

Issue

Create a GitHub action to create and merge updates to the typedocs.

Details

Currently typedoc creation is a manual process which pollutes the PR with dozens of files and detracts from the main work.

This task is to create a GitHub action workflow which is triggered on merges to main which will subsequent update the typedocs and merge them in as a subsequent commit.

As a sketch (not tested):

name: Publish TypeDocs

on:
  push:
    branches: [main]

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v2
      - name: Use Deno v1.1.1
        uses: denolib/setup-deno@master
        with:
          deno-version: 1.1.1
      - run: make typedoc
      - name: push
        uses: github-actions-x/[email protected]
        with:
          github-token: ${{ secrets.GITHUB_TOKEN }}
          push-branch: 'main'
          commit-message: 'publish typedocs'

REF: https://github.com/github-actions-x/commit

There may be better actions on the marketplace - this was just the first one I found on google.

Notes:

  • Need to ensure the _config.yaml is preserved.
  • Need to make sure the docs are formatted using make fmt - some generated files fail the deno fmt --check check.
  • Should update the make typedoc command to include --name opine
  • Will need to add steps to install typescript and typedoc NPM packages
  • Investigate whether any of this is available via deno CLI commands.

Compiled executables don't work

Issue

Setup:

  • Deno Version: 1.8.0
  • v8 Version: 9.0.257.3
  • Typescript Version: 4.2.2
  • Opine Version: 1.1.0

Details

I have replicated the Eta templating example for Opine and while the example itself worked, when I try to compile this program to a Windows executable, I get the following error upon running it:

error: ReferenceError: to is not defined
    at Function.app1.on (file://$deno$/bundle.js:30032:42)
    at Function.defaultConfiguration (file://$deno$/bundle.js:28769:10)
    at Function.init (file://$deno$/bundle.js:28756:10)
    at opine (file://$deno$/bundle.js:30051:10)
    at file://$deno$/bundle.js:32779:14

I have tried compiling executables before, but they only used standard libraries. I assumed this might be a problem with opine, as the callstack in that error message refers to it. I don't know if there are any command line arguments that could help in producing a more helpful error log

[FEAT] Support req.range() API

Issue

Add the req.range() API.

Details

See:

Express uses the range-parser package - see https://github.com/jshttp/range-parser/. This doesn't look to have any deps and therefore may be usable via Pika/Skypack/JSPM which would make this task reasonably simple! If it cannot be used via a CDN then we can look to port it and add to the utils directory, including appropriate copyright notices etc.

[DOCS] Document app.param() and Router.param() in API docs

Issue

Add API documentation for newly implemented app.param() and Router.param() APIs

Details

Add the documentation to the the API docs found in the ./.github/API/ directory. Generally documentation can be lifted fairly seamlessly, but take care to:

  • follow the current Opine docs style
  • refer to Express only when demonstrating influence / referring to original source for legal or drawing comparison, otherwise use Opine
  • use ts over js for files and code blocks

Express Docs:

Express Docs Src:

bug: Response.location doesn't exist

Issue

Response object doesn't have the location property, neither redirect.

Details

Technically, there is a location property on Response object as said here: https://github.com/asos-craigmorten/opine/blob/master/.github/API/response.md#reslocationpath

But there isn't, here a simple example:

I would like the route "/redirect" to redirect to "/home":

app.get('/redirect',(req,res,next)=>{
	res.location("/home") //location doesn't exist
})

I don't know if I am doing anything wrong or it's really a bug.

Thanks πŸ˜„

Implement opine into nest.land

Details

As we discussed on Discord, it would be great if you could register opine on nest.land! I'm going to make a PR with an egg.json file already added so you don't have to do this manually.

[FEAT] Response lifecycle hooks

Issue

In node there are libraries like on-headers and on-finished that are commonly use to run logic before and after a request has been processed, some example:

It would be nice to port some of these projects to opine but it is not currently as easy as it should for a middleware to be called back when one of these events occurs:

  1. Beforereq.respond: An async response is complete (e.g db returns output) and we are going to call request.respond.

  2. After req.respond: A request has been processed and the response has been sent, essentially the output of request.respond.

Suggested Changes

  1. Add a getter that returns a lazily instantiated and cached promise that resolves before calling request.respond.

  2. Add a getter that exposes the output of request.respond.

Error while bundling opine's mod.ts

Issue

Setup:

  • Deno Version: 1.6.2
  • v8 Version: 8.8.278.2
  • Typescript Version: 4.1.3
  • Opine Version: 1.0.0

I'm receiving an error when i try to use a bundled version of opine

Details

I'm trying to use a bundled version of opine to avoid errors with #97 (deno bundle https://deno.land/x/[email protected]/mod.ts)
the bundle generated successfully but when i try to use this bundle like :

import { opine } from "./opine.js";

const app = opine();

app.get("/", function(req, res) {
  res.send("Hello World");
});

app.listen(3000, ()=>console.log('http://localhost:3000'));

I'm getting this error

$ deno run --no-check serve.ts
error: Uncaught ReferenceError: Cannot access 'request2' before initialization
request2.get = function get(name) {
^
    at file:///home/mo/opine.js:309:1

without --no-check :

$ deno run serve.ts
Check file:///home/mo/serve.ts
error: TS2339 [ERROR]: Property 'get' does not exist on type '{ (req: any, res: Response1 | undefined, next: any): void; emit(event: any, arg: any): any; on(event: any, arg: any): any; request: any; response: any; }'.
app.get("/", function(req, res) {
    ~~~
    at file:///home/mo/serve.ts:5:5

TS7006 [ERROR]: Parameter 'req' implicitly has an 'any' type.
app.get("/", function(req, res) {
                      ~~~
    at file:///home/mo/serve.ts:5:23

TS7006 [ERROR]: Parameter 'res' implicitly has an 'any' type.
app.get("/", function(req, res) {
                           ~~~
    at file:///home/mo/serve.ts:5:28

TS2339 [ERROR]: Property 'listen' does not exist on type '{ (req: any, res: Response1 | undefined, next: any): void; emit(event: any, arg: any): any; on(event: any, arg: any): any; request: any; response: any; }'.
app.listen(3000, ()=>console.log('R...'));
    ~~~~~~
    at file:///home/mo/serve.ts:9:5

Found 4 errors.

[FEAT] Support all Express options for file-related response APIs

Issue

Support full suite of Express options for the sendFile() and download() response APIs, as well as the serveStatic() API options.

Details

Should support:

See also https://github.com/expressjs/serve-static/#options

Why don't you use `deps.ts` for React and so on?

Issue

This issue is question.

Why don't you use deps.ts for React and so on?

Details

I looked at Craig's nice entry.
Then I looked at this source in the repo. https://github.com/asos-craigmorten/opine/blob/main/examples/react/server.tsx

If the deps.ts seems to have the role of package.json, you can write following into deps.ts.

import { renderFileToString } from "https://deno.land/x/[email protected]/mod.ts";
import React from "https://dev.jspm.io/[email protected]";

Am I wrong?

Can't assign new properties to "req"

Issue

Can't assign new properties to "req"
Setup:

  • Deno Version: 1.0.0
  • v8 Version: v8 8.4.300
  • Typescript Version: 3.9.2
  • Opine Version: 0.19.1

For example; req.user (throws an error since Property 'user' does not exist on type 'Request<ParamsDictionary, any, any>')

Details

Please replace this quote block with the details of the feature / bug you wish to be addressed. If it is a bug please do your best to add steps to reproduce.

[FEAT] Expose proxy Request class for public interface

Issue

Currently the Opine Request object is a mutated version of the Deno ServerRequest. This refactor is to instead create a new Request class that is provided to the user, whose methods / properties proxy to the underlying ServerRequest.

Details

As the body property of ServerRequest is read-only it leads to a jarring interface when Opine body-parsers have to place parsed bodies onto a parsedBody property rather than onto body itself. This deviates from Express, which though isn't necessarily a bad thing, given the goal of initially mirroring the API as close as possible for v1 it is certainly something that should be achievable easily enough.

Initial thoughts are to create a new Request class which contains the custom Opine methods / getters etc. and which also supports the ServerRequest interface with at least one difference: the body property should be either the #parsedBody if exists, or fallback to the ServerRequest body or rawBody if not.

As a rough guide:

class Request {
  parsedBody: string; // TBC
  rawBody: Deno.reader | UInt8Array | Buffer | string; // TBC

  constructor(request: ServerRequest) {
    this.rawBody = request.body;
    // ...
  }

  get body() {
    return this.parsedBody ?? this.rawBody;
  }
}

[FEAT] Support `trust proxy` application setting

[FEAT] Support GZIP and Deflate Compression

Issue

Setup:

Add support for deflate and gzip encoding in body-parsers.

Details

Currently gzip and deflate are not supported in Opine and throw a 415 error. This issue is to add support to Opine for these two standard options which is now possible due to modules being made available in the Deno userland.

Relevant file: ./src/middleware/bodyParser/read.ts Line 117.

Modules to explore:

Error when i start script with --no-check flag

Issue

Setup:

  • Deno Version: 1.6.2
  • v8 Version: 8.8.278.2
  • Typescript Version: 4.1.3
  • Opine Version: 1.0.0

I'm getting an error while i disable ts check for my app

Details

command : deno run -A --no-check serve.ts
output :

error: Uncaught SyntaxError: The requested module './CtxLike.ts' does not provide an export named 'CtxLike'
export { CtxLike } from "./CtxLike.ts";
~~~~~~~
    at <anonymous> (<https://deno.land/x/[email protected]/lib/types/interfaces/index.ts>:5:1)

code i use :

import { opine } from "https://deno.land/x/[email protected]/mod.ts";

const app = opine();

app.get("/", function(req, res) {
  res.send("Hello World");
});

app.listen(3000);

[BUG] BrokenPipe Crash

Issue

Setup:

deno 1.6.3 (release, x86_64-unknown-linux-gnu)
v8 8.8.294
typescript 4.1.3

  • Opine Version: 1.0.0

Uncaught BrokenPipe: Broken pipe (os error 32)

Details

Hello, it's been a while since Opine crashed randomly with a system error, at the time it was on my mac, now on my windows and also on a linux server, the error returned is still the same:

error: Uncaught (in promise) BrokenPipe: Broken pipe (os error 32)
    at unwrapResponse (deno:runtime/js/10_dispatch_minimal.js:59:13)
    at sendAsync (deno:runtime/js/10_dispatch_minimal.js:98:12)
    at async write (deno:runtime/js/12_io.js:117:20)
    at async BufWriter.write (bufio.ts:499:29)
    at async writeResponse (_io.ts:273:15)
    at async Proxy.respond (server.ts:84:7)
    at async Response.end (response.ts:256:7)

Maybe you have to surround Opine with a try catch?
The crash occurs with any code that uses opine, however I noticed that the more routes there are, the more often it happens

Router in opine as in express

Issue

##Β Details

Please add details of the feature / bug you wish to be addressed. If it is a bug please add steps to reproduce.
I think Opine does not contain Router just like in express if is it then please let us know
const { Router } = require('express');
what is its alternative in Opine thanks in advance.

TypeScript Error: TS2345 [ERROR]: Argument of type 'string | URL' is not assignable to parameter of type 'string'.

Issue

Setup:

  • deno 1.2.0
  • v8 8.5.216
  • typescript 3.9.2
  • opine main at 2295ba2

(Also checked with the latest v0.18.0)

Details

When running my program:

// mod.ts
import {opine} from "https://deno.land/x/opine@main/mod.ts";

const app = opine();

app.get('/', (req, res) => {
    res.send('Hello Deno Land πŸ¦•');
});

app.listen(3000);
console.log("running at htpss://localhost:3000");

with the command: deno run mod.ts

I get the following error:

error: TS2345 [ERROR]: Argument of type 'string | URL' is not assignable to parameter of type 'string'.
  Type 'URL' is not assignable to type 'string'.
  return new URL(url).pathname
                 ~~~
    at https://deno.land/[email protected]/path/win32.ts:917:18

TS2345 [ERROR]: Argument of type 'string | URL' is not assignable to parameter of type 'string'.
  Type 'URL' is not assignable to type 'string'.
  return new URL(url).pathname;
                 ~~~
    at https://deno.land/[email protected]/path/posix.ts:438:18

TS2345 [ERROR]: Argument of type 'string | URL' is not assignable to parameter of type 'string'.
  Type 'URL' is not assignable to type 'string'.
  return new URL(url).pathname
                 ~~~
    at https://deno.land/[email protected]/path/win32.ts:917:18

TS2345 [ERROR]: Argument of type 'string | URL' is not assignable to parameter of type 'string'.
  Type 'URL' is not assignable to type 'string'.
  return new URL(url).pathname;
                 ~~~
    at https://deno.land/[email protected]/path/posix.ts:438:18

TS2345 [ERROR]: Argument of type 'ParsedURL' is not assignable to parameter of type 'string'.
    const loc = encodeUrl(new URL(originalUrl).toString());
                                  ~~~~~~~~~~~
    at https://deno.land/x/opine@main/src/middleware/serveStatic.ts:227:35

Found 5 errors.

I've traced the issue to these two lines:

https://github.com/asos-craigmorten/opine/blob/2295ba25be8320e0a3adfb5fe9d53477b02d1650/src/middleware/serveStatic.ts#L227

https://github.com/asos-craigmorten/opine/blob/2295ba25be8320e0a3adfb5fe9d53477b02d1650/src/utils/parseUrl.ts#L70

I believe this is an error in type and should be addressed. I cannot run my program at this time. Let me know if you agree this is the issue and I can try to implement a fix.

[BUG] react example does not work with deno 1.7.5

Issue

Setup:

  • Deno Version: deno 1.7.5
  • v8 Version: 9.0.123
  • Typescript Version: 4.1.4
  • Opine Version: 1.1.0

Details

react example looks to be broken with latest Deno.

Primarily, this is caused by breaking change where Deno.bundle is deprecated in favor of Deno.emit.
Also, I needed to bump dejs (I bumped to [email protected]) to get it working.

I have fix working locally if you'd like me to submit a pr.

Also, was wondering, if this is supposed to be an example, does it make sense to use full opine urls instead of local ref?
ala: import { opine, serveStatic } from "https://deno.land/x/[email protected]/mod.ts";
instead of: import { opine, serveStatic } from "../../mod.ts";

Network access is required to run?

Issue

Setup:

  • Deno Version: 1.6.2 (but also occurs for earlier versions)
  • v8 Version: <replace_with_v8_version>
  • Typescript Version: 4.1.3
  • Opine Version: 1.0.0 (but also occurs for versions 0.24.0, 0.25.0, 0.26.0 & 0.27.0

Please replace this line with a short description of the issue.

Details

Since v0.24.0 Opine seems to required network access to run.

Steps to reproduce

Step 1: Create an app.ts file with the following contents

import { opine } from "https://deno.land/x/[email protected]/mod.ts";

const app = opine();

app.get("/", function(req, res) {
  res.send("Hello World");
});

app.listen(3000);

Step 2: Run deno cache app.ts to cache the dependencies

Step 3: Run `deno run app.ts' and get the following error

error: Uncaught (in promise) PermissionDenied: network access to "https://deno.land/x/[email protected]/pkg/denoflate_bg.wasm", run again with the --allow-net flag
    at processResponse (deno:core/core.js:223:11)
    at Object.jsonOpAsync (deno:core/core.js:240:12)
    at async fetch (deno:op_crates/fetch/26_fetch.js:1278:29)
    at async read (mod.ts:19:15)
    at async init (https://deno.land/x/[email protected]/pkg/denoflate.js:217:45)
    at async mod.ts:23:1

I would have expected this to run without an error.

[DOCS] Cors Enablements

First of all: Thank you for this module.

As I could not find a simple & quick solution for cors enablement so far, I created a corresponding PR on https://deno.land/x/cors.

If you know any better approaches, please let me know.

[REFACTOR] Performance focus

Issue

Setup:

This issue is for first draft performance improvements to Opine.

Details

When first starting out, Opine was up to 2x faster than Express on the benchmarks and a good contender among the other server frameworks Deno currently has on offer.

Given the initial priority of feature parity, performance has been a second class citizen and has suffered, now up to 30% slower than Express in benchmarks.

Ideas welcome for how we can bring the performance back up without compromising the rich set of APIs that the framework has to offer.

[TEST] Improve body parser test coverage

Issue

The current body-parser test coverage is low, this issue seeks to improve the coverage.

Details

The Opine body-parser test code was written prior to the creation of SuperDeno and thus was unpractical at the time to port test code from the original source. Now the supertest equivalent exists we should look to improve the test coverage of these modules.

Test files:

  • ./test/units/bodyParser.json.test.ts
  • ./test/units/bodyParser.raw.test.ts
  • ./test/units/bodyParser.text.test.ts
  • ./test/units/bodyParser.urlencoded.test.ts

See https://github.com/expressjs/body-parser for details, specifically https://github.com/expressjs/body-parser/tree/master/test for guidance on desired coverage.

/react and /dejs examples are broken

Issue

How to reproduce

  1. Update deno to 1.2.1.
  2. Run deno run -A /examples/dejs/index.ts or deno run -A /examples/react/server.ts.
error: TS2345 [ERROR]: Argument of type 'string | URL' is not assignable to parameter of type 'string'.
  Type 'URL' is not assignable to type 'string'.
  return new URL(url).pathname
                 ~~~
    at https://deno.land/[email protected]/path/win32.ts:911:18

TS2345 [ERROR]: Argument of type 'string | URL' is not assignable to parameter of type 'string'.
  Type 'URL' is not assignable to type 'string'.
  return new URL(url).pathname;
                 ~~~
    at https://deno.land/[email protected]/path/posix.ts:433:18

Found 2 errors.

Details

Updating dejs to 0.8.0 fixes the issue.

$ deno --version
deno 1.2.1
v8 8.5.216
typescript 3.9.2

Sidenote

External dependencies in /examples should be consolidated either with an importMap or using a ./examples/deps.ts file, see #41.

Error executing sample script from https://deno.land/x/opine

Issue

Setup:

  • Deno Version: 1.1.2
  • v8 Version: 8.5.216
  • Typescript Version: 3.9.2
  • Opine Version: opine@main/mod.ts
  • (environment variable) DENO_INSTALL=/home/rick/.deno

Error when executing deno sample script from https://deno.land/x/opine

Details

I saved the sample script with name "sampleOpine.ts", then executed it as below. It threw an error as follows:

deno run sampleOpine.ts
Check file:///home/rick/Working/Playpen/deno/OpineTemplate/sampleOpine.ts
error: TS2305 [ERROR]: Module '"./_utils"' has no exported member 'normalizeEncoding'.
import { notImplemented, normalizeEncoding } from "./_utils.ts";
~~~~~~~~~~~~~~~~~
at https://deno.land/std/node/buffer.ts:3:26

Not quite sure what to do with this, or if it's my configuration that's the problem. NB: I was able to successfully run a Deno server app using OAK on the same machine.

Unable to serve static files

Unable to serve static files

Setup:

  • Deno Version: 1.1.3
  • v8 Version: 8.5.216
  • Typescript Version: 3.9.2
  • Opine Version: main

I try to run your example:
deno run --allow-net --allow-read https://raw.githubusercontent.com/asos-craigmorten/opine/main/examples/static-files/index.ts

And the app runs and says this:

listening on port 3000
try:
  GET /hello.txt
  GET /js/app.js
  GET /js/helper.js
  GET /css/style.css
try the files served under `static/`:
  GET /static/hello.txt
  GET /static/js/app.js
  GET /static/js/helper.js
  GET /static/css/style.css
try the css served on the root:
  GET /style.css

But then nothing seems to actually be served up either in browser or Postman
Screen Shot 2020-09-08 at 11 56 05 AM

@asos-craigmorten Would really appreciate your help! thanks

[FEATURE] Capture errors from async routes

Issue

Setup:

  • Deno Version: 1.1.1
  • v8 Version: <replace_with_v8_version>
  • Typescript Version: <replace_with_typescript_version>
  • Opine Version: main

If you throw an error in an async route, this error won't be caught for an error route

Details

The error:

The code:

The result expected:

[FEATURE] Add template rendering support

Issue

Add support for template rendering / view engines.

Details

Add the following public APIs:

  • app.engine() method
  • app.render() method
  • res.render() method

Which will review the following internals / supporting public APIs:

  • View class
  • app.engines
  • Settings:
    • view
    • views
    • view cache
    • view engine

TypeError: Cannot read property 'get' of undefined

Setup:

  • deno 1.9.0 (release, x86_64-pc-windows-msvc)
  • v8 9.1.269.5
  • typescript 4.2.2
  • Opine 1.2.0

Details

Hi, I'm trying to run getting started code from opine deno land, but I got this error message
image

Is there any problem I am facing, any solution that may work? thank you in advance

[FEAT] Support `query parser` application setting

Issue

Setup:

This issue is to support the query parser (and query parser fn) application setting, allowing users to support custom querystring parsers in Opine.

Details

See:

There isn't currently a qs library Deno equivalent, but we can look to implement the application setting allowing us to pass a custom parser function as well as investigating PIKA/SkyPack/JSPM to see if using qs is an option.

Add Eta template engine to examples

This is a really cool project!

I'm the maintainer of the Eta template engine, and I just added Deno support. I'd love to add an example of a server using Eta to the Opine examples. Could I submit a PR?

Exported middleware causing error in latest version

Issue

Setup:

  • Deno Version: <1.9.0>
  • v8 Version: <9.1.269.5>
  • Typescript Version: <4.2.2>
  • Opine Version: <1.3.2>

Details

log.ts

export const logErrors = (error: any, req: Request, res: Response, next: NextFunction) => {
  console.error(error.stack);
  next(error);
};

app.ts

import { logErrors } from './log.ts';
...
app.use(logError);

error: TS2612 [ERROR]: Property 'resolve' will overwrite the base property in 'Deferred'. If this is intentional, add an initializer. Otherwise, add a 'declare' modifier or remove the redundant declaration.
public readonly resolve!: () => void;
~~~~~~~
at https://deno.land/x/[email protected]/tools/Deferred.ts:57:21

kindly help me out of it

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.