This repo contains all the Pocket Typescript systems built as a monorepo but deployed as microservices. For services that power Recomendations or Pocket Curated Content see the Content Monorepo
This Repo includes the following packages/servers:
servers
: all our typescript microservices required for running baseline Pocket.lambdas
: all our lambda listeners that are made up of SQS Queue processers or API Gatewaysinfrastructure
: all of the terraform infrastructure that is used to deploy each microservicepackages/eslint-config-custom
:eslint
configurationspackages/tsconfig
:tsconfig.json
s used throughout the monorepopackages/apollo-utils
: holds helpers for all services that boot up graphql. It also includes tracing libraries and hoists apollo in node-modules so that we do not have to keep defining apollo in all services.packages/ts-logger
: helper library to add json structured logging to all our services.packages/tracing
: helper library to add tracing to all our services.packags/terraform-modules
: a set of modules built for Pocket based on the Terraform CDK, used to deploy our infrastructure..docker/aws-resources
: all aws resources that are used by the monorepo, if something is used here, but owned by a service not in this repository, it resides in the legacy files, otherwise each service will have its own script or prefixed resources..docker/mysql-8-resources
: all mysql resources, prefixed with a number letter system so that docker executes database creation in a specific order. All services share a single docker server, but have their own databases unless they read from our legacy (mono) database..docker/postgres-resources
: similar to mysql but for services that use postgres.
Each package/app is 100% TypeScript.
This Turborepo has some additional tools already setup for you:
- TypeScript for static type checking
- ESLint for code linting
- Prettier for code formatting
To build all apps and packages, run the following command:
cd pocket-monorepo
pnpm build
To develop all apps and packages, run the following commands:
cd pocket-monorepo
cp .env.example .env
docker compose up --wait
pnpm install
pnpm dev
This will bring up the docker shared services (MySQL, Memcached, Redis) and then run all the apps in a dev mode.
To run a specific server, run the following:
cd pocket-monorepo
cp .env.example .env
docker compose up --wait
pnpm install
pnpm dev --filter=annotations-api...
Where annotations-api is the server name from package.json you want to run. ...
prefixed informs turborepo to include all dependent workspace packages.
You can expand this to run multiple specific servers as well like:
pnpm run dev --filter=list-api... --filter=feature-flags...
This repo relies on Turbo repos caching strategies to speed up development and only execute tasks that are needed when certain files change.
More information can be found on Turbo repos site.
If you add new build outputs or inputs, you will need to add them to the necessary area in turbo.json.
If for any reason you need to bypass caching you can add --force
to any command. It would be run like:
pnpm run test --force
or
pnpm run test --filter=annocations-api... --force
To update packages this repository uses Renovate on a pr by pr basis and you can initiate that here
In some cases it may be easier to update packages locally, like updating all development depencies at once.
To select and update development dependencices, interactively you can use the following command ran at the root of the repository.
pnpm update -iDLr
To select and update production and optional dependencices, interactively you can use the following command ran at the root of the repository.
pnpm update -iPLr
When doing an integration test, if you need aws based resources, the CI is setup to run a .sh
script that corresponds to the package name you are testing. So if you need aws resources for a package named annotations-api
you would create a annoations-api.sh
in .docker/aws-resources
that created all the necessary aws resources.
Learn more about the power of Turborepo: