Skip to content

A simple TypeScript-based Express server that runs the k-text-analyzer library

Notifications You must be signed in to change notification settings

kvss/k-text-analyzer-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Text Risk Analysis Server

This is a NodeJS server written in TypeScript that uses the k-text-analyzer NPM module for text analysis. This is designed to be a quick server to run to get started; the express server is NOT proxied behind any webserver and exposed bare. Therefore, it should

  • be behind a firewall and accessible on by the servers you want to use
  • used for testing and demonstrations as it lacks caching and compression

Although self-contained, the server is really a small wrapper around the library itself; therefore you must weigh whether or not it makes sense to separate the lookup analysis from your other services. There are pros and cons to either approach.

Installation

With Docker

A Dockerfile is available if you would rather just build a container and run it. To run it, you can do the following:

docker build -t ktas .

docker run -d -p 4001:4001 ktas

Without Docker

If you want to manually install it, you first must make sure you have NodeJS installed. All other dependencies should be self-contained.

Once the code is checked out, run

npm install

tsd install

Usage

Once running, the server only exposes a single endpoint that must be reached with a POST HTTP request:

POST /

The body of the request should be a x-www-form-urlencoded body with a "text" key, similar to:

text=sample

The return will have the following shape:

{
  score: number,
  input: the input string,
  warningGenerated: true if a warning was generated, false otherwise,
  warning: the warning message if there is one, false otherwise 
}

Testing

To test the code, manually install it and then run

npm run test

This will build the project and then use Mocha to test the generated Javascript

About

A simple TypeScript-based Express server that runs the k-text-analyzer library

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published