deno-libs / tinyhttp Goto Github PK
View Code? Open in Web Editor NEW[IN DEVELOPMENT] ๐ฆ Deno port of tinyhttp, 0-legacy, tiny & fast web framework
Home Page: https://deno.land/x/tinyhttp
License: MIT License
[IN DEVELOPMENT] ๐ฆ Deno port of tinyhttp, 0-legacy, tiny & fast web framework
Home Page: https://deno.land/x/tinyhttp
License: MIT License
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)
This is to keep the framework in line with Deno's module expectations. That also makes the module more compatible with tools like trex
which expects that on installation!
I've been trying to move from legacy std/http but didn't manage to do it, so anyone else is welcome
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.
Add #resources
to the App class, update res.sendFile
and res.end
to work nicely together
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')
This is the issue to track progress of Express API implementation
app.locals
app.mountpath
app.all()
app.engine()
app.listen()
app.path()
app.render()
app.route()
app.set()
app.use()
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
req.accepts()
req.acceptsCharsets()
req.acceptsEncodings()
req.acceptsLanguages()
req.get()
req.is()
req.range()
res.app
res.locals
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()
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)
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.')
Hey @talentlessguy. I tried to install tinyhttp-deno, but got the following error:
โ payment-receiver deno run main.ts
Download https://deno.land/x/[email protected]/extensions/format.ts
Download https://deno.land/x/[email protected]/extensions/download.ts
error: Import 'https://deno.land/x/[email protected]/extensions/format.ts' failed: 404 Not Found
at https://deno.land/x/[email protected]/response.ts:6:0
Would you take a look?
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...
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.