import express from 'express'; import morgan from "morgan"; import { getLocationOfTarget } from './app.service'; const port = Number(process.env.PORT) || 3000; const app = express(); app.use(morgan('common')) app.get('/*', async (req, res) => { const target = req.url.slice(1); const location = await getLocationOfTarget(target); if (location) { res.redirect(location); } else { res.sendStatus(404); } }); app.listen(port, () => { console.log(`Now listening on port ${port}!`); });