async function appInit() {
  try {
    log.info({}, "To appInit");
    /** Step 1: Check if account's initial flag is true, if it is run the following; If not, return false for now */
    const account = await findOneAccountByUserId(ADMIN_USER_ID);
    if (!account || account.isInitial === "0") {
      log.info({}, "Has appInit");
      return Promise.resolve(false);
    }
    const hasSync = await intitalFilesSyncSpawn();
    if (hasSync) await updateAccountByUserId(ADMIN_USER_ID, { isInitial: "0" });
    log.info({}, "Has appInit");
    return Promise.resolve(true);
  } catch (err) {
    throw new Error(`Error occurs in controller init: ${err.message}`);
  }
}
/** App run first time
 * 1. Scan all files in local repo
 * 2. Save all files metadata to DB
 * 3. Upload to S3
 */
App run first time
1. Scan all files in local repo
2. Save all files metadata to DB
3. Upload to S3
App run first time 1 . Scan all files in local repo 2 . Save all files metadata to DB 3 . Upload to S3
async function appInit() {
  try {
    log.info({}, "To appInit");
    const account = await findOneAccountByUserId(ADMIN_USER_ID);
    if (!account || account.isInitial === "0") {
      log.info({}, "Has appInit");
      return Promise.resolve(false);
    }
    const hasSync = await intitalFilesSyncSpawn();
    if (hasSync) await updateAccountByUserId(ADMIN_USER_ID, { isInitial: "0" });
    log.info({}, "Has appInit");
    return Promise.resolve(true);
  } catch (err) {
    throw new Error(`Error occurs in controller init: ${err.message}`);
  }
}
async function appInit ( ) { try { log . info ( { } , "To appInit" ) ; const account = await findOneAccountByUserId ( ADMIN_USER_ID ) ; if ( ! account || account . isInitial === "0" ) { log . info ( { } , "Has appInit" ) ; return Promise . resolve ( false ) ; } const hasSync = await intitalFilesSyncSpawn ( ) ; if ( hasSync ) await updateAccountByUserId ( ADMIN_USER_ID , { isInitial : "0" } ) ; log . info ( { } , "Has appInit" ) ; return Promise . resolve ( true ) ; } catch ( err ) { throw new Error ( ` ${ err . message } ` ) ; } }
App run first time
 1.
App run first time 1 .
/** Step 1: Check if account's initial flag is true, if it is run the following; If not, return false for now */