Texa (deno web framework)

Update 0.7.0

This is a rather cool update! Texa now has a built-in static files middleware to better serve your files! Not only does it serve static files, but it can serve ANY file type if you decide to add support for it. It also allows you to create vanity URLs by trying different extensions.

Static files.

// Imports
import { Static } from "https://deno.land/x/texa/mod.ts";

// Use the static middleware.
app.use(
	// The directory to serve from, relative from <CWD>.
	new Static("www")
);

Custom extension handlers.

app.use(
	new Static("www", {
		handlers: {
			ejs: async (pathname, req, res) => {
				// Compute compiledEJS somehow..
				return [ compiledEJS, "text/html" ];
			}
		}
	})
);

Index files.

app.use(
	new Static("www", {
		indexes: [ "index.html" ]
	})
);

Vanity URLs

You can add extensions to look for just like adding index files.

app.use(
	new Static("www", {
		vanityExtensions: [ "html" ]
	})
);

Other minor improvements

Here’s a list of other minor improvements:

  • Added response header method aliases in the response object.

    • <Response>.set(headerName, headerValue): Response

    • <Response>.get(headerName): Response

    • <Response>.has(headerName boolean

    • <Response>.delete(headerName Response

  • Added methods to quickly do things on the response object.

    • <Response>.type(mimeType): Response

    • <Response>.json(data: any): Promise<Response>

  • Made a new middleware object (SubMiddleware) that allows running more middleware. See (https://i.loli.net/2020/10/15/XmdlE3PnZ1rY5y4.png)

  • Router middleware now extends the SubMiddleware object.

3 Likes