klfwdh
Pricing
Pay per usage
Go to Store
klfwdh
0.0 (0)
Pricing
Pay per usage
0
Total users
1
Monthly users
0
Last modified
3 years ago
.editorconfig
root = true
[*]indent_style = spaceindent_size = 4charset = utf-8trim_trailing_whitespace = trueinsert_final_newline = trueend_of_line = lf
.eslintrc
{ "extends": "@apify/eslint-config-ts", "root": true, "parserOptions": { "project": "./tsconfig.eslint.json" }}
Dockerfile
# using multistage build, as we need dev deps to build the TS source codeFROM apify/actor-node:16 AS builder
# copy all files, install all dependencies (including dev deps) and build the projectCOPY . ./RUN npm install --include=dev \ && npm run build
# create final image, copy only package.json, readme and compiled codeFROM apify/actor-node:16# copy only necessary filesCOPY /usr/src/app/package*.json ./COPY /usr/src/app/README.md ./COPY /usr/src/app/dist ./distCOPY /usr/src/app/INPUT_SCHEMA.json ./INPUT_SCHEMA.json
# install only prod depsRUN npm --quiet set progress=false \ && npm install --only=prod --no-optional \ && echo "Installed NPM packages:" \ && (npm list --only=prod --no-optional --all || true) \ && echo "Node.js version:" \ && node --version \ && echo "NPM version:" \ && npm --version
# run compiled codeCMD npm run start:prod
.gitignore
apify_storagenode_modules.ideadist
INPUT_SCHEMA.json
{ "title": "Input schema for the hello_word actor.", "type": "object", "schemaVersion": 1, "properties": { "message": { "title": "Message", "type": "string", "description": "Just enter your hello world message.", "editor": "textfield" } }, "required": []}
apify.json
{ "env": { "npm_config_loglevel": "silent" }}
package.json
{ "name": "example-typescript", "version": "0.0.1", "description": "This is an example of an Apify actor.", "dependencies": { "@apify/log": "^2.1.1", "apify": "^3.0.1" }, "devDependencies": { "@apify/eslint-config-ts": "^0.2.3", "@apify/tsconfig": "^0.1.0", "@typescript-eslint/eslint-plugin": "^5.30.7", "@typescript-eslint/parser": "^5.30.7", "eslint": "^8.20.0", "ts-node": "^10.9.1", "typescript": "^4.7.4" }, "scripts": { "start": "npm run start:dev", "start:prod": "node dist/main.js", "start:dev": "ts-node -T src/main.ts", "build": "tsc", "lint": "eslint ./src --ext .js,.ts", "lint:fix": "eslint ./src --ext .js,.ts --fix", "test": "echo \"Error: oops, the actor has no tests yet, sad!\" && exit 1" }, "author": "It's not you it's me", "license": "ISC"}
tsconfig.eslint.json
{ "include": ["src"]}
tsconfig.json
{ "extends": "@apify/tsconfig", "compilerOptions": { "skipLibCheck": true, "outDir": "dist" }, "include": [ "./src/**/*" ]}
src/main.ts
1// This is the main Node.js source code file of your actor.2// It is referenced from the "scripts" section of the package.json file,3// so that it can be started by running "npm start".4
5// Include Apify SDK. For more information, see https://sdk.apify.com/6import { Actor } from 'apify';7import log from '@apify/log';8
9interface Schema {10 message?: string;11}12
13Actor.main(async () => {14 // Get input of the actor.15 // If you'd like to have your input checked and have Apify display16 // a user interface for it, add INPUT_SCHEMA.json file to your actor.17 // For more information, see https://apify.com/docs/actor/input-schema18
19 const input = await Actor.getInput<Schema>();20 log.info('Input:', input);21
22 // Do something useful here...23 if (input?.message) {24 log.info(`Message is: ${input.message}`);25 }26
27 // Save output28 const output = {29 receivedInput: input,30 message: 'Hello sir!',31 };32 log.info('Output:', output);33 await Actor.setValue('OUTPUT', output);34});