// Add simple, fast, scalable persistence: https://docs.begin.com/en/data/begin-data/
// let data = require('@begin/data')

// Add secure sessions, middleware, and more: https://docs.begin.com/en/functions/http/
// let arc = require('@architect/functions')

// TODO: modify the body object!
let body = `
<!doctype html>
<html lang=en>
  <head>
    <meta charset=utf-8>
    <title>Hi!</title>
     </head>
  <body>

  

    <h1 class="center-text">
      <!-- ↓ Change "Hello world!" to something else and head on back to Begin! -->
      Welcome to TVDL
    </h1>
    <!--
    <p class="center-text">
      Your <a href="https://begin.com" class="link" target="_blank">Begin</a> app is ready to go!
    </p>
    -->

  </body>
</html>
`;

// exports.handler = async function http(req) {
//   return {
//     headers: {
//       "content-type": "text/html; charset=utf8",
//       "cache-control":
//         "no-cache, no-store, must-revalidate, max-age=0, s-maxage=0",
//     },
//     body,
//   };
// };

// Example responses

// Forward requester to a new path
exports.handler = async function http(req) {
  return {
    statusCode: 301,
    headers: { location: "https://www.tvdl.app" },
  };
};

/* Respond with successful resource creation, CORS enabled
let arc = require('@architect/functions')
exports.handler = arc.http.async (http)
async function http (req) {
  return {
    statusCode: 201,
    headers: {'content-type': 'application/json; charset=utf8'},
    body: JSON.stringify({ok: true}),
    cors: true,
  }
}
*/

/* Deliver client-side JS
exports.handler = async function http (req) {
  return {
    headers: {'content-type': 'text/javascript; charset=utf8'},
    body: 'console.log("Hello world!")',
  }
}
*/
