cmorten / opine Goto Github PK
View Code? Open in Web Editor NEWMinimalist web framework for Deno ported from ExpressJS.
Home Page: https://github.com/cmorten/opine/blob/main/.github/API/api.md
License: MIT License
Minimalist web framework for Deno ported from ExpressJS.
Home Page: https://github.com/cmorten/opine/blob/main/.github/API/api.md
License: MIT License
The current body-parser test coverage is low, this issue seeks to improve the coverage.
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:
See https://github.com/expressjs/body-parser for details, specifically https://github.com/expressjs/body-parser/tree/master/test for guidance on desired coverage.
Hello everyone, can we create a project board here to map everything we need to develop and fix?
Setup:
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
Support full suite of Express options for the sendFile()
and download()
response APIs, as well as the serveStatic()
API options.
Should support:
options
- see https://github.com/pillarjs/send#sendreq-path-optionsSetup:
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
Upgrade eggs CLI to version 0.1.3
and add repository field.
Setup:
I'm getting an error while i disable ts check for my app
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);
Add the req.range()
API.
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.
Please replace this line with a short description of the issue.
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.
## 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.
Setup:
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
@asos-craigmorten Would really appreciate your help! thanks
Setup:
deno 1.6.3 (release, x86_64-unknown-linux-gnu)
v8 8.8.294
typescript 4.1.3
Uncaught BrokenPipe: Broken pipe (os error 32)
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
Add the app.param()
API.
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.
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.
Pagic is a static site generator powered by Deno + React
Here are some demos:
If it is possible to use pagic to build the website, I would like to create the pull-request
Support objects and arrays of headers in the res.set()
API.
Express Docs: https://expressjs.com/en/4x/api.html#res.set
Setup:
This issue is to support the trust proxy
(and trust proxy fn
) application setting, allowing users to indicate their Opine app is behind a front-facing proxy.
This issue includes the support of req.ip()
and req.ips()
APIs.
See:
Response object doesn't have the location property, neither redirect.
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 😄
Setup:
I'm receiving an error when i try to use a bundled version of opine
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.
Setup:
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
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:
Background: I like it very much + I like the concept of https://nest.land/
I'm already relying in some production contexts on opine :) 👍
Setup:
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!
Setup:
(Also checked with the latest v0.18.0)
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:
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.
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?
Setup:
This issue is to support the query parser
(and query parser fn
) application setting, allowing users to support custom querystring parsers in Opine.
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.
Support the Express signature for the cookie()
and clearCookie()
APIs.
These APIs already exist in Opine, but the signature is different - expecting a full Cookie
object vs the Express name, value and options signature.
See:
Add a code example for an MVC application using Opine.
See https://github.com/expressjs/express/tree/master/examples/mvc for a guideline.
Can't assign new properties to "req"
Setup:
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.
This issue is question.
Why don't you use deps.ts
for React and so on?
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?
Setup:
Benchmark fails on contributions from forks due to permissions error posting a comment to the PR.
See #12. Notes copied below:
Uft that's annoying. TIL GH actions can't comment on PRs contributed from forks because it downgrades the permissions of the
GITHUB_TOKEN
it uses.REF: https://github.community/t/github-actions-are-severely-limited-on-prs/18179
Will look into implementing on of the workarounds like this one later maybe!
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:
Beforereq.respond
: An async response is complete (e.g db returns output) and we are going to call request.respond.
After req.respond
: A request has been processed and the response has been sent, essentially the output of request.respond
.
Add a getter that returns a lazily instantiated and cached promise that resolves before calling request.respond.
Add a getter that exposes the output of request.respond.
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.
Updating dejs to 0.8.0 fixes the issue.
$ deno --version
deno 1.2.1
v8 8.5.216
typescript 3.9.2
External dependencies in /examples should be consolidated either with an importMap or using a ./examples/deps.ts
file, see #41.
Create a GitHub action to create and merge updates to the typedocs.
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:
_config.yaml
is preserved.make fmt
- some generated files fail the deno fmt --check
check.make typedoc
command to include --name opine
deno
CLI commands.Setup:
This issue is for first draft performance improvements to Opine.
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.
Add support for template rendering / view engines.
Add the following public APIs:
app.engine()
methodapp.render()
methodres.render()
methodWhich will review the following internals / supporting public APIs:
View
classapp.engines
view
views
view cache
view engine
Setup:
Hi, I'm trying to run getting started code from opine deno land, but I got this error message
Is there any problem I am facing, any solution that may work? thank you in advance
Setup:
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";
Setup:
Add support for deflate and gzip encoding in body-parsers.
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:
Add API documentation for newly implemented app.param()
and Router.param()
APIs
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:
ts
over js
for files and code blocksExpress Docs:
Express Docs Src:
error: Import 'https://deno.land/x/vary@dc17535/mod.ts' failed: 403 Forbidden
Imported from "https://deno.land/x/[email protected]/deps.ts:46"
This is caused by this line:
https://github.com/asos-craigmorten/opine/blob/main/deps.ts#L46
Not sure what the version is supposed to be, I think it should be:
Support arrays in res.append()
.
Express Docs: https://expressjs.com/en/4x/api.html#res.append
Setup:
Error when executing deno sample script from https://deno.land/x/opine
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.
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
.
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;
}
}
Setup:
Add the res.redirect()
API
How to use session middleware?
Eggs CLI fails on Deno 1.6.0, see nestdotland/eggs#109
This issue to track upgrading the CI for Opine to publish to the nest.land registry again once the issue has been resolved (likely in a version 0.3.3)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.