Backend for wsnet2-dashboard.
It provides APIs of GraphQL
and GRPC
for the dashboard.
Name | Description | Example |
---|---|---|
SERVER_PORT | Port of the dashboard's server | "5555" |
DATABASE_URL | Database uri(including database name and password) | "mysql://wsnet:wsnetpass@localhost:3306/wsnet2" |
FRONTEND_ORIGIN | IP address of the dashboard frontend(for CORS) | "http://localhost:3000" |
GRAPHQL_RESULT_MAX_SIZE | The maximum number of results returned by a GraphQL query | "1000" |
It is necessary to start db
, as the schema is generated from the database.
docker compose -f server/compose.yaml up -d db
cd wsnet2-dashboard
docker compose run --rm backend make
The built code will be stored at wsnet2-dashboard/backend/dist
.
- GraphQL schema auto generation:
- Set the database uri in
.env
. - Run
npm run generate
at the backend's root directory. - Auto generated schema is stored at
prisma/schema.prisma
.
- Set the database uri in
- GraphQL APIs available to Apollo server is implemented at
src/types
.
The gRPC communication with wsnet2-server is carried out at the backend. The dashboard and the backend communicates through REST API(using application/msgpack
).
gRPC codes is generated by make
automatically.
(generated from server/pb/*.proto
and stored under wsnet2-dashboard/backend/src/pb
)