The backend (server) is a program that runs on node.js (or similar) written in TypeScript.
It uses express as an HTTP library, socket.io as a WebSockets library, and mikro-orm as an ORM library.
The minimal necessary index.ts
file for your server project is:
import 'reflect-metadata';
import { AocServer } from '@atlantis-of-code/aoc-server';
require('express-async-errors');
const aocServer = new AocServer();
aocServer.listen();
And in this other example (Quest), we expand its use a bit:
import 'reflect-metadata';
import { AocReport, AocServer } from '@atlantis-of-code/aoc-server';
import Big from 'big.js';
import * as dateFns from 'date-fns';
import { FileRouter } from './routers/file.router';
AocReport.globalLocals.dateFns = dateFns;
AocReport.globalLocals.numberFormat = new Intl.NumberFormat('de-DE', { minimumFractionDigits: 2, maximumFractionDigits: 2 }).format;
AocReport.globalLocals.Big = Big;
require('express-async-errors');
const aocServer = new AocServer({
customRouters: [
{
path: '/file',
router: new FileRouter().router,
checkAuth: true
}
]
});
aocServer.listen();
See the full example at quest-server/src/index.ts
Complete definition in the API.
Please note, browse Issues and Discussions in Github for more information