<commit_before># Logux Server

<img align="right" width="95" height="95" title="Logux logo"
     src="https://cdn.rawgit.com/logux/logux/master/logo.svg">

Logux is a client-server communication protocol. It synchronizes events
between clients and server logs.

This framework helps you to write Logux server and define back-end callbacks
for each client’s event type.

This is a first **proof-of-concept** version. It simply synchronizes all the events between
clients, not yet having many syntax sugar that we've planned for future.

<a href="https://evilmartians.com/?utm_source=logux-server">
  <img src="https://evilmartians.com/badges/sponsored-by-evil-martians.svg"
       alt="Sponsored by Evil Martians" width="236" height="54">
</a>


## Getting Started


### Installation

Install [Node.js](https://nodejs.org/en/download/).

Create new Node.js project:

```sh
mkdir PROJECT_NAME
cd PROJECT_NAME
npm init
```

Install Logux Server:

```sh
npm install --save logux-server logux-core
```


### Create Main File

Create `server.js` with this boilerplate:

```js
const cleanEvery = require('logux-core').cleanEvery
const Server = require('logux-server').Server

const app = new Server({
  subprotocol: '1.0.0',
  supports: '1.x',
  root: __dirname
})

app.auth(token => {
  // TODO Return user by token or false on bad token.
})

app.log.on('event', (event, meta) => {
  // TODO Do something on client event. Write to database, ask other service.
})

cleanEvery(app.log, 1000)
app.log.keep((event, meta) => {
  // TODO return true if event should not be removed yet from log<commit_msg>#9 add doc about auth callback (#10)<commit_after># Logux Server

<img align="right" width="95" height="95" title="Logux logo"
     src="https://cdn.rawgit.com/logux/logux/master/logo.svg">

Logux is a client-server communication protocol. It synchronizes events
between clients and server logs.

This framework helps you to write Logux server and define back-end callbacks
for each client’s event type.

This is a first **proof-of-concept** version. It simply synchronizes all the events between
clients, not yet having many syntax sugar that we've planned for future.

<a href="https://evilmartians.com/?utm_source=logux-server">
  <img src="https://evilmartians.com/badges/sponsored-by-evil-martians.svg"
       alt="Sponsored by Evil Martians" width="236" height="54">
</a>


## Getting Started


### Installation

Install [Node.js](https://nodejs.org/en/download/).

Create new Node.js project:

```sh
mkdir PROJECT_NAME
cd PROJECT_NAME
npm init
```

Install Logux Server:

```sh
npm install --save logux-server logux-core
```


### Create Main File

Create `server.js` with this boilerplate:

```js
const cleanEvery = require('logux-core').cleanEvery
const Server = require('logux-server').Server

const app = new Server({
  subprotocol: '1.0.0',
  supports: '1.x',
  root: __dirname
})

app.auth(token => {
  // TODO Return user by token or false on bad token. It should be Promise.
})

app.log.on('event', (event, meta) => {
  // TODO Do something on client event. Write to database, ask other service.
})

cleanEvery(app.log, 1000)
app.log.keep((event, meta) => {
  // TODO return true if event should not be removed yet from log
{'fraction_non_alphanumeric': 0.1309192200557103, 'fraction_numerical': 0.01145156298359641, 'mean_word_length': 4.196141479099678, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 17, 'https://': 8, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3033625', 'n_tokens_mistral': 1081, 'n_tokens_neox': 1015, 'n_words': 347}