Structure
Folder Structure
src- Containsserver.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 ourpackage.json.controllers- Contains "controllers" which are scripts or folders of scripts that perform certain functionality. This is a more structured version ofutilsandmiscfolders.generated- Auto-generated code based on our GraphQL schemagraphql- Contains the GraphQL schema defined in TypeScriptmiddlewares- Middleware for Typettamisc- Contains miscellaneous helper coderoutes- 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 frontendsutils- 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 TypeScripttypetta.yml- Configuration for Typetta
NodeJS Scripts
start- Runs the built backend from thedistfolder.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 thedist/_toolsfoldermock: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/generatedfolder.
- 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
tools:recompile- Recompiles the backend and runs it in tool modegenerate- Generates Typetta and GraphQL typings.generate:typetta- Generates Typetta typings.generate:graphql-endpoint- Generates typings for our GraphQL endpoint.compile:app- Cleans thedistdirectory and recompiles the backend.compile:tools- Cleans thedistdirectory and recompile the backend in tool mode, which basically includes thesrc/_toolsfolder in the final build.tidy uploads- Removes unused user-uploaded images and assets from theuploadsfolder.clean- Deletes thedistdirectorybuild- Cleans thedistdirectory, regenerates the autogenerated code, and then recompiles the backend.pretty- Run the prettier formatter on the TypeScript files withinsrc.
Note
To run a NodeJS script you have to run the follow code inside the repository's directory.
> npm run script_name