Skip to content

Structure

Folder Structure

  • src - Contains
    • server.ts - The entry point of the backend. It reads the command line arguments or environment variables to start a server in development or production mode.
    • config - Stores config files that change how the backend runs. See the Config section for more information
    • _tools - Contains code used by Node.JS scripts defined in our package.json.
    • controllers - Contains "controllers" which are scripts or folders of scripts that perform certain functionality. This is a more structured version of utils and misc folders.
    • generated - Auto-generated code based on our GraphQL schema
    • graphql - Contains the GraphQL schema defined in TypeScript
    • middlewares - Middleware for Typetta
    • misc - Contains miscellaneous helper code
    • routes - Contains all the routes in the backend. Note that accessing data is done by Apollo server's GraphQL endpoint, rather than through manually configured routes.
    • shared - Code that's shared between the backend and frontends
    • utils - Utility code.
  • dist - Where the release version of the backend is stored once you build it.
  • gulpfile.js - Script that automates copying assets over when you build the backend.
  • rucogs.service - Service file for hosting backend. See DevOps/Hosting for more information.
  • tsconfig.json - Configuration for TypeScript
  • typetta.yml - Configuration for Typetta

NodeJS Scripts

  • start - Runs the built backend from the dist folder.
  • start:recompile - Compiles the backend and then runs it.
  • start:rebuild - Regenerates and recompiles the backend, and then runs it.
  • mock - Runs a mock server with dummy data from the dist/_tools folder
  • mock:recompile - Recompiles the backend and runs it with dummy data.
  • tools - Runs the server in tool mode
    • Tool mode is used at the moment to automatically generate a GraphQL TypeScript typings from the running Apollo server. The generated files are placed under the src/generated folder.
  • tools:recompile - Recompiles the backend and runs it in tool mode
  • generate - Generates Typetta and GraphQL typings.
  • generate:typetta - Generates Typetta typings.
  • generate:graphql-endpoint - Generates typings for our GraphQL endpoint.
  • compile:app - Cleans the dist directory and recompiles the backend.
  • compile:tools - Cleans the dist directory and recompile the backend in tool mode, which basically includes the src/_tools folder in the final build.
  • tidy uploads - Removes unused user-uploaded images and assets from the uploads folder.
  • clean - Deletes the dist directory
  • build - Cleans the dist directory, regenerates the autogenerated code, and then recompiles the backend.
  • pretty - Run the prettier formatter on the TypeScript files within src.

Note

To run a NodeJS script you have to run the follow code inside the repository's directory.

> npm run script_name