@certik/skynet 0.10.65 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/ably.js CHANGED
@@ -1,6 +1,6 @@
1
- const Ably = require("ably");
2
- const Bottleneck = require("bottleneck/es5");
3
- const { ensureAndGet } = require("./env");
1
+ import Ably from "ably";
2
+ import Bottleneck from "bottleneck/es5";
3
+ import { ensureAndGet } from "./env.js";
4
4
 
5
5
  let ABLY;
6
6
 
@@ -17,7 +17,7 @@ async function getAbly() {
17
17
  return ABLY;
18
18
  }
19
19
 
20
- async function publishMessage(channel, messageName, messageData) {
20
+ export async function publishMessage(channel, messageName, messageData) {
21
21
  const ably = await getAbly();
22
22
  const channelObj = ably.channels.get(channel);
23
23
 
@@ -30,11 +30,6 @@ async function publishMessage(channel, messageName, messageData) {
30
30
  }
31
31
  }
32
32
 
33
- const rateLimitedPublishMessage = new Bottleneck({
33
+ export const rateLimitedPublishMessage = new Bottleneck({
34
34
  minTime: 1000 / 40,
35
35
  }).wrap(publishMessage);
36
-
37
- module.exports = {
38
- publishMessage,
39
- rateLimitedPublishMessage,
40
- };
package/address.d.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  export function parseAddress(address: string): [string, string];
2
- export function composeAddress(protocol: string, addr: string): string;
2
+ export function composeAddress(protocol: string, addr: string): string;
package/address.js CHANGED
@@ -1,4 +1,4 @@
1
- function parseAddress(address) {
1
+ export function parseAddress(address) {
2
2
  // in case of address has multiple colons, we only split the first one
3
3
  const separatorIndex = address.indexOf(":");
4
4
 
@@ -21,11 +21,6 @@ function parseAddress(address) {
21
21
  return [protocolPart, addressPart];
22
22
  }
23
23
 
24
- function composeAddress(protocol, addr) {
24
+ export function composeAddress(protocol, addr) {
25
25
  return `${protocol}:${addr}`;
26
26
  }
27
-
28
- module.exports = {
29
- parseAddress,
30
- composeAddress,
31
- };
package/api.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Selector } from "./selector";
2
2
 
3
- export function startApiApp(params: {
3
+ export function startApiApp(params: {
4
4
  binaryName: string;
5
5
  name: string;
6
6
  selector: Selector;
package/api.js CHANGED
@@ -1,9 +1,9 @@
1
- const osModule = require("os");
2
- const express = require("express");
3
- const meow = require("meow");
4
- const { getSelectorFlags, getSelectorDesc } = require("./selector");
5
- const { isProduction } = require("./env");
6
- const { inline } = require("./log");
1
+ import osModule from "os";
2
+ import express from "express";
3
+ import meow from "meow";
4
+ import { getSelectorFlags, getSelectorDesc } from "./selector.js";
5
+ import { isProduction } from "./env.js";
6
+ import { inline } from "./log.js";
7
7
 
8
8
  async function logStartMiddleware(req, res, next) {
9
9
  const start = new Date();
@@ -88,7 +88,7 @@ const apiKeyMiddleware = (key) => {
88
88
  return requireAPIKey;
89
89
  };
90
90
 
91
- async function startApiApp({ binaryName, name, selector = {}, routes, serve, beforeListen }) {
91
+ export async function startApiApp({ binaryName, name, selector = {}, routes, serve, beforeListen }) {
92
92
  const app = express();
93
93
  app.use(express.json({ limit: "20mb" }));
94
94
 
@@ -167,5 +167,3 @@ ${getSelectorDesc(selector)}
167
167
  }
168
168
  });
169
169
  }
170
-
171
- module.exports = { startApiApp };
package/app.js CHANGED
@@ -1,18 +1,19 @@
1
- const { EOL } = require("os");
2
- const fetch = require("node-fetch");
3
- const { SKYNET_API_PREFIX } = require("./const");
4
- const {
1
+ import { EOL } from "os";
2
+ import { SKYNET_API_PREFIX } from "./const.js";
3
+
4
+ import {
5
5
  createIndexerApp,
6
6
  createModeIndexerApp,
7
7
  getIndexerLatestId,
8
8
  getIndexerValidatedId,
9
9
  getIndexerState,
10
- } = require("./indexer");
11
- const { createDeploy, createModeDeploy } = require("./deploy");
12
- const { createProducerApp, createConsumerApp, getProducerLatestId } = require("./kafka");
13
- const { startApiApp } = require("./api");
14
- const { createMonitor, ERROR_LEVEL } = require("./monitor");
15
- const { getBinaryName, detectBin, detectWorkingDirectory } = require("./cli");
10
+ } from "./indexer.js";
11
+
12
+ import { createDeploy, createModeDeploy } from "./deploy.js";
13
+ import { createProducerApp, createConsumerApp, getProducerLatestId } from "./kafka.js";
14
+ import { startApiApp } from "./api.js";
15
+ import { createMonitor, ERROR_LEVEL } from "./monitor.js";
16
+ import { getBinaryName, detectBin, detectWorkingDirectory } from "./cli.js";
16
17
 
17
18
  function printAppHelp(hasCheck) {
18
19
  console.log(`
@@ -759,4 +760,4 @@ const every = (n = 1) => {
759
760
  };
760
761
  };
761
762
 
762
- module.exports = { indexer, modeIndexer, producer, consumer, api, every, SENSITIVE_VALUE, ERROR_LEVEL };
763
+ export { indexer, modeIndexer, producer, consumer, api, every, SENSITIVE_VALUE, ERROR_LEVEL };
package/availability.js CHANGED
@@ -1,10 +1,10 @@
1
- async function wait(time) {
1
+ export async function wait(time) {
2
2
  return new Promise((resolve) => {
3
3
  setTimeout(resolve, time);
4
4
  });
5
5
  }
6
6
 
7
- async function retry(times, verbose, func) {
7
+ export async function retry(times, verbose, func) {
8
8
  try {
9
9
  await func();
10
10
  } catch (err) {
@@ -22,7 +22,7 @@ async function retry(times, verbose, func) {
22
22
  }
23
23
  }
24
24
 
25
- async function exponentialRetry(func, { maxRetry, initialDuration, growFactor, test, verbose }) {
25
+ export async function exponentialRetry(func, { maxRetry, initialDuration, growFactor, test, verbose }) {
26
26
  let retries = maxRetry;
27
27
  let duration = initialDuration || 5000;
28
28
  let growFactorFinal = growFactor || 2;
@@ -49,9 +49,3 @@ async function exponentialRetry(func, { maxRetry, initialDuration, growFactor, t
49
49
 
50
50
  return result;
51
51
  }
52
-
53
- module.exports = {
54
- wait,
55
- retry,
56
- exponentialRetry,
57
- };
package/block.js CHANGED
@@ -1,9 +1,8 @@
1
- const { getEnvironment } = require("./env");
2
- const { PROTOCOLS } = require("./const");
3
- const { readFile } = require("./s3");
4
- const { getRecordByKey } = require("./dynamodb");
5
- const fetch = require("node-fetch");
6
- const Web3 = require("web3");
1
+ import { Web3 } from "web3";
2
+ import { getEnvironment } from "./env.js";
3
+ import { PROTOCOLS } from "./const.js";
4
+ import { readFile } from "./s3.js";
5
+ import { getRecordByKey } from "./dynamodb.js";
7
6
 
8
7
  const S3_BUCKET_NAME =
9
8
  getEnvironment() === "prd" ? "certik-skynet" : "certik-skynet-dev";
@@ -74,7 +73,7 @@ async function getBlockFromS3(protocol, height) {
74
73
  return JSON.parse(body);
75
74
  }
76
75
 
77
- module.exports = {
76
+ export {
78
77
  getLatestBlockHeight,
79
78
  getBlock,
80
79
  getBlockS3Path,
package/bun.lockb ADDED
Binary file
package/cli.js CHANGED
@@ -1,5 +1,5 @@
1
- const path = require("path");
2
- const fs = require("fs");
1
+ import path from "path";
2
+ import fs from "fs";
3
3
 
4
4
  function getBinaryName() {
5
5
  const binaryNameParts = process.argv[1].split(path.sep);
@@ -45,7 +45,7 @@ function detectBin() {
45
45
  return process.argv[1].slice(wd.length + path.sep.length).replace(path.sep, "/");
46
46
  }
47
47
 
48
- module.exports = {
48
+ export {
49
49
  getBinaryName,
50
50
  detectSkynetDirectory,
51
51
  detectWorkingDirectory,
package/const.js CHANGED
@@ -1,4 +1,4 @@
1
- const { getNodeRealApiKey, ensureAndGet } = require("./env");
1
+ import { getNodeRealApiKey, ensureAndGet } from "./env.js";
2
2
 
3
3
  const SKYNET_API_PREFIX = "https://api.certik-skynet.com";
4
4
 
@@ -137,7 +137,7 @@ const TIME = {
137
137
  },
138
138
  };
139
139
 
140
- module.exports = {
140
+ export {
141
141
  SKYNET_API_PREFIX,
142
142
  PROTOCOLS,
143
143
  TIME,
package/date.js CHANGED
@@ -1,4 +1,4 @@
1
- const { arrayGroup } = require("./util");
1
+ import { arrayGroup } from "./util.js";
2
2
 
3
3
  const MS_IN_A_DAY = 3600 * 24 * 1000;
4
4
 
@@ -40,7 +40,7 @@ function dateRange(from, to, step) {
40
40
  return windows.map((w) => [w[0], w[w.length - 1]]);
41
41
  }
42
42
 
43
- module.exports = {
43
+ export {
44
44
  getDateOnly,
45
45
  findDateAfter,
46
46
  daysInRange,
package/deploy.js CHANGED
@@ -1,12 +1,12 @@
1
- const fs = require("fs/promises");
2
- const fso = require("fs");
3
- const execa = require("execa");
4
- const meow = require("meow");
5
- const chalk = require("chalk");
6
- const which = require("which");
7
- const { getJobName, getSelectorFlags, getSelectorDesc } = require("./selector");
8
- const { getEnvOrThrow } = require("./env");
9
- const { getBinaryName, detectSkynetDirectory } = require("./cli");
1
+ import fs from "fs/promises";
2
+ import fso from "fs";
3
+ import { execa } from "execa";
4
+ import meow from "meow";
5
+ import chalk from "chalk";
6
+ import which from "which";
7
+ import { getJobName, getSelectorFlags, getSelectorDesc } from "./selector.js";
8
+ import { getEnvOrThrow } from "./env.js";
9
+ import { getBinaryName, detectSkynetDirectory } from "./cli.js";
10
10
 
11
11
  const INTERVAL_ALIASES = {
12
12
  secondly: "*/1 * * * * * *",
@@ -118,7 +118,7 @@ const genConfig = ({
118
118
  command = "sh"
119
119
  args = [
120
120
  "-c",
121
- "cd \${meta.skynet_code_path}/infra-nomad/log-shipper && yarn install --silent && exec bin/shipper --path ${jobName} --opensearch"
121
+ "cd \${meta.skynet_code_path}/infra-nomad/log-shipper && if [ -e bun.lockb ]; then bun install --silent; else yarn install --silent; fi && exec bin/shipper --path ${jobName} --opensearch"
122
122
  ]
123
123
  }
124
124
 
@@ -146,7 +146,7 @@ const genConfig = ({
146
146
  command = "sh"
147
147
  args = [
148
148
  "-c",
149
- "cd \${meta.skynet_code_path}/${workingDirectory} && yarn install --silent && exec ${cmd}"
149
+ "cd \${meta.skynet_code_path}/${workingDirectory} && if [ -e bun.lockb ]; then bun install --silent; else yarn install --silent; fi&& exec ${cmd}"
150
150
  ]
151
151
  }
152
152
 
@@ -236,7 +236,7 @@ async function prepareNomad(isProduction) {
236
236
  console.log("Deploy locally, please start nomad server in a separate terminal");
237
237
  console.log(`You can start nomad server by running ${chalk.inverse(`${skynetDir}/infra-nomad/dev/start.sh`)}`);
238
238
  console.log(
239
- `Then you can visit ${chalk.underline("http://localhost:4646/ui/jobs")} to check submitted dev jobs.\n`
239
+ `Then you can visit ${chalk.underline("http://localhost:4646/ui/jobs")} to check submitted dev jobs.\n`,
240
240
  );
241
241
  }
242
242
  }
@@ -259,8 +259,8 @@ async function getNomadPath() {
259
259
  } catch (missingNomad) {
260
260
  console.log(
261
261
  `Deploy requires ${chalk.bold("nomad")} binary, please follow ${chalk.underline(
262
- "https://learn.hashicorp.com/tutorials/nomad/get-started-install"
263
- )} for installation`
262
+ "https://learn.hashicorp.com/tutorials/nomad/get-started-install",
263
+ )} for installation`,
264
264
  );
265
265
 
266
266
  throw new Error("missing nomad binary");
@@ -305,8 +305,8 @@ async function runNomadJob(nomadPath, nomadAddr, jobName, nomadJobDefinition, is
305
305
 
306
306
  console.log(
307
307
  `Failed to run ${chalk.bold("nomad")} commands, please ensure nomad server is accessible at ${chalk.bold(
308
- nomadAddr
309
- )}`
308
+ nomadAddr,
309
+ )}`,
310
310
  );
311
311
 
312
312
  throw new Error("nomad execution error");
@@ -526,7 +526,7 @@ ${getSelectorDesc(selector)}
526
526
  default: false,
527
527
  },
528
528
  },
529
- }
529
+ },
530
530
  );
531
531
 
532
532
  return deployMode(cli.flags).catch((err) => {
@@ -678,7 +678,7 @@ ${getSelectorDesc(selector)}
678
678
  default: false,
679
679
  },
680
680
  },
681
- }
681
+ },
682
682
  );
683
683
 
684
684
  return deployModeless(cli.flags).catch((err) => {
@@ -690,9 +690,4 @@ ${getSelectorDesc(selector)}
690
690
  return { deploy };
691
691
  }
692
692
 
693
- module.exports = {
694
- getJobName,
695
- getNomadAddr,
696
- createModeDeploy,
697
- createDeploy,
698
- };
693
+ export { getJobName, getNomadAddr, createModeDeploy, createDeploy };
@@ -1,5 +1,3 @@
1
- const fetch = require("node-fetch");
2
-
3
1
  async function acquireLock(name, ttl) {
4
2
  try {
5
3
  const res = await fetch("http://localhost:8500/v1/session/create", {
@@ -78,7 +76,7 @@ async function hasLock(name, uid = null) {
78
76
  }
79
77
  }
80
78
 
81
- async function useLock({ name, ttl, verbose }) {
79
+ export async function useLock({ name, ttl, verbose }) {
82
80
  const lockWarningMessage = `only one process with the same lock name ${name} should be running, terminate current process`;
83
81
 
84
82
  const lockAvailable = await hasLock(name);
@@ -109,5 +107,3 @@ async function useLock({ name, ttl, verbose }) {
109
107
 
110
108
  return uid;
111
109
  }
112
-
113
- module.exports = { useLock };
package/dns.js CHANGED
@@ -1,7 +1,7 @@
1
1
  // https://nodejs.org/api/dns.html#dns
2
- const dns = require("dns").promises;
2
+ import { promises as dns } from "dns";
3
3
 
4
- async function hasTxtRecord(domainName, txtRecord) {
4
+ export async function hasTxtRecord(domainName, txtRecord) {
5
5
  let nsAddresses;
6
6
  // get all nameservers for the domain
7
7
  const nameservers = await dns.resolveNs(domainName);
@@ -25,5 +25,3 @@ async function hasTxtRecord(domainName, txtRecord) {
25
25
  }
26
26
  return false;
27
27
  }
28
-
29
- module.exports = { hasTxtRecord };
package/dynamodb.js CHANGED
@@ -1,21 +1,35 @@
1
- const { DynamoDB } = require("aws-sdk");
2
- const { getAWSAccessKeyId, getAWSSecretAccessKey, getAWSRegion } = require("./env");
3
- const { wait } = require("./availability");
1
+ import {
2
+ DynamoDBDocumentClient,
3
+ ScanCommand,
4
+ BatchWriteCommand,
5
+ PutCommand,
6
+ QueryCommand,
7
+ UpdateCommand,
8
+ } from "@aws-sdk/lib-dynamodb";
9
+ import { DynamoDBClient, DescribeTableCommand } from "@aws-sdk/client-dynamodb";
10
+ import { getAWSAccessKeyId, getAWSSecretAccessKey, getAWSRegion } from "./env.js";
11
+ import { wait } from "./availability.js";
4
12
 
5
13
  function getDynamoDB() {
6
- return new DynamoDB({
7
- accessKeyId: getAWSAccessKeyId(),
8
- secretAccessKey: getAWSSecretAccessKey(),
14
+ return new DynamoDBClient({
15
+ credentials: {
16
+ accessKeyId: getAWSAccessKeyId(),
17
+ secretAccessKey: getAWSSecretAccessKey(),
18
+ },
9
19
  region: getAWSRegion(),
10
20
  });
11
21
  }
12
22
 
13
23
  function getDocClient() {
14
- return new DynamoDB.DocumentClient({
15
- accessKeyId: getAWSAccessKeyId(),
16
- secretAccessKey: getAWSSecretAccessKey(),
17
- region: getAWSRegion(),
18
- });
24
+ return DynamoDBDocumentClient.from(
25
+ new DynamoDBClient({
26
+ credentials: {
27
+ accessKeyId: getAWSAccessKeyId(),
28
+ secretAccessKey: getAWSSecretAccessKey(),
29
+ },
30
+ region: getAWSRegion(),
31
+ }),
32
+ );
19
33
  }
20
34
 
21
35
  function mergeQueries(q1, q2) {
@@ -35,17 +49,12 @@ async function scanWholeTable(options) {
35
49
  ScannedCount: 0,
36
50
  };
37
51
 
38
- let data = await dynamodb.scan(options).promise();
52
+ let data = await dynamodb.send(new ScanCommand(options));
39
53
 
40
54
  while (data.LastEvaluatedKey) {
41
55
  items = mergeQueries(items, data);
42
56
 
43
- data = await dynamodb
44
- .scan({
45
- ExclusiveStartKey: data.LastEvaluatedKey,
46
- ...options,
47
- })
48
- .promise();
57
+ data = await dynamodb.send(new ScanCommand({ ...options, ExclusiveStartKey: data.LastEvaluatedKey }));
49
58
  }
50
59
 
51
60
  items = mergeQueries(items, data);
@@ -96,8 +105,8 @@ async function batchCreateRecords(tableName, records, maxWritingCapacity, verbos
96
105
  },
97
106
  };
98
107
 
99
- return docClient.batchWrite(params).promise();
100
- })
108
+ return docClient.send(new BatchWriteCommand(params));
109
+ }),
101
110
  );
102
111
 
103
112
  prevRemainingCount = remainingItems.length;
@@ -144,7 +153,7 @@ async function createRecord(tableName, fields, verbose = false) {
144
153
  Item: fields,
145
154
  };
146
155
 
147
- return docClient.put(params).promise();
156
+ return docClient.send(new PutCommand(params));
148
157
  }
149
158
 
150
159
  async function getRecordsByKey(tableName, keys, indexName) {
@@ -167,17 +176,17 @@ async function getRecordsByKey(tableName, keys, indexName) {
167
176
  let data;
168
177
 
169
178
  try {
170
- data = await docClient.query(params).promise();
179
+ data = await docClient.send(new QueryCommand(params));
171
180
 
172
181
  let items = data.Items;
173
182
 
174
183
  while (data.LastEvaluatedKey) {
175
- data = await docClient
176
- .query({
177
- ExclusiveStartKey: data.LastEvaluatedKey,
184
+ data = await docClient.send(
185
+ new QueryCommand({
178
186
  ...params,
179
- })
180
- .promise();
187
+ ExclusiveStartKey: data.LastEvaluatedKey,
188
+ }),
189
+ );
181
190
 
182
191
  items = items.concat(data.Items);
183
192
  }
@@ -247,7 +256,7 @@ async function updateRecordByKey(tableName, idKey, fields, conditionExpressions
247
256
  deleteParams.ConditionExpression = conditionExpressions;
248
257
  }
249
258
 
250
- data = await docClient.update(deleteParams).promise();
259
+ data = await docClient.send(new UpdateCommand(deleteParams));
251
260
  }
252
261
 
253
262
  if (fieldsToUpdate.length > 0) {
@@ -270,7 +279,7 @@ async function updateRecordByKey(tableName, idKey, fields, conditionExpressions
270
279
  params.ConditionExpression = conditionExpressions;
271
280
  }
272
281
 
273
- data = await docClient.update(params).promise();
282
+ data = await docClient.send(new UpdateCommand(params));
274
283
  }
275
284
 
276
285
  return data && data.Attributes;
@@ -291,12 +300,12 @@ async function createTableIfNotExist(
291
300
  },
292
301
  ],
293
302
  otherOptions = {},
294
- verbose = false
303
+ verbose = false,
295
304
  ) {
296
305
  const dynamodb = getDynamoDB();
297
306
 
298
307
  try {
299
- const table = await dynamodb.describeTable({ TableName: tableName }).promise();
308
+ const table = await dynamodb.send(new DescribeTableCommand({ TableName: tableName }));
300
309
 
301
310
  if (verbose) {
302
311
  console.log(`table ${tableName} already exist`, table);
@@ -325,7 +334,7 @@ async function createTableIfNotExist(
325
334
  while (!isCreated) {
326
335
  await wait(5000);
327
336
 
328
- const t = await dynamodb.describeTable({ TableName: tableName }).promise();
337
+ const t = await dynamodb.send(new DescribeTableCommand({ TableName: tableName }));
329
338
 
330
339
  console.log("waiting for table to become active");
331
340
 
@@ -342,15 +351,15 @@ async function batchDeleteRecords(tableName, keys) {
342
351
  for (let start = 0; start < keys.length; start += 25) {
343
352
  const slice = keys.slice(start, start + 25);
344
353
 
345
- await docClient
346
- .batchWrite({
354
+ await docClient.send(
355
+ new BatchWriteCommand({
347
356
  RequestItems: {
348
357
  [tableName]: slice.map((key) => {
349
358
  return { DeleteRequest: { Key: key } };
350
359
  }),
351
360
  },
352
- })
353
- .promise();
361
+ }),
362
+ );
354
363
  }
355
364
  }
356
365
 
@@ -369,7 +378,7 @@ function getIndexKeyName(globalSecondaryIndexes, indexName, type) {
369
378
  async function deleteRecordsByHashKey(tableName, indexName, hashKeyValue, verbose = false) {
370
379
  const docClient = getDocClient();
371
380
 
372
- const meta = await getDynamoDB().describeTable({ TableName: tableName }).promise();
381
+ const meta = await getDynamoDB().send(new DescribeTableCommand({ TableName: tableName }));
373
382
 
374
383
  const hashKeyName = indexName
375
384
  ? getIndexKeyName(meta.Table.GlobalSecondaryIndexes, indexName, "HASH")
@@ -395,7 +404,7 @@ async function deleteRecordsByHashKey(tableName, indexName, hashKeyValue, verbos
395
404
  params.IndexName = indexName;
396
405
  }
397
406
 
398
- let data = await docClient.query(params).promise();
407
+ let data = await docClient.send(new QueryCommand(params));
399
408
 
400
409
  await batchDeleteRecords(
401
410
  tableName,
@@ -407,19 +416,19 @@ async function deleteRecordsByHashKey(tableName, indexName, hashKeyValue, verbos
407
416
  }
408
417
  : {
409
418
  [mainHashKeyName]: item[mainHashKeyName],
410
- }
411
- )
419
+ },
420
+ ),
412
421
  );
413
422
 
414
423
  totalDeleted += data.Items.length;
415
424
 
416
425
  while (data.LastEvaluatedKey) {
417
- data = await docClient
418
- .query({
426
+ data = await docClient.send(
427
+ new QueryCommand({
419
428
  ...params,
420
429
  ExclusiveStartKey: data.LastEvaluatedKey,
421
- })
422
- .promise();
430
+ }),
431
+ );
423
432
 
424
433
  await batchDeleteRecords(
425
434
  tableName,
@@ -431,8 +440,8 @@ async function deleteRecordsByHashKey(tableName, indexName, hashKeyValue, verbos
431
440
  }
432
441
  : {
433
442
  [mainHashKeyName]: item[mainHashKeyName],
434
- }
435
- )
443
+ },
444
+ ),
436
445
  );
437
446
 
438
447
  totalDeleted += data.Items.length;
@@ -445,7 +454,7 @@ async function deleteRecordsByHashKey(tableName, indexName, hashKeyValue, verbos
445
454
  return totalDeleted;
446
455
  }
447
456
 
448
- module.exports = {
457
+ export {
449
458
  getDocClient,
450
459
  scanWholeTable,
451
460
  batchCreateRecords,
package/env.js CHANGED
@@ -51,7 +51,7 @@ function isDev() {
51
51
  return getEnvironment() === "dev";
52
52
  }
53
53
 
54
- module.exports = {
54
+ export {
55
55
  ensureAndGet,
56
56
  getEnvOrThrow,
57
57
  getAWSAccessKeyId,
package/examples/api CHANGED
@@ -7,7 +7,7 @@
7
7
  // $ examples/api deploy
8
8
  // $ examples/api --help
9
9
 
10
- const { api, every, SENSITIVE_VALUE, ERROR_LEVEL } = require("../app");
10
+ import { api, every, SENSITIVE_VALUE, ERROR_LEVEL } from "../app";
11
11
 
12
12
  // an example middleware
13
13
  async function exampleMiddleware(req, res, next) {
package/examples/consumer CHANGED
@@ -8,7 +8,7 @@
8
8
  // $ examples/consumer deploy --protocol eth
9
9
  // $ examples/consumer --help
10
10
 
11
- const { consumer, every, ERROR_LEVEL } = require("../app");
11
+ import { consumer, every, ERROR_LEVEL } from "../app";
12
12
 
13
13
  async function consume({ protocol, messages, verbose }) {
14
14
  console.log("consume called with", protocol, messages, verbose);
package/examples/indexer CHANGED
@@ -8,7 +8,7 @@
8
8
  // $ examples/indexer deploy --protocol eth
9
9
  // $ examples/indexer --help
10
10
 
11
- const { indexer, every, ERROR_LEVEL } = require("../app");
11
+ import { indexer, every, ERROR_LEVEL } from "../app";
12
12
 
13
13
  async function build({ protocol, verbose }) {
14
14
  console.log("build called with", protocol, verbose);
@@ -41,8 +41,8 @@ const app = indexer({
41
41
  // for more flags check meow documentation at https://github.com/sindresorhus/meow
42
42
  protocol: {
43
43
  type: "string",
44
- description: "which chain to index"
45
- }
44
+ description: "which chain to index",
45
+ },
46
46
  },
47
47
 
48
48
  env: {},
@@ -9,7 +9,7 @@
9
9
  // $ examples/mode-indexer deploy --protocol eth
10
10
  // $ examples/mode-indexer --help
11
11
 
12
- const { modeIndexer, every, SENSITIVE_VALUE } = require("../app");
12
+ import { modeIndexer, every, SENSITIVE_VALUE } from "../app";
13
13
 
14
14
  async function build({ protocol, from, to, verbose }) {
15
15
  console.log("build called with", protocol, from, to, verbose);