The "general purpose API", is the second verion of a back-end REST API I build with no clear single purpose.
It is used for user management, everything related to the activity logger as well as the leaderboard for ISTIT.
First and foremost, the API is setup to run as an Azure Function App. As of writing, all of the existing functions (located within src/functions/) are HTTP triggers, which means they respond to REST calls through their respective endpoints.
In regard to communicating with the database, Prisma is used.
I am currently running a PostgreSQL server, but since this layer of direct communication with the database is abstracted away through Prisma, essentially any SQL-capable database could be used.
The package tsup is used for building the project both in local development and for production.
Each endpoint contains its own entry file in the src/functions/ directory. The file name is usally a reflection of the path name that is used when calling the endpoint. Endpoints can be configured to be called through any number of HTTP methods.
For example, the endpoint:
src/functions/action.ts
... provides handling for GET, POST, PUT and DELETE methods.
As Prisma is the backbone in which the database layer is built upon, consult their documentation which is a lot more thorough than anything I would be able to cover here: https://www.prisma.io/docs/orm/prisma-migrate/getting-started
Every time a model (in schema.prisma) is changed, Prisma needs a new migration. Each migration should have a name. Assuming we want to call a new migration "added-user-field". we would run the following command:
npx prisma migration dev --name "added-user-field"