tappin logo - word 'tappin' with a period surrounded by black border
  1. Introduction
    1. Welcome
    2. Basics
    3. Factory
    4. Philosophy
  2. Reflection
    1. Overview
    2. Dynamic loading
  3. HTTP
    1. Overview
    2. Server
    3. Middlewares

Setting-up server

HTTP module

As said many times before, Tappin itself is pretty minimal. Due to that constraint, HTTP server is a seperate module. It is exported under httpModule from http package.

Starting a server

All you have to do is to import httpModule and add a service, which uses httpOptionsServiceTemplate template.

For providing options, HTTP service exports two helpers: httpStaticOptions(accepts raw HTTP object, useful when you have static configuration) and httpDynamicOptions(accepts a function, which accepts a DynamicService(see reflection for details) and returns a config). You can also create your own service, which uses httpOptionsServiceTemplate.

const appModule = createModule((dsl) =>
  dsl
    .service(httpStaticOptions({ port: 8080 }))
    .import(httpModule)
);

Why is it so fast?

In short - Tappin's HTTP server implementation aggresively caches:

  • URL objects
  • Middleware chains for specific pathnames

After each request, Tappin's HTTP server caches URL object for the pathname and middleware chain for specific path.