All files / lib/mainFn index.ts

66.66% Statements 6/9
100% Branches 0/0
0% Functions 0/2
62.5% Lines 5/8

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32    5x 5x   5x       5x                     5x                      
import * as T from "../types"
import { Daemons } from "./Daemons"
import "../interfaces/ServiceInterfaceBuilder"
import "../interfaces/Origin"
 
import "./Daemons"
 
import { MainEffects } from "../StartSdk"
 
export const DEFAULT_SIGTERM_TIMEOUT = 30_000
/**
 * Used to ensure that the main function is running with the valid proofs.
 * We first do the folowing order of things
 * 1. We get the interfaces
 * 2. We setup all the commands to setup the system
 * 3. We create the health checks
 * 4. We setup the daemons init system
 * @param fn
 * @returns
 */
export const setupMain = <Manifest extends T.Manifest, Store>(
  fn: (o: {
    effects: MainEffects
    started(onTerm: () => PromiseLike<void>): PromiseLike<void>
  }) => Promise<Daemons<Manifest, any>>,
): T.ExpectedExports.main => {
  return async (options) => {
    const result = await fn(options)
    return result
  }
}