Code Monkey home page Code Monkey logo

tinyhttp's People

Contributors

aarontravass avatar danyalasif 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

tinyhttp's Issues

`app.route` is not working properly

Reproduction:

import { App } from 'https://denopkg.com/deno-libs/tinyhttp@master/mod.ts'
import { makeFetch } from 'https://deno.land/x/[email protected]/mod.ts'

const app = new App()

app.route('/').get((req, res) => void res.end(req.url))

const res = await makeFetch(app.handler)('/')
res.expect(200)

Tool setup

  • Coverage (Coveralls)
  • CI (Actions)
  • Code quality (Codefactor)

Move to native Deno http

I've been trying to move from legacy std/http but didn't manage to do it, so anyone else is welcome

Examples

  • basic
  • eta
  • mongodb
  • postgresql
  • jwt
  • async
  • no-match-handler
  • graphql

Make `res.sendFile` work and use Deno resources API

Description

ATM res.sendFile doesn't work properly and causes tests to hang because it opens file but doesn't close them. In Opine, there's a private property for storing resources and end function closes them. tinyhttp should have something similar.

Task

Add #resources to the App class, update res.sendFile and res.end to work nicely together

multiple sub-apps cannot mount on the same root

import { App } from 'https://denopkg.com/deno-libs/tinyhttp@master/mod.ts'
import { makeFetch } from 'https://deno.land/x/[email protected]/mod.ts'

const app = new App()

const route1 = new App()
route1.get('/route1', (_req, res) => void res.end('route1'))

const route2 = new App()
route2.get('/route2', (_req, res) => void res.end('route2'))

app.use(route1)
app.use(route2)

const res1 = await makeFetch(app.handler)('/route1')
res1.expect('route1')

const res2 = await makeFetch(app.handler)('/route2')
res2.expect('route2')

Implementation

This is the issue to track progress of Express API implementation

App

Properties

  • app.locals
  • app.mountpath

Methods

  • app.all()
  • app.engine()
  • app.listen()
  • app.path()
  • app.render()
  • app.route()
  • app.set()
  • app.use()

Request

Properties

  • req.app
  • req.body
  • req.cookies
  • req.fresh
  • req.hostname
  • req.ip
  • req.ips
  • req.method
  • req.params
  • req.path
  • req.protocol
  • req.query
  • req.route
  • req.secure
  • req.signedCookies
  • req.stale
  • req.subdomains
  • req.xhr
  • req.originalUrl
  • req.is

Methods

  • req.accepts()
  • req.acceptsCharsets()
  • req.acceptsEncodings()
  • req.acceptsLanguages()
  • req.get()
  • req.is()
  • req.range()

Response

Properties

  • res.app
  • res.locals

Methods

  • res.append()
  • res.attachment()
  • res.cookie()
  • res.clearCookie()
  • res.download()
  • res.end()
  • res.format()
  • res.get()
  • res.json()
  • res.jsonp()
  • res.links()
  • res.location()
  • res.redirect()
  • res.render()
  • res.send()
  • res.sendFile()
  • res.sendStatus()
  • res.set()
  • res.status()
  • res.type()
  • res.vary()

Tests

  • App (port tests from original repo)
  • Request (port tests from original repo)
  • Response (port tests from original repo)

Bug: doesn't match wares containing base path

Reproduction:

import { makeFetch } from 'https://deno.land/x/[email protected]/mod.ts'

const app = new App()

app.use('/abc', (_req, res) => void res.end('Hello world'))
;(await makeFetch(app.handler)('/abc/def')).expectStatus(200).expectBody(
  'Hello world',
)
;(await makeFetch(app.handler)('/abcdef')).expect(404)

Subapp error handler is not respected

Reproduction:

import { App } from 'https://denopkg.com/deno-libs/tinyhttp@master/mod.ts'
import { makeFetch } from 'https://deno.land/x/[email protected]/mod.ts'

const app = new App({
  onError: (err, req) =>
  new Response(`Ouch, ${err} hurt me on ${req?.url} page.`, {
    status: 500,
  })
})

const subApp = new App({
  onError: (err, req) =>
  new Response(`Handling ${err} from child on ${req?.url} page.`, {
    status: 500,
  })
})

subApp.get('/route', async (req, res, next) => await next('you'))

app.use('/subapp', subApp)

const server = app.handler
const fetch = makeFetch(server)

const res = await fetch('/subapp/route')
res.expectStatus(500).expectBody('Handling you from child on /subapp/route page.')

Broken coverage uploads

Deno coverage randomly drops on different levels and now it just dropped to 0% for no apparent reason

this should be fixed ASAP

...if I only knew how...

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.