Files
badgedex/src/index.js
T
2026-07-17 13:55:39 +02:00

28 lines
777 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
require('dotenv').config();
const express = require('express');
const helmet = require('helmet');
const logger = require('./lib/logger');
const api = require('./api');
const version = require('./lib/version').version();
const app = express();
const PORT = process.env.PORT || 3000;
app.use(helmet({
crossOriginResourcePolicy: false,
}));
app.use('/', api.router);
// Central error handler catches all unhandled errors
// eslint-disable-next-line no-unused-vars
app.use((err, req, res, next) => {
logger.error({ err, url: req.url }, 'Unhandled error');
res.status(err.status || 500).json({ error: err.message || 'Internal Server Error' });
});
app.listen(PORT, () => {
logger.info(`BadgeDex version ${version} listening on http://localhost:${PORT}/`);
});