import express from "express"; import { config } from "dotenv"; import path from "path"; const __dirname = import.meta.dirname; const app = express(); app.set('view engine', 'ejs'); app.use('/assets', express.static('assets')); app.set('views', path.join(__dirname, "views", "pages")); app.locals = { visibility: [ "Backend", "Personal", "Friends-only", "Login-only", "Public" ] } config(); app.use(async (req, res, next) => { const buttonsJson = await fetch("https://cdn.abtmtr.link/site_content/buttons.json") .catch(() => res.status(500).send()) .then((res) => res.json()); app.locals.buttons = buttonsJson; next(); }) app.get('/', async (req, res) => { const statusesJson = await fetch("https://cdn.abtmtr.link/site_content/v13/statuses.json") .catch(() => res.status(500).send()) .then((res) => res.json()); res.render('index', { statuses: statusesJson }); }) app.get('/services', async (req, res) => { const servicesJson = await fetch("https://cdn.abtmtr.link/site_content/v13/services.json") .catch(() => res.status(500).send()) .then((res) => res.json()); res.render('services/index', { services: servicesJson }); }); app.get('/computers', async (req, res) => { const computersJson = await fetch("https://cdn.abtmtr.link/site_content/v13/computers.json") .catch(() => res.status(500).send()) .then((res) => res.json()); res.render('computers/index', { computers: computersJson }); }); app.get('/links', async (req, res) => { const linksJson = await fetch("https://cdn.abtmtr.link/site_content/v13/links.json") .catch(() => res.status(500).send()) .then((res) => res.json()); res.render('links/index', { links: linksJson }); }); app.get('/matkap', (req, res) => { res.render('matkap/index'); }); app.get('/about', (req, res) => { res.render('about/index'); }); app.get("/favicon.ico", (req, res) => { res.redirect("https://cdn.abtmtr.link/site_content/favicon.ico") }) app.listen(process.env.PORT, () => { const url = new URL("http://localhost/"); url.port = process.env.PORT; console.log(`Example app listening on ${url.toString()}`); });