Coder Social home page Coder Social logo

denotrain's People

Contributors

0xflotus avatar caesar2011 avatar diegoquiroz avatar freakyfelt avatar kanziw avatar lispy avatar omaralmgerbie 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

denotrain's Issues

Circular reference between Response and Context

After testing around for a bit I have found that there exists a circular reference between the response and context classes. I was wondering if this is a critical issue or just the way it should be.

Allow for more valid characters in req.param templates

Routes created using a path template only allow for alphanumeric characters[1], which excludes many common values, such as kebab-case-slugs, snake_case_slugs, and ~user directories.

I think this is a decent list of valid values, but given the pathname comes from URL you might be able to get away with just looking for anything that's not a path separator (e.g. /).

new RegExp('[A-z0-9.\-_~!$&\'()*+,;=:@]+') [3]

Another option would be to use pathToRegexp[2], which is what Express uses under the covers:

[1]

.replace(/\/:([a-z]+)/gi, "/([0-9a-zA-Z]+)");

[2] https://raw.githubusercontent.com/pillarjs/path-to-regexp/v6.1.0/src/index.ts
[3] https://stackoverflow.com/questions/4669692/valid-characters-for-directory-part-of-a-url-for-short-links

POST method not working.

Hello Guys, nice work you all did !.

I have a question about the POST request:

here's my script

import { Application, Router } from "./deps.ts";

const app = new Application({ port: 3001 });

app.get("/", (ctx) => {
  return { "hello": "world" };
});

app.post("/cadastrar", async (ctx) => {
  console.log(ctx.req);
  return ctx.req.body;
});

await app.run();

Screen Shot 2020-05-15 at 18 52 56

Postman

image

Capture all requests after a certain path

Hello!

I was wondering if it was possible to allow a handler to catch all requests for a certain path. For example, if we have

app.get("/:id/:thing", (ctx: ext.dt.Context) => {
  // do whatever here
}); 

would it be possible for both /1/a and /1/a/b to be handled?

Cannot run example script on latest version of deno

Running the example script has this result:

Compile https://deno.land/x/[email protected]/mod.ts
error: Uncaught TypeError: Cannot resolve extension for "https://raw.githubusercontent.com/jshttp/mime-db/master/db.json" with mediaType "Json".
    at getExtension ($deno$/compiler.ts:218:13)
    at new SourceFile ($deno$/compiler.ts:263:22)
    at Function.addToCache ($deno$/compiler.ts:339:16)
    at processImports ($deno$/compiler.ts:743:31)
    at async processImports ($deno$/compiler.ts:753:7)
    at async processImports ($deno$/compiler.ts:753:7)
    at async processImports ($deno$/compiler.ts:753:7)
    at async processImports ($deno$/compiler.ts:753:7)
    at async processImports ($deno$/compiler.ts:753:7)
    at async compile ($deno$/compiler.ts:1316:31)

Initially ran it inside a ts file and so added any types. I tried running this as a js file as well.
Very unfamiliar with deno, sorry if this is a deno issue and not a denotrain issue.

EDIT: Running on WSL1

Respond with HTML

I couldn't find a way to respond with HTML, but I saw you're working on it in Response.

Just to document:

app.get("/", async (ctx) => {
  return "<h1>Hello world</h1>"; 
});

Screen Shot 2020-05-15 at 6 59 22 PM

readme example doesn't run correctly on windows

PS C:\Users\mark\Documents\PROJECTS\deno-test> deno --version
deno 1.0.0
v8 8.4.300
typescript 3.9.2
PS C:\Users\mark\Documents\PROJECTS\deno-test> deno run --allow-net=127.0.0.1 https://deno.land/x/[email protected]/example/routers/example.ts
Download https://deno.land/x/[email protected]/example/routers/example.ts
Compile https://deno.land/x/[email protected]/example/routers/example.ts
error: Uncaught PermissionDenied: network access to "0.0.0.0:3001", run again with the --allow-net flag
    at unwrapResponse ($deno$/ops/dispatch_json.ts:43:11)
    at Object.sendSync ($deno$/ops/dispatch_json.ts:72:10)
    at Object.listen ($deno$/ops/net.ts:51:10)
    at listen ($deno$/net.ts:152:22)
    at serve (https://deno.land/[email protected]/http/server.ts:261:20)
    at Application.run (https://deno.land/x/[email protected]/Application.ts:29:15)
    at https://deno.land/x/[email protected]/example/routers/example.ts:41:11

Just setting appRoot folder not working

I am trying to set a document root using following. For some reason, it's not working. Any idea if anything being done wrong here?

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

// Create a new application (port defualts to 3000, hostname to 0.0.0.0)
const app = new Application({
  port: 80,
  appRoot: "./site/",
// appRoot: "site/",
// appRoot: "site",
});

await app.run();

Parsing int64 params

When I using path parameters from router with an int64 value, the automated parser return an incorrect value.
Eg: /:userId --> /394518333870964737
Expect: { userId: 394518333870964737 }
Actual: { userId: 394518333870964740 }

I think you should add a new param like "options: object" to define more option (Eg: { parse: false } to prevent automated parser).

Doesn't run in [email protected]

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/x/[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/x/[email protected]/path/posix.ts:433: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: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 4 errors.

URL Broken "View documentation on the official documentation website."

Trivial, but I was interested in reading the official site.

What I found
Url to official documentation site is broken.

What I expect
When I click the "View documentation on the Denotrain page [official documentation website](https://doc.deno.land/https/deno.land/x/denotrain@master/mod.ts)." link located at https://github.com/Caesar2011/denotrain it should let see the official documentation website.

Reproduction
Click url as shown at bottom of page.

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.