1import http from 'http';
2import { Actor } from 'apify';
3import log from '@apify/log';
4
5await Actor.init();
6
7const chargeUser = async ({eventName, count}) => {
8 const chargeOptions = {
9 eventName,
10 count,
11 }
12 const chargeResult = await Actor.charge(chargeOptions)
13 log.info(`Charged user.`, { chargeOptions, chargeResult })
14}
15
16const server = http.createServer((req, res) => {
17
18
19 if (req.headers['x-apify-container-server-readiness-probe']) {
20 res.writeHead(200);
21 res.end('ok');
22 return;
23 }
24
25 chargeUser({eventName: 'cheap', count: 12});
26 chargeUser({eventName: 'expensive', count: 2});
27
28 res.writeHead(200, { 'Content-Type': 'text/plain' });
29 res.end(`Hello from Actor Standby!\nThanks for your money lol\n`);
30});
31
32
33server.listen(Actor.config.get('standbyPort'));