Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

esi-server

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

esi-server

Edge Side Includes (ESI) fragments server

  • 1.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

node-esi-server

Edge Side Includes (ESI) html fragment http server

This node server aims at rendering templates with provided data using a template provider and a data provider.

Supported template providers:

  • nunjucks

Supported data providers:

Install

npm install --save esi-server

Usage

Using the nunjucks template provider and koa-router data provider

const TemplateProvider = require("esi-server-template-nunjucks"),
    {Server} = require("esi-server"),
    templateProvider = new TemplateProvider(),
    DataProvider = require("esi-server-data-koa-router")
    dataProvider = new DataProvider(),
    router = dataProvider.getRouter();
router.get("/articles/:id", ctx => {
    return new Promise(resolve => {
        resolve(Object.assign(
            {
                title: "My article",
                body: "My body"
            },
            {id: ctx.params.id}
        ));
    });
});
app = new Server({
    templateProvider: templateProvider,
    dataProvider: dataProvider
});
// Listen request from port 3000 TCP port
app.listen(3000);

Sample queries

Each query must have a JSON string object with two properties :

  • data property is used as arguments of data provider get function
  • tpl property is used as arguments of template provider get function
GET /fragment?{"data":["/articles/1"],"tpl":["article.html",{"titleTag":"h1"}]}
GET /fragment?{"data":["/articles",{"order":"publishedAt","limit":10}],"tpl":["articles.html",{"title":"Last published articles"}]}
GET /fragment?{"tpl":["header.html",{"title":"Last published articles"}]}

FAQs

Package last updated on 17 Dec 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc