npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

tonto

v0.1.1

Published

Tonto.js: Apache Config File Generator

Downloads

7

Readme

 _____ ___  _  _ _____ ___
|_   _/ _ \| \| |_   _/ _ \
  | || (_) | .` | | || (_) |
  |_| \___/|_|\_| |_| \___/.JS
 APACHE CONFIG FILE GENERATOR

NPM version Build Status Coverage Status Code Climate

Dependency Status Dev Dependency Status

Tonto.js

This library helps with automating the generation of Apache web server configuration files. It provides a native camelCased javascript function API which support all native (and native mod) configuration directives from Apache versions 2.4, 2.2, and 2.0:

Additionally, Tonto is easily configured at instantiation to support any custom directive that you may have, (such as 3rd-party mod directives like 'PassengerRoot').

The Name "Tonto"

This library is named after the Tonto (Dilzhę́’é) people, who are one of the Western Apache groups in North America.

Long ago, their enemies called them "foolish", "wild", "crazy", and "those who you don't understand" for speaking and doing things differently than their neighbors. Today, they are known throughout the art communities for their superior fine crafts.

Installation

Use NPM to install the tonto package into your node.js project:

$ npm install tonto --save

Getting Started

1. Each instance of Tonto is a version-specific apache config document object that you add directives to by calling it's directive functions:

var tonto = new Tonto('2.4');

2. There are solo directive functions that take a single value argument, and block directive functions which take a sub-directive setter object as the second argument:

tonto.serverName('somesite.com');
tonto.virtualHost('*:80', function (subDirectiveDocument) {
  // Here, you can call any directive function directly on subDirectiveDocument, and it will be added as a sub-directive.
  subDirectiveDocument.serverName('somesite.com');
});

3. When the document object has all directives added to it, you can render the document to string by calling:

tonto.render();

4. All directives are chainable:

var renderedDocument = tonto
  .loadModule('some_module /some/path/to/module.so')
  .serverSignature('Off')
  .traceEnable('Off')
  .render();

Directive Functions

Specifying an Apache Version

Tonto.js comes with built-in support for all native (and native mod) directives in versions 2.4, 2.2, and 2.0. Additionally, you can specify any number of extra directives.

You specify which version you want to use during instantiation of the constructor:

var twoFour = Tonto('2.4');
Object.keys(twoFour).length; // 594

var twoTwo = Tonto('2.2');
Object.keys(twoTwo).length; // 419

var twoZero = Tonto('2.0');
Object.keys(twoZero).length; // 364

Directive/Function Case Differences

Whereas Apache directives are typed in TitleCase, tonto converts each of the directives into camelBackCase named functions.

For example:

  • LoadModule is added to the document with: .loadModule('some_module /some/path/to/module.so')
  • SSLCertificateKeyFile is added to the document with: .sslCertificateKeyFile('/some/path/to/some_key.pem')
  • VirtualHost is added to the document with: .virtualHost('*:80', subDirectiveSetter)

Sub-Directive Setter

Block directives require a function as the second argument. This function has one argument itself, which is a clean sub-document. You can call any directive from the main document on a sub-document.

Here is an example of a sub-directive setter defined as a named function:

tonto.virtualHost('*:80', subDirectiveSetter);

function subDirectiveSetter(subDirectives) {
  subDirectives.serverName('somesite.com');
}

This example will render:

<VirtualHost *:80>
  ServerName somesite.com
</VirtualHost>

Defining Custom Directives

If you are using a 3rd party mod that provides custom directives, there is an easy way to extend tonto.js with custom functions for this purpose:

tonto.extend([
  'CustomDirective',
  '<CustomBlock>'
]);

tonto.customDirective('some value'); // Solo directive

tonto.customBlock('some value', function (subDirectives) {
  // Because CustomBlock is surrounded in < and >, it is processed as a block directive
});