### Run the app with yarn Source: https://github.com/ayaka-notes/ayakaleaf-pro/blob/server-pro/services/web/README.md Install dependencies and start the app natively using yarn and Node. ```bash $ yarn install $ yarn run start ``` -------------------------------- ### Start services with bin/up Source: https://github.com/ayaka-notes/ayakaleaf-pro/blob/server-pro/develop/README.md Starts the services after building. Once running, open http://localhost/launchpad to create the first admin account. ```shell bin/up ``` -------------------------------- ### Build and start base container Source: https://github.com/ayaka-notes/ayakaleaf-pro/blob/server-pro/server-ce/hotfix/5.5.3/NOTES.md Builds the base Docker image and starts a container with a bash entrypoint, naming it 'new'. This is the first step to prepare the environment for patching. ```bash docker build -t base . CONTAINER_NAME=new # Start the container docker run -t -i --entrypoint /bin/bash --name $CONTAINER_NAME base ``` -------------------------------- ### Run project-history with yarn Source: https://github.com/ayaka-notes/ayakaleaf-pro/blob/server-pro/services/project-history/README.md Install dependencies and start the project-history service locally using yarn and Node. ```bash yarn install yarn run start ``` -------------------------------- ### Example compile request (JSON5) Source: https://github.com/ayaka-notes/ayakaleaf-pro/blob/server-pro/services/clsi/README.md JSON5 example of a compile request to POST /project//compile. Includes compiler options, rootResourcePath, and resources array. Comments are not valid JSON. ```json5 { compile: { options: { // Which compiler to use. Can be latex, pdflatex, xelatex or lualatex compiler: 'lualatex', // How many seconds to wait before killing the process. Default is 60. timeout: 40, }, // The main file to run LaTeX on rootResourcePath: 'main.tex', // An array of files to include in the compilation. May have either the content // passed directly, or a URL where it can be downloaded. resources: [ { path: 'main.tex', content: '\\documentclass{article}\n\\begin{document}\nHello World\n\\end{document}', }, // ,{ // "path": "image.png", // "url": "www.example.com/image.png", // "modified": 123456789 // Unix time since epoch // } ], }, } ``` -------------------------------- ### Run E2E tests with make commands Source: https://github.com/ayaka-notes/ayakaleaf-pro/blob/server-pro/server-ce/test/README.md Run from server-ce/test/toolkit. Installs and starts Overleaf, runs the launchpad tests, then cleans up. Use OVERLEAF_PORT and OVERLEAF_IMAGE environment variables to customize. ```sh make setup SUITE=launchpad # install and start Overleaf make test_launchpad # run the launchpad tests make clean # remove everything again ``` -------------------------------- ### Install dependencies for native install Source: https://github.com/ayaka-notes/ayakaleaf-pro/blob/server-pro/services/git-bridge/README.md Install Maven and OpenJDK 8 on a Debian-based system and set them as the default alternatives. ```bash sudo apt-get update sudo apt-get install -y maven sudo apt-get install -y openjdk-8-jdk sudo update-alternatives --set java /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java sudo update-alternatives --set javac /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/javac ``` -------------------------------- ### Run specific services in development mode with bin/dev Source: https://github.com/ayaka-notes/ayakaleaf-pro/blob/server-pro/develop/README.md Starts only the specified subset of services in development mode. Provide a space-separated list of service names. Note: starting the web service only updates backend code; start webpack as well to update frontend code. ```shell bin/dev [service1] [service2] ... [serviceN] ``` -------------------------------- ### Run unit tests with make Source: https://github.com/ayaka-notes/ayakaleaf-pro/blob/server-pro/services/project-history/README.md Install dependencies once and run unit tests in the test_unit Docker container. ```makefile make install # Only needs running once, or when yarn packages are updated make test_unit ``` -------------------------------- ### Run acceptance tests with make Source: https://github.com/ayaka-notes/ayakaleaf-pro/blob/server-pro/services/project-history/README.md Install dependencies once and run acceptance tests against a live service in the acceptance_test container. ```makefile make install # Only needs running once, or when yarn packages are updated make test_acceptance ``` -------------------------------- ### Example compile response (JSON) Source: https://github.com/ayaka-notes/ayakaleaf-pro/blob/server-pro/services/clsi/README.md Example JSON response from a successful compile, containing status and outputFiles with URLs for the PDF and log. ```json { "compile": { "status": "success", "outputFiles": [ { "type": "pdf", "url": "http://localhost:3013/project//output/output.pdf" }, { "type": "log", "url": "http://localhost:3013/project//output/output.log" } ] } } ``` -------------------------------- ### Complete Script Runner Example with Progress Tracking Source: https://github.com/ayaka-notes/ayakaleaf-pro/blob/server-pro/services/web/scripts/lib/README.md Shows the full usage of scriptRunner: import the utility, define an async main function that accepts trackProgress, pass variables, and handle success/error with process.exit. The example simulates sub-jobs with delays and logs progress messages. ```javascript // Import the script runner utility (adjust the path as needed) import { scriptRunner } from './lib/ScriptRunner.mjs' const subJobs = 30 /** * Your script's main work goes here. * It must be an async function and accept `trackProgress`. * @param {(message: string) => void} trackProgress - Call this to log progress. */ async function main(trackProgress) { for (let i = 0; i < subJobs; i++) { await new Promise(resolve => setTimeout(() => resolve(), 1000)) await trackProgress(`Job in progress ${i + 1}/${subJobs}`) } await trackProgress('Job finished') } // Define any variables your script needs (optional) const scriptVariables = { subJobs, } // --- Execute the script using the runner with async/await --- try { await scriptRunner(main, scriptVariables) process.exit() } catch (error) { console.error(error) process.exit(1) } ``` -------------------------------- ### Run all services in development mode with bin/dev Source: https://github.com/ayaka-notes/ayakaleaf-pro/blob/server-pro/develop/README.md Starts all services in development mode using node --watch, which automatically restarts services on code changes. If no services are named, all services start. ```shell bin/dev ``` -------------------------------- ### Run acceptance tests with service lifecycle commands Source: https://github.com/ayaka-notes/ayakaleaf-pro/blob/server-pro/services/web/README.md During development, start the service, run tests repeatedly, and stop the service. ```bash make test_acceptance_app_start_service make test_acceptance_app_run # Run as many times as needed during development make test_acceptance_app_stop_service ``` -------------------------------- ### Output: Stack trace without call-site context Source: https://github.com/ayaka-notes/ayakaleaf-pro/blob/server-pro/libraries/o-error/README.md Example output of the error from the previous snippet, showing the stack trace starts at `process.nextTick` and does not mention `sayHi1`. ```text Error: not found at process.nextTick (repl:8:18) at process._tickCallback (internal/process/next_tick.js:61:11) ``` -------------------------------- ### Run acceptance tests with service running Source: https://github.com/ayaka-notes/ayakaleaf-pro/blob/server-pro/services/project-history/README.md Leave the service running for rapid iteration on acceptance tests: start the service, run tests as needed, then stop the service. ```makefile make test_acceptance_start_service make test_acceptance_run # Run as many times as needed during development make test_acceptance_stop_service ``` -------------------------------- ### Run all migrations in dev-env Source: https://github.com/ayaka-notes/ayakaleaf-pro/blob/server-pro/tools/migrations/README.md Runs all migrations in the dev-env using make. Note: `make install` will also pick them up. ```shell make services/web/migrate # Note: "make install" will pick them up as well ``` -------------------------------- ### Run Lezer-LaTeX parser on a file Source: https://github.com/ayaka-notes/ayakaleaf-pro/blob/server-pro/services/web/frontend/js/features/source-editor/lezer-latex/README.md Run the parser against a specific example file. If the file path is omitted, the default file (examples/demo.tex) will be run. ```sh bin/yarn -w services/web run 'lezer-latex:run' web/test/unit/src/LezerLatex/examples/amsmath.tex ``` -------------------------------- ### Example doc export output Source: https://github.com/ayaka-notes/ayakaleaf-pro/blob/server-pro/services/web/scripts/delete-orphaned-docs/README.md Example output of the doc export command. Shows the CSV format with _id and project_id columns. The script accepts either plain hex strings or the ObjectId(...) format. ```csv _id,project_id ObjectId(5babb6f864c952737a9a4c32),ObjectId(5b98bba5e2f38b7c88f6a625) ObjectId(4eecaffcbffa66588e000007),ObjectId(4eecaffcbffa66588e00000d) ``` -------------------------------- ### LaTeX itemize list example Source: https://github.com/ayaka-notes/ayakaleaf-pro/blob/server-pro/services/web/public/static/latex/learn/free-online-introduction-to-latex-part-1.pdf Creates a bulleted list with three items: Tea, Milk, and Biscuits. ```latex \begin{itemize} \item Tea \item Milk \item Biscuits \end{itemize} ``` -------------------------------- ### Start the CLSI Docker container Source: https://github.com/ayaka-notes/ayakaleaf-pro/blob/server-pro/services/clsi/README.md Runs the CLSI container with necessary environment variables and volume mounts. On macOS, use -v /var/run/docker.sock.raw:/var/run/docker.sock instead. ```shell docker run --rm \ -p 127.0.0.1:3013:3013 \ -e LISTEN_ADDRESS=0.0.0.0 \ -e SANDBOXED_COMPILES=true \ -e TEXLIVE_IMAGE=texlive/texlive \ -e TEXLIVE_IMAGE_USER=root \ -e SANDBOXED_COMPILES_HOST_DIR_COMPILES="$PWD/compiles" \ -v "$PWD/compiles:/overleaf/services/clsi/compiles" \ -v "$PWD/cache:/overleaf/services/clsi/cache" \ -v /var/run/docker.sock:/var/run/docker.sock \ --name clsi \ overleaf/clsi ``` -------------------------------- ### Runtime configuration JSON format Source: https://github.com/ayaka-notes/ayakaleaf-pro/blob/server-pro/services/git-bridge/README.md Example configuration file format for the git-bridge server. Includes port, git directory, API base URL, optional HTTP basic auth, postback URL, service name, OAuth2 server, repo store, swap store, and swap job settings. Restart the server for changes to take effect. ```json { "port" (int): the port number, "rootGitDirectory" (string): the directory in which to store git repos and the db/atts, "apiBaseUrl" (string): base url for the snapshot api, "username" (string, optional): username for http basic auth, "password" (string, optional): password for http basic auth, "postbackBaseUrl" (string): the postback url, "serviceName" (string): current name of writeLaTeX in case it ever changes, "oauth2Server" (string): oauth2 server, with protocol and without trailing slash, null or missing if oauth2 shouldn't be used }, "repoStore" (object, optional): { configure the repo store "maxFileSize" (long, optional): maximum size of a file, inclusive }, "swapStore" (object, optional): { the place to swap projects to. if null, type defaults to "noop" "type" (string): "s3", "memory", "noop" (not recommended), "awsAccessKey" (string, optional): only for s3, "awsSecret" (string, optional): only for s3, "s3BucketName" (string, optional): only for s3 }, "swapJob" (object, optional): { configure the project swapping job. if null, defaults to no-op "minProjects" (int64): lower bound on number of projects present. The swap job will never go below this, regardless of what the watermark shows. Regardless, if minProjects prevents an eviction, the swap job will WARN, "lowGiB" (int32): the low watermark for swapping, i.e. swap until disk usage is below this, "highGiB" (int32): the high watermark for swapping, i.e. start swapping when disk usage becomes this, "intervalMillis" (int64): amount of time in between running swap job and checking watermarks. 3600000 is 1 hour } } ``` -------------------------------- ### LaTeX equation example Source: https://github.com/ayaka-notes/ayakaleaf-pro/blob/server-pro/services/web/public/static/latex/learn/free-online-introduction-to-latex-part-1.pdf Displays a simple equation with Greek letters and a number, producing a numbered equation. ```latex \begin{equation} \alpha+\beta+ 1 \end{equation} ``` -------------------------------- ### directorySize Source: https://github.com/ayaka-notes/ayakaleaf-pro/blob/server-pro/libraries/object-persistor/README.md Returns the size of a directory (all objects whose keys start with the supplied key). ```APIDOC ## directorySize ### Description Returns the size of a directory (all objects whose keys start with the supplied `key`). ### Method async function ### Signature `async function directorySize(bucketName, key)` ### Parameters - `bucketName` (string) - Required - The name of the bucket to examine - `key` (string) - Required - The key prefix for the objects ### Returns An integer containing the size, in bytes ### Notes When using a secondary persistor, this returns the value from the secondary persistor if no objects are found on the primary. ``` -------------------------------- ### LaTeX command example: \emph for emphasis Source: https://github.com/ayaka-notes/ayakaleaf-pro/blob/server-pro/services/web/public/static/latex/learn/free-online-introduction-to-latex-part-1.pdf Shows the \emph command to emphasize text. The output renders 'mainly' in italics. ```latex The rain in Spain falls\emph{mainly}on the plain. ``` -------------------------------- ### Optional arguments for \documentclass Source: https://github.com/ayaka-notes/ayakaleaf-pro/blob/server-pro/services/web/public/static/latex/learn/free-online-introduction-to-latex-part-2.pdf Optional arguments are given in square brackets after the command name. This example sets the font size to 12pt and uses a two-column layout. ```latex \documentclass[12pt,twocolumn]{article} ``` -------------------------------- ### Run all migrations in server-ce Source: https://github.com/ayaka-notes/ayakaleaf-pro/blob/server-pro/tools/migrations/README.md Runs all pending migrations for the server-ce environment. Note: migrations are run by default on container start. ```shell yarn run migrations migrate -t 'server-ce' # Note: They are run by default on container start. ``` -------------------------------- ### Theme and color theme customization Source: https://github.com/ayaka-notes/ayakaleaf-pro/blob/server-pro/services/web/public/static/latex/learn/free-online-introduction-to-latex-part-3.pdf Set the presentation theme with \usetheme and the color theme with \usecolortheme. The example uses the Darmstadt theme and beetle color theme, but many alternatives exist. ```latex \documentclass{beamer} % or Warsaw, Bergen, Madrid, ... \usetheme{Darmstadt} % or albatross, beaver, crane, ... \usecolortheme{beetle} John \title{Theme Demo} April 28, 2013 \author{John} \begin{document} \begin{frame} \titlepage \end{frame} \end{document} ``` -------------------------------- ### GET /shutdown Source: https://github.com/ayaka-notes/ayakaleaf-pro/blob/server-pro/services/filestore/README.md Initiates a graceful shutdown of the filestore service. This endpoint is used to stop the service. ```APIDOC ## GET /shutdown ### Description Initiates a graceful shutdown of the filestore service. This endpoint is used to stop the service. ### Method GET ### Endpoint /shutdown ### Response #### Success Response (200) - **body** (string) - A message indicating the shutdown has been initiated. #### Response Example Shutting down ``` -------------------------------- ### TikZ: Colours as \draw options Source: https://github.com/ayaka-notes/ayakaleaf-pro/blob/server-pro/services/web/public/static/latex/learn/free-online-introduction-to-latex-part-3.pdf Shows how to specify colours as options to \draw in a TikZ picture. The example draws a grid, axes in red, and a diamond with a blue outline and yellow fill. ```LaTeX \begin{tikzpicture} \draw[help lines](0,0) grid (3,3); % axes \draw[<->, thick, red] (0,3)--(0,0)--(3,0); % diamond \draw[thick, blue, fill=yellow] (1.5,0.5) -- (2.5,1.5) -- (1.5,2.5) -- (0.5,1.5) -- cycle; \end{tikzpicture} ``` -------------------------------- ### Including images with \includegraphics (graphicx) Source: https://github.com/ayaka-notes/ayakaleaf-pro/blob/server-pro/services/web/public/static/latex/learn/free-online-introduction-to-latex-part-2.pdf Two examples of the \includegraphics command from the graphicx package, showing width scaling and rotation with the angle option. Supported formats include JPEG, PNG, and PDF. ```LaTeX \includegraphics[ width=0.5\textwidth]{gerbil} ``` ```LaTeX \includegraphics[ width=0.3\textwidth, angle=270]{gerbil} ``` -------------------------------- ### OError.getFullStack(error) Source: https://github.com/ayaka-notes/ayakaleaf-pro/blob/server-pro/libraries/o-error/README.md Static method to get the full stack trace including tagged errors and causes. ```APIDOC ## OError.getFullStack(error) ⇒ string ### Description Return the `stack` property from `error`, including the `stack`s for any tagged errors added with `OError.tag` and for any `cause`s. ### Parameters - **error** (Error | null | undefined) - Required - any error (may or may not be an `OError`) ``` -------------------------------- ### LaTeX figure with includegraphics example Source: https://github.com/ayaka-notes/ayakaleaf-pro/blob/server-pro/services/web/public/static/latex/learn/free-online-introduction-to-latex-part-1.pdf Inserts an image (gerbil) using the \includegraphics command inside a figure environment. ```latex \begin{figure} \includegraphics{gerbil} \end{figure} ``` -------------------------------- ### Unnumbered equation with equation* Source: https://github.com/ayaka-notes/ayakaleaf-pro/blob/server-pro/services/web/public/static/latex/learn/free-online-introduction-to-latex-part-1.pdf Creates an unnumbered displayed equation using the equation* environment. The example shows a summation with subscript and superscript. ```latex \begin{equation*} \Omega=\sum_{k=1}^{n}\omega_k \end{equation*} ``` -------------------------------- ### Output: Realistic error stack trace without context Source: https://github.com/ayaka-notes/ayakaleaf-pro/blob/server-pro/libraries/o-error/README.md A more realistic example of an error stack trace that lacks useful context, illustrating why tagging is needed. ```text DBError: socket connection refused at someObscureLibraryFunction (...) at ... ``` -------------------------------- ### Define custom command for complicated equation Source: https://github.com/ayaka-notes/ayakaleaf-pro/blob/server-pro/services/web/public/static/latex/learn/free-online-introduction-to-latex-part-2.pdf Define your own command for a complicated equation using \newcommand. The example defines \rperf as a performance metric. ```latex \newcommand{\rperf}{\rho_{\text{perf}}} = c X + \varepsilon ``` -------------------------------- ### GET /status Source: https://github.com/ayaka-notes/ayakaleaf-pro/blob/server-pro/services/filestore/README.md Returns the status of the filestore service. It responds with HTTP 200 and the message 'filestore is up' when the service is running, or HTTP 503 when the service is shutting down. ```APIDOC ## GET /status ### Description Returns the status of the filestore service. It responds with HTTP 200 and the message 'filestore is up' when the service is running, or HTTP 503 when the service is shutting down. ### Method GET ### Endpoint /status ### Response #### Success Response (200) - **body** (string) - The message 'filestore is up'. #### Response Example filestore is up #### Error Response (503) - **body** (string) - The message indicating the service is shutting down. #### Response Example Service shutting down ``` -------------------------------- ### TikZ: Plotting functions (sine and cosine) Source: https://github.com/ayaka-notes/ayakaleaf-pro/blob/server-pro/services/web/public/static/latex/learn/free-online-introduction-to-latex-part-3.pdf Plots simple functions with TikZ. The example draws axes and plots sine and cosine curves with specified domains and colours. ```LaTeX \begin{tikzpicture}[scale=0.5] % y axis \draw[<->, thick](0,2) -- (0,-2); % x axis \draw[ ->, thick](0,0) -- (7, 0); % curves \draw[cyan,domain=0:2*pi] plot (\x,{sin(\xr)}); \draw[magenta,domain=0:2*pi] plot (\x,{cos(\xr)}); \end{tikzpicture} ``` -------------------------------- ### Align equations with align* Source: https://github.com/ayaka-notes/ayakaleaf-pro/blob/server-pro/services/web/public/static/latex/learn/free-online-introduction-to-latex-part-1.pdf Aligns a sequence of equations at the equals sign using the align* environment. Use & to separate columns and \\ to start a new line. ```latex \begin{align*} (x+1)^3&= (x+1)(x+1)(x+1)\ &= (x+1)(x^2 + 2x + 1)\ &= x^3 + 3x^2 + 3x + 1 \end{align*} ``` -------------------------------- ### Problem: Error stack trace missing call-site context Source: https://github.com/ayaka-notes/ayakaleaf-pro/blob/server-pro/libraries/o-error/README.md Shows the problem: an error thrown inside a `process.nextTick` callback loses the call-site context, so the stack trace starts at the built-in `nextTick` and omits the `sayHi1` function. ```javascript const demoDatabase = { findUser(id, callback) { process.nextTick(() => { // return result asynchronously if (id === 42) { callback(null, { name: 'Bob' }) } else { callback(new Error('not found')) } }) }, } function sayHi1(userId, callback) { demoDatabase.findUser(userId, (err, user) => { if (err) return callback(err) callback(null, 'Hi ' + user.name) }) } sayHi1(43, (err, result) => { if (err) { console.error(err) } else { console.log(result) } }) ``` -------------------------------- ### deleteDirectory(bucketName, key) Source: https://github.com/ayaka-notes/ayakaleaf-pro/blob/server-pro/libraries/object-persistor/README.md Deletes all objects whose keys start with the given key prefix. When using a secondary persistor, deletes from both persistors. ```APIDOC ## deleteDirectory(bucketName, key) ### Description Deletes a directory (all objects whose keys start with the supplied `key`). When using a secondary persistor, this deletes the objects from both persistors. ### Method async function ### Parameters - **bucketName** (string) - Required - The name of the bucket to delete from - **key** (string) - Required - The key prefix for the objects ### Notes - When using a secondary persistor, this deletes the objects from both persistors. ``` -------------------------------- ### Build and run Docker image Source: https://github.com/ayaka-notes/ayakaleaf-pro/blob/server-pro/services/git-bridge/README.md Build the Docker image and run it with the demo configuration file mounted at /conf/runtime.json. ```bash docker build -t writelatex-git-bridge . ``` ```bash docker run -v `pwd`/conf/local.json:/conf/runtime.json writelatex-git-bridge ``` -------------------------------- ### getRedirectUrl method signature Source: https://github.com/ayaka-notes/ayakaleaf-pro/blob/server-pro/libraries/object-persistor/README.md Gets a signed link directly to the backend, if possible. Returns a string or null if a link cannot be generated. Do not use this method with a secondary persistor because it does not check object existence. ```JavaScript async function getRedirectUrl(bucketName, key) ``` -------------------------------- ### Print all routes with bin/routes Source: https://github.com/ayaka-notes/ayakaleaf-pro/blob/server-pro/services/web/README.md Run bin/routes to print out all routes in the project. ```bash bin/routes ``` -------------------------------- ### Create overleaf group and add users Source: https://github.com/ayaka-notes/ayakaleaf-pro/blob/server-pro/services/clsi/README.md Alternative solution: create an overleaf group, add root and the uid 1000 user, then set ownership and permissions on compiles. ```shell sudo useradd --uid 1000 host-node-user # If required sudo groupadd overleaf sudo usermod -a -G overleaf root sudo usermod -a -G overleaf $(id -nu 1000) sudo chown -R 1000:overleaf compiles sudo chmod -R g+w compiles sudo chmod g+s compiles ``` -------------------------------- ### OError.getFullInfo(error) Source: https://github.com/ayaka-notes/ayakaleaf-pro/blob/server-pro/libraries/o-error/README.md Static method to get the merged info from tags and causes on an error. ```APIDOC ## OError.getFullInfo(error) ⇒ Object ### Description The merged info from any `tag`s and causes on the given error. If an info property is repeated, the last one wins. ### Parameters - **error** (Error | null | undefined) - Required - any error (may or may not be an `OError`) ``` -------------------------------- ### Dev-environment build, test, and clean commands Source: https://github.com/ayaka-notes/ayakaleaf-pro/blob/server-pro/services/git-bridge/README.md Commands to build, test, and clean the project from the dev-environment using bin/run. ```bash bin/run git-bridge make package ``` ```bash bin/run git-bridge make test ``` ```bash bin/run git-bridge make clean ``` -------------------------------- ### Using \label, \ref, and \eqref in LaTeX Source: https://github.com/ayaka-notes/ayakaleaf-pro/blob/server-pro/services/web/public/static/latex/learn/free-online-introduction-to-latex-part-2.pdf Complete LaTeX document showing how to use \label and \ref for sections and \eqref (from amsmath) for equations, so numbers are generated automatically. ```LaTeX \documentclass{article} \usepackage{amsmath} % for \eqref \begin{document} \section{Introduction} \label{sec:intro} In Section\ref{sec:method}, we\ldots \section{Method} \label{sec:method} \begin{equation} \label{eq:euler} e^{i\pi}+ 1 = 0 \end{equation} By\eqref{eq:euler}, we have\ldots \end{document} ``` -------------------------------- ### GET /health_check Source: https://github.com/ayaka-notes/ayakaleaf-pro/blob/server-pro/services/filestore/README.md Performs a health check on the filestore service. This endpoint is used to verify that the service is running and responsive. ```APIDOC ## GET /health_check ### Description Performs a health check on the filestore service. This endpoint is used to verify that the service is running and responsive. ### Method GET ### Endpoint /health_check ### Response #### Success Response (200) - **body** (string) - A message indicating the service is healthy. #### Response Example OK ``` -------------------------------- ### Clone the Overleaf repository Source: https://github.com/ayaka-notes/ayakaleaf-pro/blob/server-pro/services/clsi/README.md First step to run the CLSI as a standalone service: checkout the repository. ```shell git clone git@github.com:overleaf/overleaf.git ``` -------------------------------- ### Run npm dependency modifications inside container Source: https://github.com/ayaka-notes/ayakaleaf-pro/blob/server-pro/server-ce/hotfix/5.5.3/NOTES.md Executes a series of npm commands inside the container to modify package.json overrides, uninstall specific packages, and install specific versions. This includes using the 'json' tool to set overrides for multer, form-data, and superagent, and uninstalling/installing packages like @node-saml/passport-saml, multer, swagger-tools, and request. Ends with 'npm install' and 'npm audit'. ```bash docker exec -i $CONTAINER_NAME /bin/bash <<'EOF' npm install -g json json -I -f package.json -c 'this.overrides["swagger-tools"].multer="2.0.2"' json -I -f package.json -c 'this.overrides["request@2.88.2"]["form-data"]="2.5.5"' json -I -f package.json -c 'this.overrides["superagent@7.1.6"] ??= {}' json -I -f package.json -c 'this.overrides["superagent@7.1.6"]["form-data"]="4.0.4"' json -I -f package.json -c 'this.overrides["superagent@3.8.3"] ??= {}' json -I -f package.json -c 'this.overrides["superagent@3.8.3"]["form-data"]="2.5.5"' npm uninstall -w libraries/metrics @google-cloud/opentelemetry-cloud-trace-exporter @google-cloud/profiler npm uninstall -w libraries/logger @google-cloud/logging-bunyan npm uninstall -w services/web @slack/webhook contentful @contentful/rich-text-types @contentful/rich-text-html-renderer npm uninstall -w services/history-v1 @google-cloud/secret-manager npm uninstall -w services/web "@node-saml/passport-saml" npm install -w services/web "@node-saml/passport-saml@^5.1.0" npm uninstall -w services/web multer npm install -w services/web "multer@2.0.2" npm uninstall -w services/history-v1 swagger-tools npm install -w services/history-v1 swagger-tools@0.10.4 npm uninstall -w services/clsi request npm install -w services/clsi request@2.88.2 npm install npm audit --audit-level=high EOF ``` -------------------------------- ### Run all tests with make test Source: https://github.com/ayaka-notes/ayakaleaf-pro/blob/server-pro/services/web/README.md Runs the full test suite. ```bash make test ``` -------------------------------- ### Run acceptance tests for a module with make test_acceptance_module Source: https://github.com/ayaka-notes/ayakaleaf-pro/blob/server-pro/services/web/README.md Runs acceptance tests for a single module, e.g., saas-authentication. ```bash make test_acceptance_module MODULE=saas-authentication ``` -------------------------------- ### Run acceptance tests with make test_acceptance Source: https://github.com/ayaka-notes/ayakaleaf-pro/blob/server-pro/services/web/README.md Runs acceptance tests against a live service in the acceptance_test container. ```bash make test_acceptance ``` -------------------------------- ### Run all migrations in SAAS via rake Source: https://github.com/ayaka-notes/ayakaleaf-pro/blob/server-pro/tools/migrations/README.md Lists and then runs migrations for the staging environment using rake tasks. First list to check that only your newly added migration is shown, then run the migrations. ```shell # list first and check that only your newly added migration is shown. If not, ask in the dev channel for help. rake deploy:migrations:list[staging] # After confirming the listing, run the migrations rake deploy:migrations[staging] ``` -------------------------------- ### Maven build, test, and clean commands Source: https://github.com/ayaka-notes/ayakaleaf-pro/blob/server-pro/services/git-bridge/README.md Maven commands to build the jar, run tests, and clean the project from the base directory. ```bash mvn package ``` ```bash mvn test ``` ```bash mvn clean ``` -------------------------------- ### Build services with bin/build Source: https://github.com/ayaka-notes/ayakaleaf-pro/blob/server-pro/develop/README.md Builds the Overleaf Community Edition services. If Docker runs out of RAM during parallel builds, create a .env file in this directory with COMPOSE_PARALLEL_LIMIT=1. ```shell bin/build ``` -------------------------------- ### Run unit tests with make test_unit Source: https://github.com/ayaka-notes/ayakaleaf-pro/blob/server-pro/services/web/README.md Runs unit tests in the test_unit Docker container. ```bash make test_unit ``` -------------------------------- ### Minimal LaTeX document Source: https://github.com/ayaka-notes/ayakaleaf-pro/blob/server-pro/services/web/public/static/latex/learn/free-online-introduction-to-latex-part-1.pdf A minimal LaTeX document that starts with \documentclass{article}, includes a comment, and ends with \end{document}. The comment is ignored by LaTeX. ```latex \documentclass{article} \begin{document} Hello World! % your content goes here... \end{document} ``` -------------------------------- ### Run acceptance tests for a module with pattern using make test_acceptance_module Source: https://github.com/ayaka-notes/ayakaleaf-pro/blob/server-pro/services/web/README.md Runs acceptance tests for a module with a TEST_NAME_PATTERN argument, e.g., SSO. ```bash make test_acceptance_module MODULE=saas-authentication TEST_NAME_PATTERN=SSO ``` -------------------------------- ### Run tests for a module with make test_module Source: https://github.com/ayaka-notes/ayakaleaf-pro/blob/server-pro/services/web/README.md Runs both unit and acceptance tests for a specific module, e.g., saas-authentication. ```bash make test_module MODULE=saas-authentication ``` -------------------------------- ### deleteDirectory method signature Source: https://github.com/ayaka-notes/ayakaleaf-pro/blob/server-pro/libraries/object-persistor/README.md Deletes a directory, i.e., all objects whose keys start with the supplied key. When using a secondary persistor, deletes the objects from both persistors. ```JavaScript async function deleteDirectory(bucketName, key) ``` -------------------------------- ### Enable request logging with metrics.http.monitor Source: https://github.com/ayaka-notes/ayakaleaf-pro/blob/server-pro/libraries/metrics/README.md Enable request logging by passing the logger to metrics.http.monitor and mounting it as middleware. ```javascript const logger = require('@overleaf/logger') ... app.use(metrics.http.monitor(logger)) ``` -------------------------------- ### Initialize and inject metrics route Source: https://github.com/ayaka-notes/ayakaleaf-pro/blob/server-pro/libraries/metrics/README.md Initialize the metrics module before importing other modules, then create an Express app and inject the metrics route at /metrics. ```javascript // Metrics must be initialized before importing anything else require('@overleaf/metrics/initialize') const express = require('express') const metrics = require('@overleaf/metrics') const app = express() metrics.injectMetricsRoute(app) ``` -------------------------------- ### Snapshot initial container state Source: https://github.com/ayaka-notes/ayakaleaf-pro/blob/server-pro/server-ce/hotfix/5.5.3/NOTES.md Cleans any existing directories, creates a snapshot directory, and exports the container's overleaf directory (excluding node_modules) to /tmp/a. This captures the state before applying npm changes. ```bash # Clean any existing directories rm -rf /tmp/{a,b} # Take snapshot of initial container mkdir /tmp/a ; docker export $CONTAINER_NAME | tar --exclude node_modules -x -C /tmp/a --strip-components=1 overleaf ``` -------------------------------- ### Run subset of acceptance tests with MOCHA_ARGS Source: https://github.com/ayaka-notes/ayakaleaf-pro/blob/server-pro/services/project-history/README.md Run a subset of acceptance tests by passing arguments to the mocha CLI via MOCHA_ARGS. ```makefile make test_acceptance_run MOCHA_ARGS='--grep=AuthorizationManager' ``` -------------------------------- ### TikZ: Drawing circles and rectangles Source: https://github.com/ayaka-notes/ayakaleaf-pro/blob/server-pro/services/web/public/static/latex/learn/free-online-introduction-to-latex-part-3.pdf Demonstrates built-in TikZ commands for drawing simple shapes: a circle and a rectangle on a grid. ```LaTeX \begin{tikzpicture} \draw[help lines](0,0) grid (3,3); \draw(1.5,2.0) circle (0.5); \draw(0.5,0.5) rectangle (2.5,1.5); \end{tikzpicture} ``` -------------------------------- ### Animation with \pause in itemize Source: https://github.com/ayaka-notes/ayakaleaf-pro/blob/server-pro/services/web/public/static/latex/learn/free-online-introduction-to-latex-part-3.pdf Use the \pause command inside an itemize list to reveal items one by one on separate slides. The example shows two items, with the pause before the second item. ```latex \begin{itemize} \itemCan you feel the ICan you feel the \pause\itemanticipation? \end{itemize} ``` -------------------------------- ### Generate Lezer-LaTeX parser files Source: https://github.com/ayaka-notes/ayakaleaf-pro/blob/server-pro/services/web/frontend/js/features/source-editor/lezer-latex/README.md Generate the Lezer-LaTeX parser files from the grammar. The first command is automatic (on changes), the second is manual. Run from the monorepo root. ```sh make install ``` ```sh bin/yarn -w services/web run 'lezer-latex:generate' ``` -------------------------------- ### getObjectStream method signature Source: https://github.com/ayaka-notes/ayakaleaf-pro/blob/server-pro/libraries/object-persistor/README.md Retrieves a stream from the backend for reading. The opts object can include start and end for byte range downloads. When using a secondary persistor, it falls back to the secondary if the object is not on the primary. ```JavaScript async function getObjectStream(bucketName, key, opts = {}) ``` -------------------------------- ### Run unit tests for a module with make test_unit_module Source: https://github.com/ayaka-notes/ayakaleaf-pro/blob/server-pro/services/web/README.md Runs unit tests for a single module, e.g., saas-authentication. ```bash make test_unit_module MODULE=saas-authentication ``` -------------------------------- ### Load amsmath package in preamble Source: https://github.com/ayaka-notes/ayakaleaf-pro/blob/server-pro/services/web/public/static/latex/learn/free-online-introduction-to-latex-part-1.pdf Loads the amsmath package in the preamble to access its mathematical commands and environments. Place before \begin{document}. ```latex \documentclass{article} \usepackage{amsmath} % preamble \begin{document} % now we can use commands from amsmath here... \end{document} ``` -------------------------------- ### Create a new migration Source: https://github.com/ayaka-notes/ayakaleaf-pro/blob/server-pro/tools/migrations/README.md Creates a new migration file in the migrations folder based on a template. The template provides `migrate` and `rollback` methods. ```shell yarn run migrations create ``` -------------------------------- ### POST /project//compile Source: https://github.com/ayaka-notes/ayakaleaf-pro/blob/server-pro/services/clsi/README.md Compiles a LaTeX project. The request includes compiler options, the main file path, and an array of resources (files with content or URLs). The response contains the compilation status and URLs to output files. ```APIDOC ## POST /project//compile ### Description Compiles a LaTeX project. The request includes compiler options, the main file path, and an array of resources (files with content or URLs). The response contains the compilation status and URLs to output files. ### Method POST ### Endpoint /project//compile ### Parameters #### Path Parameters - **project-id** (string) - Required - The project identifier. Any project-id can be specified, and files and LaTeX environment are persisted between requests. #### Request Body - **compile** (object) - Required - The compilation request object. - **options** (object) - Optional - Compilation options. - **compiler** (string) - Optional - Which compiler to use. Can be latex, pdflatex, xelatex or lualatex. - **timeout** (number) - Optional - How many seconds to wait before killing the process. Default is 60. - **rootResourcePath** (string) - Required - The main file to run LaTeX on. - **resources** (array) - Required - An array of files to include in the compilation. May have either the content passed directly, or a URL where it can be downloaded. - **path** (string) - Required - The file path. - **content** (string) - Optional - The file content. - **url** (string) - Optional - The URL where the file can be downloaded. - **modified** (number) - Optional - Unix time since epoch for cache invalidation. ### Request Example { "compile": { "options": { "compiler": "lualatex", "timeout": 40 }, "rootResourcePath": "main.tex", "resources": [ { "path": "main.tex", "content": "\\documentclass{article}\n\\begin{document}\nHello World\n\\end{document}" } ] } } ### Response #### Success Response (200) - **compile** (object) - The compilation result. - **status** (string) - The compilation status (e.g., success). - **outputFiles** (array) - List of output files. - **type** (string) - The file type (e.g., pdf, log). - **url** (string) - The URL to access the output file. #### Response Example { "compile": { "status": "success", "outputFiles": [ { "type": "pdf", "url": "http://localhost:3013/project//output/output.pdf" }, { "type": "log", "url": "http://localhost:3013/project//output/output.log" } ] } } ``` -------------------------------- ### Run acceptance tests with pattern using make test_acceptance_run Source: https://github.com/ayaka-notes/ayakaleaf-pro/blob/server-pro/services/web/README.md Runs a subset of acceptance tests matching the given mocha pattern, e.g., AuthorizationManager. ```bash make test_acceptance_run TEST_NAME_PATTERN='AuthorizationManager' ``` -------------------------------- ### Import and instantiate ObjectPersistor Source: https://github.com/ayaka-notes/ayakaleaf-pro/blob/server-pro/libraries/object-persistor/README.md Import the object-persistor module and create a new persistor instance with a configuration object. The config object is described in the 'Configuration' section of the documentation. ```JavaScript // import the module const ObjectPersistor = require('object-persistor') const config = { // see 'Configuration' section below } // create a new persistor const Persistor = ObjectPersistor(config) ``` -------------------------------- ### Output: Full stack with annotations and info object Source: https://github.com/ayaka-notes/ayakaleaf-pro/blob/server-pro/libraries/o-error/README.md Output showing the full stack with `failed to ...` annotations and the merged `info` object containing `userId`. ```text Error: not found at process.nextTick (repl:8:18) at process._tickCallback (internal/process/next_tick.js:61:11) TaggedError: failed to find user at demoDatabase.findUser (repl:3:37) at process.nextTick (repl:8:9) at process._tickCallback (internal/process/next_tick.js:61:11) TaggedError: failed to say hi at sayHi3 (repl:3:12) at demoDatabase.findUser (repl:3:21) at process.nextTick (repl:8:9) at process._tickCallback (internal/process/next_tick.js:61:11) { userId: 43 } ``` -------------------------------- ### sendFile Source: https://github.com/ayaka-notes/ayakaleaf-pro/blob/server-pro/libraries/object-persistor/README.md Uploads a file from the local disk to the bucket. ```APIDOC ## sendFile ### Description Uploads a file from the local disk. ### Method async function ### Signature `async function sendFile(bucketName, key, fsPath)` ### Parameters - `bucketName` (string) - Required - The name of the bucket to upload to - `key` (string) - Required - The key for the uploaded object - `fsPath` (string) - Required - The path on disk to the file for uploading ### Notes When using a secondary persistor, this method uploads only to the primary. If an object already exists at the specified key, it will be overwritten. This method is designed for applications which may write temporary data out to the disk before uploading. ``` -------------------------------- ### Run unit tests for a module with pattern using make test_unit_module Source: https://github.com/ayaka-notes/ayakaleaf-pro/blob/server-pro/services/web/README.md Runs unit tests for a module with a TEST_NAME_PATTERN argument, e.g., SSO. ```bash make test_unit_module MODULE=saas-authentication TEST_NAME_PATTERN=SSO ``` -------------------------------- ### Create unique sorted project ids from docs Source: https://github.com/ayaka-notes/ayakaleaf-pro/blob/server-pro/services/web/scripts/delete-orphaned-docs/README.md Creates a unique sorted list of project ids from the docs export file. ```bash cut -d, -f 2 all-docs-doc_id-project_id.csv | sort | uniq > all-docs-project_ids.sorted.uniq.csv ``` -------------------------------- ### Create unique sorted project ids from projects Source: https://github.com/ayaka-notes/ayakaleaf-pro/blob/server-pro/services/web/scripts/delete-orphaned-docs/README.md Creates a unique sorted list of project ids from the projects export file. ```bash sort all-projects-project_id.csv | uniq > all-projects-project_id.sorted.uniq.csv ``` -------------------------------- ### Build the CLSI Docker image Source: https://github.com/ayaka-notes/ayakaleaf-pro/blob/server-pro/services/clsi/README.md Builds the Docker image for the CLSI service from the provided Dockerfile. ```shell docker build . -t overleaf/clsi -f services/clsi/Dockerfile ``` -------------------------------- ### LaTeX TikZ-Feynman environment for B0 decay diagram Source: https://github.com/ayaka-notes/ayakaleaf-pro/blob/server-pro/services/clsi/test/acceptance/fixtures/examples/tikz_feynman/main.tex A complete LaTeX TikZ-Feynman environment for a B0 meson decay into pions, with explicit vertex placement, fermion and boson edges, and decorative braces labeling the final states. Uses the \diagram* command and requires the tikz-feynman package. ```latex \begin{feynman} \vertex (a1) {\\(\overline b\\)}; \vertex[right=1cm of a1] (a2); \vertex[right=1cm of a2] (a3); \vertex[right=1cm of a3] (a4) {\\(b\\)}; \vertex[right=1cm of a4] (a5); \vertex[right=2cm of a5] (a6) {\\(u\\)}; \vertex[below=2em of a1] (b1) {\\(d\\)}; \vertex[right=1cm of b1] (b2); \vertex[right=1cm of b2] (b3); \vertex[right=1cm of b3] (b4) {\\(\overline d\\)}; \vertex[below=2em of a6] (b5) {\\(\overline d\\)}; \vertex[above=of a6] (c1) {\\(\overline u\\)}; \vertex[above=2em of c1] (c3) {\\(d\\)}; \vertex at ($(c1)!0.5!(c3) - (1cm, 0)$) (c2); \diagram* { {[edges=fermion] (b1) -- (b2) -- (a2) -- (a1), (b5) -- (b4) -- (b3) -- (a3) -- (a4) -- (a5) -- (a6), }, (a2) -- [boson, edge label=\(W\)] (a3), (b2) -- [boson, edge label'=\(W\)] (b3), (c1) -- [fermion, out=180, in=-45] (c2) -- [fermion, out=45, in=180] (c3), (a5) -- [boson, bend left, edge label=\(W^{-}\)] (c2), }; \draw [decoration={brace}, decorate] (b1.south west) -- (a1.north west) node [pos=0.5, left] {\\(B^{0}\\)}; \draw [decoration={brace}, decorate] (c3.north east) -- (c1.south east) node [pos=0.5, right] {\\(\pi^{-}\\)}; \draw [decoration={brace}, decorate] (a6.north east) -- (b5.south east) node [pos=0.5, right] {\\(\pi^{+}\\)}; \end{feynman} ``` -------------------------------- ### Use \min operator instead of plain text Source: https://github.com/ayaka-notes/ayakaleaf-pro/blob/server-pro/services/web/public/static/latex/learn/free-online-introduction-to-latex-part-1.pdf Shows the difference between writing 'min' as text (bad) and using the \min operator (good) in amsmath. The \min operator provides proper spacing and formatting. ```latex \begin{equation*} % bad! min_{x,y}(1-x)^2 + 100(y-x^2)^2 \end{equation*} \begin{equation*} % good! \min_{x,y}{(1-x)^2 + 100(y-x^2)^2} \end{equation*} ``` -------------------------------- ### List migrations for staging via rake Source: https://github.com/ayaka-notes/ayakaleaf-pro/blob/server-pro/tools/migrations/README.md Lists migrations for the staging environment using the rake task. This is used for SAAS staging/production. ```shell rake deploy:migrations:list[staging] ``` -------------------------------- ### Run subset of unit tests with MOCHA_ARGS Source: https://github.com/ayaka-notes/ayakaleaf-pro/blob/server-pro/services/project-history/README.md Run a subset of unit tests by passing arguments to the mocha CLI via MOCHA_ARGS. ```makefile make test_unit MOCHA_ARGS='--grep=AuthorizationManager' ``` -------------------------------- ### List migrations with East via yarn Source: https://github.com/ayaka-notes/ayakaleaf-pro/blob/server-pro/tools/migrations/README.md Lists migrations for the server-ce environment using the yarn wrapper around East. Note: do not put a `--` between `migrations` and the east arguments because Yarn 4 forwards it literally and breaks subcommand parsing. ```shell yarn run migrations list -t 'server-ce' ``` -------------------------------- ### Run Lezer-LaTeX unit tests Source: https://github.com/ayaka-notes/ayakaleaf-pro/blob/server-pro/services/web/frontend/js/features/source-editor/lezer-latex/README.md Run the unit tests for the Lezer-LaTeX parser alone. These tests are part of test_frontend. ```sh make test_unit TEST_NAME_PATTERN='lezer-latex' ```