diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..9e11752
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,6 @@
+dist: trusty
+addons:
+ chrome: stable
+language: node_js
+node_js:
+- "8.8"
\ No newline at end of file
diff --git a/README.md b/README.md
index 9c15a35..2fc3fe6 100644
--- a/README.md
+++ b/README.md
@@ -1,2 +1,55 @@
# webshot-factory
+[![Build Status](https://travis-ci.org/ashubham/webshot-factory.svg?branch=master)](https://travis-ci.org/ashubham/webshot-factory)
+[![npm version](https://badge.fury.io/js/webshot-factory.svg)](https://badge.fury.io/js/webshot-factory)
+
+
+
screenshots at scale based on headless chrome
+
+## Installation
+
+```
+npm i webshot-factory
+```
+
+## Usage
+
+```javascript
+import * as shotFactory from 'webshot-factory';
+
+await shotFactory.init({
+ // Number of worker threads (chrome instances) to run.
+ // A shot is assigned to a worker in round robin.
+ concurrency: 10,
+
+ // The callback method to be exposed on the window,
+ // which would be called by the application
+ // Shot will be taken when callback is called.
+ callbackName: 'callPhantom',
+
+ // A cache warmer url,
+ // so that workers can cache the webpage scripts.
+ warmerUrl: 'http://google.com',
+ width: 1000, // shot width
+ height: 600, // shot height
+ timeout: 60000, // timeout (millis) to wait for shot.
+ webshotDebugPort: 3030 // Port where the status page is served.
+});
+
+// Once initialized just call getShot and
+// a shot will be scheduled on a worker
+// chrome instance.
+shotFactory.getShot('http://yahoo.com').then(buffer => {
+ console.log(buffer);
+});
+```
+
+## Status Page
+
+`Webshot-factory` includes a status page to check the status of the running chrome instance workers.
+
+Visit: `http://:/status`
+
+To check the status and debug any problems. The page looks like this:
+
+
diff --git a/assets/webshot-factory.png b/assets/webshot-factory.png
new file mode 100644
index 0000000..d0524f4
Binary files /dev/null and b/assets/webshot-factory.png differ
diff --git a/index.ts b/index.ts
index 9fb5814..6863d8a 100644
--- a/index.ts
+++ b/index.ts
@@ -11,7 +11,7 @@ let ip;
internalIp.v4().then(_ip => ip = _ip);
export interface Config extends shotPool.PoolConfig {
-
+ webshotDebugPort: string;
}
let defaultConfig: Config = {
@@ -20,14 +20,19 @@ let defaultConfig: Config = {
warmerUrl: '',
width: 800,
height: 600,
- timeout: 60000
+ timeout: 60000,
+ webshotDebugPort: process.env.webshotDebugPort
};
+let passedConfig : Config;
+
export async function init(options: Config) {
options = Object.assign({}, defaultConfig, options);
- return shotPool.create(
+ passedConfig = options;
+ await shotPool.create(
options
);
+ return shotPool;
}
export function getShot(url: string): PromiseLike {
@@ -85,4 +90,4 @@ app.get('/status', (req, res) => {
`)
});
-app.listen(parseInt(process.env.webshotDebugPort), ip);
\ No newline at end of file
+app.listen(parseInt(passedConfig.webshotDebugPort), ip);
\ No newline at end of file
diff --git a/package.json b/package.json
index 9552082..1366017 100644
--- a/package.json
+++ b/package.json
@@ -1,11 +1,11 @@
{
"name": "webshot-factory",
- "version": "0.3.2",
+ "version": "0.3.3",
"description": "screenshots at scale based on headless chrome",
"main": "dist/index.js",
"types": "dist/declarations/index.d.ts",
"scripts": {
- "test": "echo \"Error: no test specified\" && exit 1",
+ "test": "npm run build",
"build": "tsc -p .",
"prepublish": "npm run build"
},
@@ -13,6 +13,12 @@
"type": "git",
"url": "git+https://github.com/ashubham/webshot-factory.git"
},
+ "keywords": [
+ "webshot",
+ "headless",
+ "chrome",
+ "screenshot"
+ ],
"author": "ashish.shubham@thoughtspot.com",
"license": "ISC",
"bugs": {
@@ -27,7 +33,7 @@
"internal-ip": "^3.0.0",
"lodash": "^4.17.4",
"log4js": "^1.1.1",
- "puppeteer": "^0.11.0"
+ "puppeteer": "^1.0.0"
},
"devDependencies": {
"@types/bluebird": "^3.5.11",