Files
the-sunken-reach/backend/src/app.js
T
joshuaandClaude Opus 5.5 18d9e7301c V1.23.0: every subclass, 43 species, the Artificer, and the road to level 20
- All 123 official subclasses (2014 books and the 2024 Player's Handbook), each
  with its book and features up to level 20; one file per class
- The builder has a subclass step after the class: pick one, let a die suggest
  one, or decide later; its gifts arrive at the class's choice level
- 2024 updates (Wild Heart, Warrior of the Elements) offer a one-click switch
- The Road Ahead: a level 1-20 timeline on every sheet and in the builder
- 33 new species (2024 Aasimar and Goliath, Monsters of the Multiverse) with
  chosen +2/+1 or +1/+1/+1 bonuses; species roll is now a d8 by family
- The Artificer: class, half-caster slots from level 1, features, Flash of Genius
- Class tables and counters run to level 20; a fifth Boon, Resolve

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-11 16:02:51 +02:00

49 lines
1.8 KiB
JavaScript

const express = require('express');
const cors = require('cors');
const compression = require('compression');
const authRoutes = require('./routes/auth.routes');
const campaignsRoutes = require('./routes/campaigns.routes');
const charactersRoutes = require('./routes/characters.routes');
const encountersRoutes = require('./routes/encounters.routes');
const notesRoutes = require('./routes/notes.routes');
const referenceRoutes = require('./routes/reference.routes');
function createApp() {
const app = express();
// The site and the API are on different hosts, so a browser asks leave
// before each kind of request. maxAge lets it remember the answer (browsers
// cap it at two hours) and not ask again every time.
app.use(cors({ origin: process.env.CORS_ORIGIN || 'http://localhost:5173', maxAge: 7200 }));
// Nothing in front of the API compresses for it (frp only tunnels), so the
// JSON is gzipped here.
app.use(compression());
app.use(express.json());
app.get('/health', (req, res) => res.json({ ok: true }));
app.use('/auth', authRoutes);
app.use('/campaigns', campaignsRoutes);
app.use('/characters', charactersRoutes);
app.use('/encounters', encountersRoutes);
app.use('/notes', notesRoutes);
app.use('/reference', referenceRoutes);
app.use((req, res) => {
res.status(404).json({ error: 'Not found' });
});
// eslint-disable-next-line no-unused-vars
app.use((err, req, res, next) => {
console.error(err);
if (err.code === 'P2025') return res.status(404).json({ error: 'Record not found' });
if (err.code === 'P2002') return res.status(409).json({ error: 'A record with that value already exists' });
res.status(500).json({ error: 'Internal server error' });
});
return app;
}
module.exports = { createApp };