Skip to content

vu-bui/apollo-react-template

Repository files navigation

Apollo React Template

MIT-licensed template for scaffolding self-contained NodeJS web server backed by MongoDB with both GraphQL and Swagger endpoints. Tech stack usage are

Features

  • Expose a configrable /graphql endpoint that support both HTTP and WebSocket requests. Subscriptions are also supported.
  • A configurable Swagger descriptor endpoint at /api/swagger and all other RESTful APIs that acts as a compatible proxy to GraphQL resolvers.
  • A web UI built on React and Apollo that is packaged to the server on build. The UI is styled using Material UI and JSS.
  • A build system that supports building to a self-contained NodeJS web server with appropriate versioning that can run natively or inside Docker container.
  • Docker Compose files that support starting a Docker stack of the application.
  • A Jenkins pipeline that is suitable to build the application as well as a Docker Compose file to start the sustainable Jenkins server.
  • Visual Studio Code support.

Getting Started

Required Software

  • MongoDB 4+ with replica set. If no replica set is set up, subscription won't work because it's built based on replica set oplog. Starting the system in cluster mode might also need it as a communication channel, depends on how we code.
  • NodeJS 12+
  • Visual Studio Code for development.
  • Docker for hosting Jenkins and building docker distributions

Development Configurations

Create a file in root directory and name it .env and override any configurations in .env.example as needed.

Commands

  • Install dependencies
npm i
  • Start API development web server
npm run dev
  • Start UI development server
cd ui
npm run dev
  • Build the source code (can optionally set VERSION environment variable to mark the version for the package)
npm run build
  • Produce distribution package for the current host OS
npm run dist
  • Populate seed data
npm run db:seed
  • Clean up all data
npm run db:reset

Setting Up IDE

Install the following Visual Studio Code plugins

Debug the API server by pressing F5 or go to Debug > Start Debugging.

Setting Up Jenkins

  • Install Docker
  • Start or join a Docker swarm
docker swarm init
  • Run the following command
cd docker-compose
docker stack deploy -c docker-compose.ci.yml ci
  • Go to the Jenkins server at port 8080 and add new Multibranch Pipeline project using the project's Git URL.

Documentation

Please read here.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published