Skip to content

Backend (/src/api)

The backend is where the actual magic happens! The frontend can be considered a thin-client application: there is very little code and needs the backend application to function properly.

The backend application uses the Express NPM package to expose multiple API endpoints for the frontend to consume. When the application starts, it will load src/index.ts, which in turn will load src/routes.ts. After this point, other routes.ts files will be loaded to expose the actual API endpoints.

One of those routes.ts files is found under src/game-implementation, which exposes API endpoints the CanvasComponent of the frontend project uses. It’s important to note that a routes.ts-file is just the “glue” between Express and the actual API endpoint logic. API endpoint logic is always defined in a Controller-class, which will then use one or more services to create an appropriate response for the incoming request.