active-db.ts

import { apiPrefix } from '../../utility/constants/app';
import { getActiveDb, setActiveDb } from '../fetch/active-db';

export default async function activeDbEndpoint(app) {
  app.put(`${apiPrefix}/active-db/set`, async (req, res) => {
    // NOTE: pass referer to switch between envirnments
    const result = await setActiveDb(req);
    res.json({
      ...result,
      message: 'ok'
    });
  });

  app.get(`${apiPrefix}/active-db/get`, async (req, res) => {
    // NOTE: pass referer to switch between envirnments
    const result = await getActiveDb(req);
    res.json({
      ...result,
      message: 'ok'
    });
  });
}