@microlink/function 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -12,7 +12,7 @@
12
12
 
13
13
  ## Highlights
14
14
 
15
- - Starts from $0/mo.
15
+ - Starts from \$0/mo.
16
16
  - Run Serverless Javascript functions (also [locally](https://github.com/microlinkhq/local)).
17
17
  - Ability to require to require any of the [allowed](#npm-packages) NPM packages.
18
18
  - Headless Chromium browser access in the same request cycle.
@@ -22,12 +22,12 @@
22
22
 
23
23
  - [How it works](#how-it-works)
24
24
  - [Installation](#installation)
25
- * [from NPM](#from-npm)
26
- * [from CDN](#from-cdn)
25
+ - [from NPM](#from-npm)
26
+ - [from CDN](#from-cdn)
27
27
  - [Get Started](#get-started)
28
- * [Input](#input)
29
- + [NPM packages](#npm-packages)
30
- * [Output](#output)
28
+ - [Input](#input)
29
+ - [NPM packages](#npm-packages)
30
+ - [Output](#output)
31
31
  - [Examples](#examples)
32
32
  - [Pricing](#pricing)
33
33
  - [API](#api)
@@ -66,9 +66,8 @@ Load directly in the browser from your favorite CDN:
66
66
  Let say you have a JavaScript like this:
67
67
 
68
68
  ```js
69
- const ping = ({ query, response }) => query.statusCode
70
- ? response.status()
71
- : response.statusText()
69
+ const ping = ({ statusCode, response }) =>
70
+ statusCode ? response.status() : response.statusText()
72
71
  ```
73
72
 
74
73
  To run the previous code as **Microlink Function**, all you need to do is wrap the function with the `microlink` decorator:
@@ -76,7 +75,7 @@ To run the previous code as **Microlink Function**, all you need to do is wrap t
76
75
  ```js
77
76
  const microlink = require('@microlink/function')
78
77
 
79
- const ping = microlink({ query, response }) => query.statusCode
78
+ const ping = microlink({ response }) => statusCode
80
79
  ? response.status()
81
80
  : response.statusText()
82
81
  )
@@ -98,9 +97,9 @@ console.log(result)
98
97
 
99
98
  When a function is wrapped by **Microlink Function** the function execution is done remotely, giving back the result.
100
99
 
101
- Any **Microlink Function** receives the following parameters:
100
+ Any **Microlink Function** will receive the following parameters:
102
101
 
103
- - `query`: The query parameter provided as second argument.
102
+ - `html`: When [meta](https://microlink.io/docs/api/parameters/meta) is enabled, the HTML markup of the website is provided.
104
103
  - `page`: The [`puppeteer#page`](https://github.com/puppeteer/puppeteer/blob/main/docs/api.md#class-page) instance to interact with the headless browser.
105
104
  - `response`: The [`puppeteer#response`](https://github.com/puppeteer/puppeteer/blob/main/docs/api.md#class-httpresponse) as result of the implicit [`page.goto`](https://github.com/puppeteer/puppeteer/blob/main/docs/api.md#pagegotourl-options).
106
105
 
@@ -111,9 +110,8 @@ Additionally, you can require a allowed list of common NPM packages inside your
111
110
  ```js
112
111
  const microlink = require('@microlink/function')
113
112
 
114
- const ping = microlink(({ query, response }) => {
113
+ const ping = microlink(({ statusCode, response }) => {
115
114
  const { result } = require('lodash')
116
- const { statusCode } = query
117
115
  return result(response, statusCode ? 'status' : 'statusText')
118
116
  })
119
117
  ```
@@ -127,6 +125,7 @@ The list of allowed NPM packages are:
127
125
  - [`@mozilla/readability`](https://npm.im/@mozilla/readability)
128
126
  - [`async`](https://npm.im/async)
129
127
  - [`cheerio`](https://npm.im/cheerio)
128
+ - [`extract-email-address`](https://npm.im/extract-email-address)
130
129
  - [`got`](https://npm.im/got)
131
130
  - [`ioredis`](https://npm.im/ioredis)
132
131
  - [`jsdom`](https://npm.im/jsdom)
@@ -165,9 +164,8 @@ For [authenticating](https://microlink.io/docs/api/basics/authentication) your r
165
164
  ```js
166
165
  const microlink = require('@microlink/function')
167
166
 
168
- const code = ({ query, response }) => {
167
+ const code = ({ statusCode, response }) => {
169
168
  const { result } = require('lodash')
170
- const { statusCode } = query
171
169
  return result(response, statusCode ? 'status' : 'statusText')
172
170
  }
173
171
 
@@ -180,7 +178,7 @@ const ping = microlink(code, { apiKey: process.env.MICROLINK_API_KEY })
180
178
 
181
179
  #### fn
182
180
 
183
- *Required*<br>
181
+ _Required_<br>
184
182
  Type: `function`
185
183
 
186
184
  The function that be executed inside Microlink API browser.