Socket
Socket
Sign inDemoInstall

@ifaxity/koa-json

Package Overview
Dependencies
41
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @ifaxity/koa-json

@ifaxity/koa-json ===================


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

Readme

Source

@ifaxity/koa-json

A minimal koa@2 pug/html render engine

Minimal dependencies & code is cut down to not take so much space. Because node_modules hell is something i want to avoid. This module was for private purposes but making it public wont do any harm.

Code heavily based on the koa-views package


Installation:

npm install @ifaxity/koa-json --save

or if you use yarn

yarn add @ifaxity/koa-json


Usage

To use the module just require it like this

const jwt = require('@ifaxity/koa-json');

And then you need to add it to your koa server like this:

const render = require('@ifaxity/koa-json');

// or whatever folder you use for your views
app.use(render(__dirname + '/views'), {
  ext: 'pug',
  globals: {
    title: 'Default title',
  }
});


// Example route
app.use(async ctx => {
  // Render state object
  ctx.state = {
    title: 'Index page title',
  };

  await ctx.render('index', {
    foo: 'bar',
  });
});

// You can also switch between .pug and .html files like this
// As the option 'ext' only specifies the default extension
app.use(async ctx => {
  await ctx.render('index.html');
});

FAQs

Last updated on 19 Sep 2019

Did you know?

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc