import express from 'express';
import router from './server/router/index';
import cors from 'cors';

const PORT = process.env.PORT || 3000;
const app = express();

app.use(cors());

app.use('/static', express.static('public'));
app.use(express.json());
app.use('/api', router);
app.use(
    (err, req, res, next) => {
        if(!err.status){
            res.status(500).send(err);
        }
        else {
            res.status(err.status).send(err);
        }
});

app.listen(PORT);


