Socket
Socket
Sign inDemoInstall

freon

Package Overview
Dependencies
1
Maintainers
1
Versions
31
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    freon

Fast server-side web framework


Version published
Weekly downloads
31
increased by933.33%
Maintainers
1
Install size
114 kB
Created
Weekly downloads
 

Readme

Source

freon

Fast server-side web framework

freon on NPM

Build Status freon's Total Downloads on NPM freon's Version on NPM bitHound Overall Score bitHound Code Dependencies Dev Dependencies Known Vulnerabilities freon's License freon's Stars on GitHub

Example

const Freon = require('freon');
const app = new Freon.Application(['example.com', /.+\.example\.com/]);
app.onGet(/\/.+\.html/, (req, res) => {
  // Server code..
});

API

const Freon = require('freon');

Freon.Application

See the Application docs

Plugins

Plugins are trivial to create for freon. For example, a plugin that injects a property foo into the request object and sets it to 'bar':

// fooBarPlugin.js

module.exports = (req, res, next) => {
  req.foo = 'bar';
  next();
}

Note that it is vital to call next() when the plugin is finished loading. If any plugin does not call next(), then the server will halt when it is requested, waiting for that plugin to load, which it never will.

To load this plugin:

// server.js

const app = new Freon.application(['example.com']);
app.plugin(require('./fooBarPlugin.js'));

static

Use Freon.static to serve a static folder. It will be compressed using gzip and deflate, send the Last-Modified header, and send 304 status codes without a body when possible. If the file is not found in the directory, it will then pass on the request to the next handlers.

const app = new Freon.application(['example.com']);
app.plugin(Freon.static('someRandomDir/theDirToServeWebFilesFrom'));

Other useful plugins

You may find these plugins useful:

Freon will overwrite the request and response object. See the properties and methods that are added:

Request Object

Response Object

Keywords

FAQs

Last updated on 26 May 2018

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc