Skip to content

v2.2: New (old) view engine

Compare
Choose a tag to compare
@talentlessguy talentlessguy released this 28 Sep 22:38
· 19 commits to master since this release

v.2.2

Features

new View engine

by @talentlessguy in #401

View engine was ported from express for cases like multiple view engines and custom View processing. See docs for more info.

App doesn't require a first argument as engine options in a generic anymore. Instead pass engine options to app.engine and res.render.

Example:

import { App } from '@tinyhttp/app'
import { renderFile, type EtaConfig } from 'eta'
import type { PartialConfig } from 'eta/dist/types/config'

const app = new App()

app.engine('eta', eta.renderFile)

app.use((_, res) => void res.render<PartialConfig>('index.eta', { name: 'Eta' }))

app.listen(3000, () => console.log(`Listening on http://localhost:3000`))

new type: AppConstructor

A constructor type for @tinyhttp/app has been moved into a type for more convenience:

import type { AppConstructor } from '@tinyhttp/app'

new App method: app.disabled

Returns if a setting is disabled:

app.disabled('networkExtensions') // true

Bug Fixes

Improvements

  • Cut down total deps of @tinyhttp/app from 25 to 23.
  • Install size of @tinyhttp/app decreased from 692KB to 540KB (22% smaller) by switching from es-mime-types to mime@beta
  • app.set, app.enable and app.disable now have stricter types
  • app.engine supports extensions with and without a dot
  • app.render, res.render and app.engine support passing template engine options as a generic
  • a few es- modules owned by @talentlessguy are moved to the tinyhttp organization to avoid lock-in and make it easier to maintain

New examples

Full Changelog: https://github.com/tinyhttp/tinyhttp/compare/@tinyhttp/app@2.1.4...@tinyhttp/app@2.2.0