0.0.15 • Published 8 months ago

@zipadee/core v0.0.15

Weekly downloads
-
License
MIT
Repository
github
Last release
8 months ago

@zipadee/core

A simple Node HTTP server with middleware.

!CAUTION Zipadee is very early, under construction, will change a lot, and may never be sufficiently maintained for any level of use. If you want to try it, please consider contributing!

Usage

import {App, html} from '@zipadee/core';

const app = new App();

app.use(async (req, res) => {
  res.body = html`<h1>Hello world!</h1>`;
});

app.listen();

Features

HTML Templates

Zipadee's html template tag offers a number of conveniences that may eliminate the need for a separate HTML template system like Liquid or Nunjucks:

  • Automatic escaping* of untrusted interpolated strings
  • Composition of nested templates
  • Support for arrays: Makes it easy to build lists without having to use arr.join(''), and supports streaming.
  • Pretty-ish-printing: Templates can be automatically dedented and nested templates re-indented when a nicer looking output is desired.
  • Asynchronous templates with treaming support: Zipadee streams each chunk of a template as its ready, and automatically waits for Primises in the stream.

    app.use(async (req, res) => {
      // Render the shell ASAP, render the body when data is loaded
      res.body = html`
        <html>
          <head>
            <script type="module" src="./app.js"></script>
            <link rel="stylesheet href="./app.css">
          </head>
          <body>
            ${renderBody(req)}
          </body>
        </html>
      `;
    });
    
    const renderBody = async (req) => {
      const data = await getData(req);
      return html` <h1>${data.title}</h1> `;
    };

*Zipadee's html tag does not yet perform contextual auto-escaping, which requires parsing the HTML templates, so it's still possible to create unsafe attribute values like javascript:....

0.0.15

8 months ago

0.0.14

10 months ago

0.0.12

10 months ago

0.0.13

10 months ago

0.0.11

11 months ago

0.0.10

11 months ago

0.0.9

11 months ago

0.0.8

11 months ago

0.0.7

11 months ago

0.0.6

11 months ago

0.0.5

11 months ago

0.0.4

11 months ago

0.0.3

11 months ago

0.0.2

11 months ago

0.0.1

11 months ago