Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: upgrade deps and update node #7

Merged
merged 6 commits into from
Jul 27, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
node_modules

# Logs
logs
*.log
npm-debug.log*

# Dependency directory
node_modules

# Optional npm cache directory
.npm

# Optional REPL history
.node_repl_history

# Typescript stuff
typings
build
docs
coverage

package-lock.json
35 changes: 9 additions & 26 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,22 +1,8 @@
build
typings

# Logs
logs
*.log
npm-debug.log*

# Runtime data
pids
*.pid
*.seed

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# Dependency directory
node_modules

Expand All @@ -26,21 +12,18 @@ node_modules
# Optional REPL history
.node_repl_history


# Typescript stuff
typings
build
docs
coverage
build/
coverage/
config/
tsconfig.json
tslint.json

# Files
# Typescript files (but not the definitions)
*.ts
!*.d.ts
*.js.map
*.spec.js
*.spec.ts
*.spec.d.ts
*.spec.js.map

.travis.yml
.testdata
# Testfiles
jest.json
test/
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package-lock=false
17 changes: 1 addition & 16 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,6 @@
language: node_js
node_js:
- '8'
- '6'
- '5'
- '4.2'

script: npm run citest
after_script: npm install coveralls@^2.11.9 && cat ./coverage/lcov.info | coveralls

before_deploy:
- npm run bootstrap
- tsc --outDir .

deploy:
provider: npm
email: christoph.buehler@bluewin.ch
api_key:
secure: rZpdXuZORp8oQWogOXlRJjBPSwPJxxHXYoJY/2iqw/0OAVB65UPKEPX7+F2u33KrodWSR/vf/D4AUFnbJaGzLEecQnCJjIcvaFOhsbmoZxVWM2LWuboH2CfKhxVrcN2c4LBmlo+sItuVarqqvbGakb9BmkwWEsD4VSU6mjoBJ9QQfdDyyXCB64sPLabbd9apah096lOb4KXqxcs0A4GMYVR54MuEf/+nhEiw34pqMJrwI2CHPD2Z0FujHFNj8cT7c4ZbyqvMQY/uoQzbOyeJMUfQ579jVhUEDC/gs2O/OZGbjSwU91t9Pm+keFCWYzUakOaNz1JM5y8zgSQH3n26iCmp+nFPxP0rioIAnI0QL04JgXxnZHOgVo0R+Oz+/B1vCPqnr6C5G2V+flQCht5BDHtCne5Q+roiMaRL7nmrxeHd3qlQ53l7RewKu+qgllVYiyWRUmVFmcs84NwmcYJQauwObkaKOrEvOSi77taqQDD9WKIEY0F156+1gAdzKFl1oLyMCbLDy/MmLrOejCCl88HH/+JD44hDBlgM/SpcENci5MjP24V0WXYJDkhcgFjDCBO+uc4seZYvrg0kMLRhg5hSxTIT93zHZNvrRkAw1TD73tV/tafXrO588ZI+/eJBIcTCc2kRg2FuDnrsspEBO66obsmpAeuf49dipD4oGTg=
on:
tags: true
repo: smartive/proc-that-rest-extractor
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]

### Changed
- Update node to v6/v8 and upgrade modules

## [v0.5.0]
### Added
Expand Down
29 changes: 29 additions & 0 deletions config/tsconfig.base.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"compilerOptions": {
"target": "es6",
"module": "commonjs",
"moduleResolution": "node",
"removeComments": false,
"outDir": "../build",
"rootDir": "../src",
"declaration": true,
"sourceMap": false,
"importHelpers": true,
"strictNullChecks": true,
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"lib": [
"es2015",
"dom"
]
},
"include": [
"../src/**/*"
],
"exclude": [
"../node_modules",
"../build"
]
}
6 changes: 6 additions & 0 deletions config/tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": "./tsconfig.base.json",
"compilerOptions": {
"outDir": "../"
}
}
1 change: 0 additions & 1 deletion index.ts

This file was deleted.

