File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -43,7 +43,9 @@ yarn add @tinyhttp/app
4343
4444You can see the documentation [ here] ( https://tinyhttp.v1rtl.site/docs ) .
4545
46- ## Example
46+ ## Get Started
47+
48+ The app structure is quite similar to Express, except that you need to import ` App ` from ` @tinyhttp/app ` instead of default import from ` express ` .
4749
4850``` ts
4951import { App } from ' @tinyhttp/app'
Original file line number Diff line number Diff line change 11import { App } from '@tinyhttp/app'
2- import staticFolder from '@tinyhttp/static'
2+ import { staticHandler } from '@tinyhttp/static'
33import logger from '@tinyhttp/logger'
44
55const app = new App ( )
1616 ` )
1717 } )
1818 . use ( logger ( ) )
19- . use ( staticFolder ( ) )
19+ . use ( staticHandler ( './' ) )
2020 . listen ( 3000 )
Original file line number Diff line number Diff line change 11{
22 "name" : " @tinyhttp/static" ,
3- "version" : " 0.1.26 " ,
3+ "version" : " 0.1.27 " ,
44 "description" : " tinyhttp static middleware" ,
55 "main" : " dist/index.js" ,
66 "types" : " dist/index.d.ts" ,
Original file line number Diff line number Diff line change @@ -13,13 +13,13 @@ export type StaticHandlerOptions = Partial<{
1313 recursive : boolean
1414} >
1515
16- export const staticHandler = (
17- dir = process . cwd ( ) ,
18- { prefix = '/' , recursive = false } : StaticHandlerOptions
19- ) : AsyncHandler => {
16+ export const staticHandler = ( dir = process . cwd ( ) , opts ?: StaticHandlerOptions ) : AsyncHandler => {
2017 return async ( req : Request , res : Response , next ?: NextFunction ) => {
2118 let files : string [ ]
2219
20+ const prefix = opts . prefix || '/'
21+ const recursive = opts . recursive || false
22+
2323 if ( recursive ) {
2424 files = (
2525 await recursiveReaddir ( dir , {
You can’t perform that action at this time.
0 commit comments