Skip to content

Crawlee—A web scraping and browser automation library for Node.js to build reliable crawlers. In JavaScript and TypeScript. Extract data for AI, LLMs, RAG, or GPTs. Download HTML, PDF, JPG, PNG, and other files from websites. Works with Puppeteer, Playwright, Cheerio, JSDOM, and raw HTTP. Both headful and headless mode. With proxy rotation.

Renamed environment variables to match the server, bumped package.json version

Jan Curn0e22ddce823a
diff --git a/README.md b/README.md
index f08124ac7..1684a7efc 100644
--- a/README.md
+++ b/README.md
@@ -78,7 +78,7 @@ const server = http.createServer((req, res) => {
process.exit(err ? 1 : 0);
});
});
-server.listen(process.env.APIFIER_INTERNAL_PORT|0, (err) => {
+server.listen(process.env.APIFY_INTERNAL_PORT|0, (err) => {
if( err ) {
console.log(`Oops: ${err}`);
process.exit(1);
@@ -89,7 +89,7 @@ server.listen(process.env.APIFIER_INTERNAL_PORT|0, (err) => {
```
Note that by calling `Apifier.heyIAmReady()` you tell the Actor runtime that your server is ready to start
-receiving HTTP requests over the port specified by the `APIFIER_INTERNAL_PORT` environment variable.
+receiving HTTP requests over the port specified by the `APIFY_INTERNAL_PORT` environment variable.
To set a promise dependency from an external library, use the following code:
diff --git a/build/actor.js b/build/actor.js
index 6acb01401..1b8b78a95 100644
--- a/build/actor.js
+++ b/build/actor.js
@@ -27,9 +27,9 @@ var main = exports.main = function main(userFunc) {
if (!userFunc || typeof userFunc !== 'function') {
throw new Error('Handler function must be provided as a parameter');
}
- var serverPort = parseInt(process.env.APIFIER_INTERNAL_PORT, 10);
+ var serverPort = parseInt(process.env.APIFY_INTERNAL_PORT, 10);
if (!(serverPort > 0 && serverPort < 65536)) {
- throw new Error('APIFIER_INTERNAL_PORT environment variable must have a value from 1 to 65535.');
+ throw new Error('APIFY_INTERNAL_PORT environment variable must have a value from 1 to 65535.');
}
var handler = function handler(req, res) {
@@ -84,11 +84,11 @@ var main = exports.main = function main(userFunc) {
};
/**
- * Notifies Apifier runtime that act is listening on port specified by the APIFIER_INTERNAL_PORT environment
+ * Notifies Apifier runtime that act is listening on port specified by the APIFY_INTERNAL_PORT environment
* variable and is ready to receive a HTTP request with act input.
*/
var heyIAmReady = exports.heyIAmReady = function heyIAmReady() {
- var watchFileName = process.env.APIFIER_WATCH_FILE;
+ var watchFileName = process.env.APIFY_WATCH_FILE;
if (watchFileName) {
_fs2.default.writeFile(watchFileName, '', function (err) {
if (err) console.log('WARNING: Cannot write to watch file ' + watchFileName + ': ' + err);
diff --git a/package.json b/package.json
index a8867a3cc..cfc270771 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "apifier",
- "version": "0.0.21",
+ "version": "0.0.22",
"description": "Apifier SDK for JavaScript",
"main": "build/index.js",
"keywords": [
diff --git a/src/actor.js b/src/actor.js
index 6a871fd22..2109a5b1e 100644
--- a/src/actor.js
+++ b/src/actor.js
@@ -10,9 +10,9 @@ export const main = (userFunc) => {
if (!userFunc || typeof (userFunc) !== 'function') {
throw new Error('Handler function must be provided as a parameter');
}
- const serverPort = parseInt(process.env.APIFIER_INTERNAL_PORT, 10);
+ const serverPort = parseInt(process.env.APIFY_INTERNAL_PORT, 10);
if (!(serverPort > 0 && serverPort < 65536)) {
- throw new Error('APIFIER_INTERNAL_PORT environment variable must have a value from 1 to 65535.');
+ throw new Error('APIFY_INTERNAL_PORT environment variable must have a value from 1 to 65535.');
}
const handler = (req, res) => {
@@ -72,11 +72,11 @@ export const main = (userFunc) => {
};
/**
- * Notifies Apifier runtime that act is listening on port specified by the APIFIER_INTERNAL_PORT environment
+ * Notifies Apifier runtime that act is listening on port specified by the APIFY_INTERNAL_PORT environment
* variable and is ready to receive a HTTP request with act input.
*/
export const heyIAmReady = () => {
- const watchFileName = process.env.APIFIER_WATCH_FILE;
+ const watchFileName = process.env.APIFY_WATCH_FILE;
if (watchFileName) {
fs.writeFile(watchFileName, '', (err) => {
if (err) console.log(`WARNING: Cannot write to watch file ${watchFileName}: ${err}`);
diff --git a/test/actor.js b/test/actor.js
index b47a37bd0..b11bbee9f 100644
--- a/test/actor.js
+++ b/test/actor.js
@@ -62,8 +62,8 @@ const testWatchFileWillBecomeEmpty = (path, waitMillis) => {
const testMain = (method, bodyRaw, contentType, userFunc, expectedExitCode = 0) => {
const port = popFreePort();
- process.env.APIFIER_INTERNAL_PORT = port;
- process.env.APIFIER_WATCH_FILE = createWatchFile();
+ process.env.APIFY_INTERNAL_PORT = port;
+ process.env.APIFY_WATCH_FILE = createWatchFile();
// intercept calls to process.exit()
const EMPTY_EXIT_CODE = 'dummy';
@@ -108,7 +108,7 @@ const testMain = (method, bodyRaw, contentType, userFunc, expectedExitCode = 0)
})
.then(() => {
// watch file should be empty by now
- return testWatchFileWillBecomeEmpty(process.env.APIFIER_WATCH_FILE, 0);
+ return testWatchFileWillBecomeEmpty(process.env.APIFY_WATCH_FILE, 0);
})
.then(() => {
// test process exit code is as expected
@@ -132,7 +132,7 @@ const testMain = (method, bodyRaw, contentType, userFunc, expectedExitCode = 0)
describe('Apifier.main()', () => {
it('throws on invalid args', () => {
- process.env.APIFIER_INTERNAL_PORT = 1234;
+ process.env.APIFY_INTERNAL_PORT = 1234;
expect(() => {
Apifier.main();
}).to.throw(Error);
@@ -143,16 +143,16 @@ describe('Apifier.main()', () => {
Apifier.main(() => {});
};
- process.env.APIFIER_INTERNAL_PORT = null;
+ process.env.APIFY_INTERNAL_PORT = null;
expect(fn).to.throw(Error);
- process.env.APIFIER_INTERNAL_PORT = '';
+ process.env.APIFY_INTERNAL_PORT = '';
expect(fn).to.throw(Error);
- process.env.APIFIER_INTERNAL_PORT = 0;
+ process.env.APIFY_INTERNAL_PORT = 0;
expect(fn).to.throw(Error);
- process.env.APIFIER_INTERNAL_PORT = 65536;
+ process.env.APIFY_INTERNAL_PORT = 65536;
expect(fn).to.throw(Error);
});
@@ -189,8 +189,8 @@ describe('Apifier.main()', () => {
describe('Apifier.heyIAmReady()', () => {
it('it works as expected', () => {
- process.env.APIFIER_WATCH_FILE = createWatchFile();
+ process.env.APIFY_WATCH_FILE = createWatchFile();
Apifier.heyIAmReady();
- return testWatchFileWillBecomeEmpty(process.env.APIFIER_WATCH_FILE, 1000);
+ return testWatchFileWillBecomeEmpty(process.env.APIFY_WATCH_FILE, 1000);
});
});