19 changes: 19 additions & 0 deletions jest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"collectCoverage": true,
"mapCoverage": true,
"transform": {
"^.+\\.tsx?$": "<rootDir>/node_modules/ts-jest/preprocessor.js"
},
"testMatch": [
"**/test/**/*.spec.ts"
],
"testPathIgnorePatterns": [
"/node_modules/"
],
"moduleFileExtensions": [
"ts",
"tsx",
"js",
"json"
]
}
41 changes: 21 additions & 20 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@
"description": "extractor for proc-that which loads results from REST apis.",
"main": "index.js",
"scripts": {
"clean": "rimraf build",
"bootstrap": "npm install && typings install",
"pretest": "npm run clean && tsc",
"test": "mocha --ui bdd --recursive ./build",
"precitest": "npm run bootstrap && npm run clean && tsc",
"citest": "istanbul cover -x \"**/*.spec.*\" _mocha --report lcovonly -- --ui bdd --recursive ./build",
"develop": "npm run clean && tsc -w --sourceMap --pretty"
"clean": "del-cli ./build ./coverage",
"build": "npm run clean && tsc -p ./config/tsconfig.build.json",
"develop": "npm run clean && tsc -p .",
"lint": "tslint -c ./tslint.json -p ./config/tsconfig.build.json",
"test": "npm run lint && npm run clean && jest -c ./jest.json",
"test:watch": "npm run clean && jest -c ./jest.json --watch"
},
"keywords": [
"etl",
Expand All @@ -19,29 +18,31 @@
"proc-that",
"rest"
],
"engines": {
"node": ">=6"
},
"repository": {
"type": "git",
"url": "git@github.com:smartive/proc-that-rest-extractor.git"
"url": "https://github.com/smartive/proc-that-rest-extractor.git"
},
"bugs": "https://github.com/smartive/proc-that-rest-extractor/issues",
"author": "Christoph Bühler <christoph.buehler@bluewin.ch>",
"license": "MIT",
"devDependencies": {
"chai": "^3.5.0",
"chai-as-promised": "^5.3.0",
"del-cli": "^0.2.0",
"istanbul": "^0.4.4",
"mocha": "^2.5.3",
"mocha-lcov-reporter": "^1.2.0",
"rimraf": "^2.5.3",
"sinon": "^1.17.4",
"sinon-chai": "^2.8.0",
"typescript": "^1.8.10",
"typings": "^1.3.1"
"@types/jest": "^20.0.5",
"del-cli": "^1.1.0",
"jest": "^20.0.4",
"ts-jest": "^20.0.7",
"tslint": "^5.5.0",
"tslint-config-airbnb": "^5.2.1",
"tsutils": "^2.8.0",
"typescript": "^2.4.2"
},
"dependencies": {
"proc-that": "^0.4.0",
"restler": "^3.4.0",
"rxjs": "5.0.0-beta.10"
"@types/node": "^8.0.17",
"rxjs": "^5.4.2",
"tslib": "^1.7.1"
}
}
32 changes: 18 additions & 14 deletions RestExtractor.ts → src/RestExtractor.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import {Extractor} from 'proc-that';
import {Observable, Observer} from 'rxjs';
import { Extractor } from 'proc-that';
import { Observable, Observer } from 'rxjs';

export enum RestExtractorMethod {
Get,
Post,
Put
Put,
}

type MethodOptions = {
Expand Down Expand Up @@ -33,7 +33,7 @@ export type RestExtractorOptions = {
*
*/
export class RestExtractor implements Extractor {
private rest:any = require('restler');
private rest: any = require('restler');

/**
*
Expand All @@ -42,26 +42,30 @@ export class RestExtractor implements Extractor {
* @param resultSelector
* @param {number} [timeout=120000] Request timeout in milliseconds
*/
constructor(private url:string, private method:RestExtractorMethod = RestExtractorMethod.Get, private resultSelector:(obj:any) => any = o => o, private restlerOptions: RestExtractorOptions = {}) {
}
constructor(
private url: string,
private method: RestExtractorMethod = RestExtractorMethod.Get,
private resultSelector: (obj: any) => any = o => o,
private restlerOptions: RestExtractorOptions = {},
) { }

public read(): Observable<any> {
return Observable.create((observer:Observer<any>) => {
let options: MethodOptions & RestExtractorOptions = this.restlerOptions;
options.method = this.getUrlMethod();
return Observable.create((observer: Observer<any>) => {
const options: MethodOptions & RestExtractorOptions = this.restlerOptions;
options.method = this.getUrlMethod();
this.rest
.request(this.url, options)
.on('error', err => {
.on('error', (err) => {
observer.error(err);
})
.on('complete', result => {
.on('complete', (result) => {
try {
let json = typeof result === 'string' ? JSON.parse(result) : result;
json = this.resultSelector(json);
if (json instanceof Array || json.constructor === Array) {
json.forEach(element => observer.next(element));
} else {
observer.next(json)
observer.next(json);
}
} catch (e) {
observer.error(e);
Expand All @@ -72,7 +76,7 @@ export class RestExtractor implements Extractor {
});
}

private getUrlMethod():string {
private getUrlMethod(): string {
switch (this.method) {
case RestExtractorMethod.Post:
return 'post';
Expand All @@ -82,4 +86,4 @@ export class RestExtractor implements Extractor {
return 'get';
}
}
}
}
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './RestExtractor';
Loading