import { ApphouseStore } from '../context/ApphouseStore';
import { IStoreWithBase } from '../context/context.interface';
import { defineRoutes } from './routing/defineRoutes';
import { Route } from './routing/route.interface';

export function initApphouse<S>(routes?: Route[], store?: IStoreWithBase<S>) {
  let _store = store as IStoreWithBase<S>;
  if (!_store) {
    // let's create a store if one isn't provided
    _store = new ApphouseStore('apphouse') as unknown as IStoreWithBase<S>;
  }
  return defineRoutes(routes || [], _store);
}
