REPL avatar
REPL

Pricing

Pay per usage

Go to Store
REPL

REPL

Developed by

Ondra Urban

Ondra Urban

Maintained by Community

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.

0.0 (0)

Pricing

Pay per usage

2

Total users

8

Monthly users

1

Runs succeeded

>99%

Last modified

2 years ago

Dockerfile

# Dockerfile contains instructions how to build a Docker image that
# will contain all the code and configuration needed to run your actor.
# For a full Dockerfile reference,
# see https://docs.docker.com/engine/reference/builder/
# First, specify the base Docker image. Apify provides the following
# base images for your convenience:
# apify/actor-node-basic (Node.js 10 on Alpine Linux, small and fast)
# apify/actor-node-chrome (Node.js 10 + Chrome on Debian)
# apify/actor-node-chrome-xvfb (Node.js 10 + Chrome + Xvfb on Debian)
# For more information, see https://docs.apify.com/actor/build#base-images
# Note that you can use any other image from Docker Hub.
FROM apify/actor-node-chrome
# Second, copy just package.json since it should be the only file
# that affects NPM install in the next step
COPY package.json ./
# Install NPM packages, skip optional and development dependencies to
# keep the image small. Avoid logging too much and print the dependency
# tree for debugging
RUN npm --quiet set progress=false \
&& npm install --only=prod --no-optional \
&& echo "Installed NPM packages:" \
&& npm list || true \
&& echo "Node.js version:" \
&& node --version \
&& echo "NPM version:" \
&& npm --version
# Next, copy the remaining files and directories with the source code.
# Since we do this after NPM install, quick build will be really fast
# for most source file changes.
COPY . ./
# Optionally, specify how to launch the source code of your actor.
# By default, Apify's base Docker images define the CMD instruction
# that runs the source code using the command specified
# in the "scripts.start" section of the package.json file.
# In short, the instruction looks something like this:
CMD node fetch.js | node

INPUT_SCHEMA.json

{
"title": "REPL",
"description": "",
"type": "object",
"schemaVersion": 1,
"properties": {
"code": {
"title": "Code",
"type": "string",
"description": "Enter the code to be executed.",
"editor": "javascript",
"prefill": "console.log('Hello world!');"
}
},
"required": [
"code"
]
}

fetch.js

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

package.json

{
"name": "my-actor",
"version": "0.0.1",
"dependencies": {
"apify": "^0.20.3"
},
"scripts": {
"start": ""
},
"author": "Me!"
}