REPL avatar
REPL
Try for free

No credit card required

View all Actors
REPL

REPL

mnmkng/repl
Try for free

No credit card required

Develop scripts and tools blazingly fast with this Apify REPL. You no longer need to build your actor with every code change just to test something out. Create a REPL task and hack away. No builds needed. Latest Apify included.

Dockerfile

1FROM apify/actor-node-puppeteer-chrome
2
3COPY package.json ./
4
5RUN npm --quiet set progress=false \
6 && npm install --only=prod --no-optional \
7 && echo "Installed NPM packages:" \
8 && (npm list || true) \
9 && echo "Node.js version:" \
10 && node --version \
11 && echo "NPM version:" \
12 && npm --version
13
14COPY . ./
15
16CMD node fetch.js | node

INPUT_SCHEMA.json

1{
2  "title": "REPL",
3  "description": "",
4  "type": "object",
5  "schemaVersion": 1,
6  "properties": {
7    "code": {
8      "title": "Code",
9      "type": "string",
10      "description": "Enter the code to be executed.",
11      "editor": "javascript",
12      "prefill": "console.log('Hello version 1!');"
13    }
14  },
15  "required": [
16    "code"
17  ]
18}

fetch.js

1const ApifyClient = require('apify-client');
2
3const client = new ApifyClient({
4    token: process.env.APIFY_TOKEN,
5});
6
7client.keyValueStore(process.env.APIFY_DEFAULT_KEY_VALUE_STORE_ID).getRecord('INPUT')
8    .then(record => {
9        const input = record && record.value;
10        const { code } = input;
11        const type = typeof code;
12        if (type !== 'string') throw new Error(`Expected script to evaluate but received: ${type}`);
13        if (!code.length) throw new Error('Cannot evaluate empty script.');
14        process.stdout.write(code);
15    })
16    .catch(err => {
17        console.error(err);
18        process.exit(1);
19    })

package.json

1{
2    "name": "my-actor",
3    "version": "0.0.1",
4    "dependencies": {
5        "apify": "^1.2.1"
6    },
7    "scripts": {
8        "start": ""
9    },
10    "author": "Me!"
11}
Developer
Maintained by Community
Actor metrics
  • 1 monthly users
  • 100.0% runs succeeded
  • 0.0 days response time
  • Created in Jan 2020
  • Modified 6 months ago
Categories