Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

alpine-ts

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

alpine-ts - npm Package Compare versions

Comparing version 0.3.0 to 0.3.1

19

package.json
{
"name": "alpine-ts",
"version": "0.3.0",
"version": "0.3.1",
"description": "Alpine - the Apache Log Parser in Typescript",

@@ -12,4 +12,3 @@ "main": "src/index.js",

"byline": "^5.0.0",
"through2": "^0.6.2",
"underscore.string": "^3.3.5"
"through2": "^4.0.2"
},

@@ -20,4 +19,3 @@ "devDependencies": {

"@types/through2": "^2.0.36",
"@types/underscore.string": "^0.0.38",
"mocha": "^8.2.1",
"mocha": "^8.3.0",
"nyc": "^15.1.0",

@@ -36,3 +34,3 @@ "rimraf": "^3.0.2",

"type": "git",
"url": "https://github.com/blarsen/node-alpine.git"
"url": "https://github.com/UrielCh/node-alpine-ts.git"
},

@@ -48,3 +46,4 @@ "keywords": [

"author": "uriel chemouni <uchemouni@gmail.com>",
"contributors": [{
"contributors": [
{
"name": "Bjørn Hell Larsen",

@@ -61,5 +60,5 @@ "email": "blarsen@nonews.net"

"bugs": {
"url": "https://github.com/UrielCh/node-alpine/issues"
"url": "https://github.com/UrielCh/node-alpine-ts/issues"
},
"homepage": "https://github.com/UrielCh/node-alpine",
"homepage": "https://github.com/UrielCh/node-alpine-ts",
"files": [

@@ -69,2 +68,2 @@ "src/*.js",

]
}
}
# Alpine
`alpine2` is a fork of `alpine`, this version is writen in Typescript, and so contains de full typing.
`alpine-ts` is a fork of `alpine`, this version is writen in Typescript, so contains a full typing.
`alpine2` is a parser for Apache mod_log log files. It supports the three most common log formats (the Common Log Format,
`alpine-ts` is a parser for Apache mod_log log files. It supports the three most common log formats (the Common Log Format,
the Common Log Format with a vhost field and the Combined log format)

@@ -28,5 +28,6 @@ and also allows you to specify custom log formats by passing it the LogFormat string used to generate the log file you want parsed.

```typescript
import Alpine from 'alpine';
const alpine = new Alpine("%h %s %B");
const data = alpine.parseLine("www.brain-salad.com 403 4321");
import Alpine, {AlpineLine} from 'alpine';
const alpine: Alpine = new Alpine("%h %s %B");
const data: AlpineLine = alpine.parseLine("www.brain-salad.com 403 4321");
console.log(data);

@@ -50,10 +51,22 @@ ```

import fs from 'fs';
import Alpine from 'alpine';
import Alpine, {AlpineLine} from 'alpine';
const alpine = new Alpine();
alpine.parseReadStream(fs.createReadStream('access_log', {encoding: "utf8"}),
function(data) {
console.log("Status: " + data.status + ", request: " + data.request);
function(data: AlpineLine) {
console.log(`Status: ${data.status}, request: ${data.request}`);
});
```
### Change from the legacy `alpine`
- Parameterized filed like `AlpineLine['RequestHeader header']` are now avalable in `AlpineLine.RequestHeader['header']`
- AlpineLine contains some helper like:
- AlpineLine.url return the log line as a request (patial if not all data are available in the log format)
- AlpineLine.method return 'GET'/'POST'/'PUT' ...
- AlpineLine.pathname return the requested path
- AlpineLine.extension return the file extention from the requested path like (.js, .css, .html ....)
- AlpineLine.getQuery('name') return a query parameter value
- AlpineLine.getQueryAll('name') return a query parameter value in a string[]
### Use streams

@@ -60,0 +73,0 @@

@@ -16,3 +16,2 @@ /**

const byline_1 = __importDefault(require("byline"));
const underscore_string_1 = __importDefault(require("underscore.string"));
const through2_1 = __importDefault(require("through2"));

@@ -152,7 +151,11 @@ const fields_1 = require("./fields");

function stripQuotes(text) {
if ((underscore_string_1.default.startsWith(text, '"') && underscore_string_1.default.endsWith(text, '"')) ||
(underscore_string_1.default.startsWith(text, "[") && underscore_string_1.default.endsWith(text, "]")))
return text.substr(1, text.length - 2);
const length = text.length;
if (length <= 2)
return text;
const c1 = text[0];
const c2 = text[length - 1];
if ((c1 === '"' && c2 === '"') || (c1 === '[' && c2 === ']'))
return text.substr(1, length - 2);
return text;
}
//# sourceMappingURL=alpine.js.map
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc