Getting Started
Installation
Install Mongalayer and its peer dependencies.
Install the packages
Mongalayer is published under the @mongalayer scope. Install the packages you need:
Terminal
# Server-side (Node.js)
npm install @mongalayer/server
# Client-side (browser, Node.js, or any fetch-compatible runtime)
npm install @mongalayer/client
Peer dependencies
@mongalayer/server requires the MongoDB Node.js driver and Zod as peer dependencies:
Terminal
npm install mongodb zod
Project structure
A typical project using Mongalayer looks like this:
my-app/
├── model/ # Application model per collection (Types & Zod schemas)
│ └── project.ts
│── server/
│ ├── access/ # Access definitions per collection
│ │ └── project.ts
│ ├── mongalayer.ts # Mongalayer instance setup
│ └── index.ts # Your HTTP server (Lambda, Express, etc.)
├── client/
│ └── index.ts # Mongalayer client setup and API wrappers
└── package.json