<commit_before># Rosid

Just-in-time development server and static site exporter written in [Node.js](https://nodejs.org/). Rosid invokes functions before serving files to the browser. This allows you to pre-process anything on-the-fly, without saving it.

## Contents

- [Description](#description)
	- [What is Rosid?](#what-is-rosid)
	- [Why Rosid?](#why-rosid)
	- [How does it work?](#how-does-it-work)
- [Requirements](#requirements)
- [Setup](#setup)
- [Routes](#routes)
	- [Name](#name)
	- [Path](#path)
	- [Handler](#handler)
	- [Args](#args)
- [Handlers](#handlers)
- [Execute](#execute)
	- [Initialize](#initialize)
	- [Serve](#serve)
	- [Compile](#compile)
- [Options](#options)

## Description

### What is Rosid?

Rosid is a framework that focus on two features:

1. A **development server with live-reloading**, which transforms files as soon as you request them.
2. A **static site generator**, which transforms files using defined transform-functions.

### Why Rosid?

- It doesn't force you to use a defined directory structure
- It's build on popular modules like [Browsersync](https://www.browsersync.io)
- It integrates nicely with tools you are are already using to transform your files (e.g. [Gulp](http://gulpjs.com), [Grunt](http://gruntjs.com) or Vanilla JS)
- It's lightweight and only includes what it really needs
- Transformed files don't need to be saved along their source files
- It lets you compile code to static files to host them anywhere

### How does it work?

Rosid starts a server and compares requested URLs with user-defined patterns. A associated file handler will be executed when a pattern matches. The handler receives information about the request and can transform the file, which will be send to the browser.

## Requirements

Rosid dependents on...

- [Node.js](https://nodejs.org/en/)
- [npm](https://www.npmjs.com)

Make sure to install and update all dependencies before you setup Rosid.

## Setup

Install Rosid using [npm](https://npmjs.com).

```sh
npm install rosid
```

Create a new JS-file and add insert the following code:

```js
'use strict'

/*
 * Your file-handlers.
 */
const transfromJS = (...) => {...}
const transfromSASS = (...) => {...}

/*
 * Rosid compares all requested URLs with the following patterns.
 * The associated file-handler will be executed when a pattern matches.
 */
const routes = [{...}, {...}]

/*
 * Require and initialize Rosid.
 */
let Rosid = require('rosid')(routes)
```

Both the file-handlers and routes are placeholders and Rosid hasn't been executed, yet. Read more about [routes](#routes), [handlers](#handlers) and how to [execute](#execute) Rosid to get started.

## Routes

The route-configuration is an array of objects. Each object must contain a path and a file handler.

```js
const routes = [{
		name    : 'JS',
		path    : 'assets/scripts/**/*.js',
		handler : transfromJS
	},
	{
		name    : 'SCSS',<commit_msg>Update Routes description to include "name"<commit_after># Rosid

Just-in-time development server and static site exporter written in [Node.js](https://nodejs.org/). Rosid invokes functions before serving files to the browser. This allows you to pre-process anything on-the-fly, without saving it.

## Contents

- [Description](#description)
	- [What is Rosid?](#what-is-rosid)
	- [Why Rosid?](#why-rosid)
	- [How does it work?](#how-does-it-work)
- [Requirements](#requirements)
- [Setup](#setup)
- [Routes](#routes)
	- [Name](#name)
	- [Path](#path)
	- [Handler](#handler)
	- [Args](#args)
- [Handlers](#handlers)
- [Execute](#execute)
	- [Initialize](#initialize)
	- [Serve](#serve)
	- [Compile](#compile)
- [Options](#options)

## Description

### What is Rosid?

Rosid is a framework that focus on two features:

1. A **development server with live-reloading**, which transforms files as soon as you request them.
2. A **static site generator**, which transforms files using defined transform-functions.

### Why Rosid?

- It doesn't force you to use a defined directory structure
- It's build on popular modules like [Browsersync](https://www.browsersync.io)
- It integrates nicely with tools you are are already using to transform your files (e.g. [Gulp](http://gulpjs.com), [Grunt](http://gruntjs.com) or Vanilla JS)
- It's lightweight and only includes what it really needs
- Transformed files don't need to be saved along their source files
- It lets you compile code to static files to host them anywhere

### How does it work?

Rosid starts a server and compares requested URLs with user-defined patterns. A associated file handler will be executed when a pattern matches. The handler receives information about the request and can transform the file, which will be send to the browser.

## Requirements

Rosid dependents on...

- [Node.js](https://nodejs.org/en/)
- [npm](https://www.npmjs.com)

Make sure to install and update all dependencies before you setup Rosid.

## Setup

Install Rosid using [npm](https://npmjs.com).

```sh
npm install rosid
```

Create a new JS-file and add insert the following code:

```js
'use strict'

/*
 * Your file-handlers.
 */
const transfromJS = (...) => {...}
const transfromSASS = (...) => {...}

/*
 * Rosid compares all requested URLs with the following patterns.
 * The associated file-handler will be executed when a pattern matches.
 */
const routes = [{...}, {...}]

/*
 * Require and initialize Rosid.
 */
let Rosid = require('rosid')(routes)
```

Both the file-handlers and routes are placeholders and Rosid hasn't been executed, yet. Read more about [routes](#routes), [handlers](#handlers) and how to [execute](#execute) Rosid to get started.

## Routes

The route-configuration is an array of objects. Each object must contain a name, path and handler.

```js
const routes = [{
		name    : 'JS',
		path    : 'assets/scripts/**/*.js',
		handler : transfromJS
	},
	{
		name    : 'SCSS',
{'fraction_non_alphanumeric': 0.13384484228473997, 'fraction_numerical': 0.0006820119352088661, 'mean_word_length': 3.941870261162595, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 10, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '438898', 'n_tokens_mistral': 1831, 'n_tokens_neox': 1724, 'n_words': 681}