cotrav_monorepo_package_creation_service_build_guide
This is an old revision of the document!
Table of Contents
Cotrav Monorepo – Package Creation & Service Build Guide
This document describes how to create shared packages and build/run services in the Cotrav monorepo. It is Confluence-ready and can be pasted directly.
Repository Structure
cotrav-services/ │ ├─ package.json (root – workspaces enabled) │ ├─ packages/ (shared libraries) │ ├─ logger/ │ ├─ errors/ │ ├─ middlewares/ │ └─ tsconfig.json (base TS config for packages) │ ├─ workspace/ (runtime services) │ ├─ auth-service/ │ ├─ booking-service/ │ └─ payment-service/ │ └─ node_modules/
Prerequisites
| Tool | Version |
|---|
| Node.js | >= 18.x |
| npm | >= 9.x |
| TypeScript | >= 5.x |
| VS Code | Recommended |
Root Workspace Setup
Root package.json
The root enables npm workspaces so shared packages can be consumed without publishing.
cmd
npm install
Build Package
package/logger
cmd
npm run build --workspace=packages/logger
package/errors
cmd
npm run build --workspace=packages/errors
Creating Error & Middleware Packages
Repeat the same steps for:
@cotrav/errors@cotrav/middlewares
Only business logic differs, structure remains identical.
Creating a Service
Example: auth-service
Folder Creation
cd workspace mkdir auth-service cd auth-service npm init -y
cotrav_monorepo_package_creation_service_build_guide.1768824192.txt.gz · Last modified: by pradnya
