text: 'use strict';
  
  const express = require('express');
  const router = express.Router();
  
  const config = require("../database/config");
  const CosmosClient = require("@azure/cosmos").CosmosClient;
  
  const { endpoint, key, databaseId, containerId } = config;
  const client = new CosmosClient({ endpoint, key });
  
  const Database = require('../database/database');
  const database = new Database(client, databaseId, containerId);
  
  router.get('/', async (req, res) => {
      await database.init();
  
      try {
          res.json(await database.getAll());
      }
      catch(err) {
          res.json(err)
      }
  });
  
  router.post('/', async (req, res) => {
  
      var fs = require('fs');
      var discos = JSON.parse(fs.readFileSync('./routes/discos.json', 'utf8'));
  
      for(let club of discos)
      {
          console.log(club);
      }
  
      res.status(200).send({
          msg: 'created!'
      });
  });
  
  router.delete('/', async (req, res) => {
      var id = req.body.id;
  
      let message = "Deleted!";
  
      try {
          await database.dropData(id);
      }
      catch(err) {
          message = err;
      }
  
      res.status(200).send({
          msg: message
      });
  });
  
  router.put('/', async (req, res) => {
      res.status(200).send({
          msg: 'updated!'
      });
  });
  
  module.exports = router;