Skip to content

Latest commit

 

History

History
44 lines (30 loc) · 2 KB

README.md

File metadata and controls

44 lines (30 loc) · 2 KB

Backend

日本語

Backend for wsnet2-dashboard. It provides APIs of GraphQL and GRPC for the dashboard.

Environment variables

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"

Build the application

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.

About the GraphQL

The ORM being used is Prisma.

  • 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.
  • GraphQL APIs available to Apollo server is implemented at src/types.

About the gRPC

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)