A Srvem middleware used to serve static files from a specified directory.
npm install --save @srvem/app @srvem/static
import { Srvem } from '@srvem/app'
import { SrvStatic } from '@srvem/static'
// create a Srvem app
const app: Srvem = new Srvem()
// use SrvStatic middleware
app.use(new SrvStatic('public')) // host the /public directory
// listen on port 3000
app.server.listen(3000)
import { Context, MiddlewareBlueprint } from '@srvem/app'
/**
* Used to serve static files from a directory.
*/
declare class SrvStatic extends MiddlewareBlueprint {
/**
* Root of the served directory.
*/
baseDirectory: string
/**
* Default index file name for directory requests
*/
indexName: string
/**
* Constructs the SrvStatic middleware.
*
* @param baseDirectory Root of the served directory
* @param indexName Default index file name for directory requests
*/
constructor(baseDirectory?: string, indexName?: string)
/**
* Attempts to serve GET requests.
*
* @param ctx The Context
*/
main(ctx: Context): Promise<void>
}
- @srvem/app - The core package of Srvem (contains a class used to construct a Srvem app).
- @srvem/router - A Srvem middleware used to develop routers and server APIs with asynchronous request handlers.
Kaleab S. Melkie <[email protected]>
MIT License
Copyright © 2017 srvem
Made with ❤ in Addis Ababa.