import express from 'express';
import Manager from './Manager.js';

const app = express();
const appManager = new Manager();

app.get('/api/lastmatch', async function(req, res) {
    if (!req.query.name) {
        return res.status(400).send();
    }

    try {
        const results = await appManager.getInfo(req.query.name);
        res.send(results);
    } catch (e) {
        console.error(e);
        return res.status(503).send();
    }
});

app.listen('80', async function() {
    console.log(`server listening on 80`);
});
