### Install and Start Manifest Admin Panel Source: https://github.com/mnfst/manifest-baas/blob/master/packages/core/admin/README.md Installs dependencies and starts the admin panel. Ensure a Manifest task is running on port 1111 before executing. ```bash npm install npm run start ``` -------------------------------- ### Start Development Server Source: https://github.com/mnfst/manifest-baas/blob/master/CONTRIBUTING.md After installing dependencies, use this command to start the development server. ```bash npm run dev ``` -------------------------------- ### Install Project Dependencies Source: https://github.com/mnfst/manifest-baas/blob/master/examples/main-demo/README.md Run this command to install all necessary project dependencies before starting the application. ```bash npm i ``` -------------------------------- ### Install Project Dependencies Source: https://github.com/mnfst/manifest-baas/blob/master/packages/create-manifest/assets/monorepo/README.md Run this command to install all necessary project dependencies. ```bash npm install ``` -------------------------------- ### Install Project Dependencies Source: https://github.com/mnfst/manifest-baas/blob/master/CONTRIBUTING.md Run these commands from the root of the repository to install all necessary project dependencies. ```bash npm install npm install --workspaces ``` -------------------------------- ### Install Manifest JS SDK Source: https://github.com/mnfst/manifest-baas/blob/master/packages/js-sdk/README.md Install the SDK using npm. ```bash npm i @mnfst/sdk ``` -------------------------------- ### Start Development Server Source: https://github.com/mnfst/manifest-baas/blob/master/packages/js-sdk/sandbox/README.md Run this command to start a local development server. The application will automatically reload on source file changes. ```bash ng serve ``` -------------------------------- ### Start Development Server Source: https://github.com/mnfst/manifest-baas/blob/master/examples/main-demo/README.md Starts the application in development mode. The admin panel will be available at http://localhost:1111 and the API documentation at http://localhost:1111/api. The page reloads automatically on changes. ```bash npm run start ``` -------------------------------- ### Install Manifest CLI Source: https://github.com/mnfst/manifest-baas/blob/master/packages/core/manifest/README.md Commands to create a new Manifest project using NPM or Yarn. ```bash # NPM npx create-manifest@latest # Yarn yarn create manifest ``` -------------------------------- ### Bootstrap a New Manifest Project Source: https://context7.com/mnfst/manifest-baas/llms.txt Use the create-manifest CLI to bootstrap a new project. After creation, run `npm run dev` to start the backend server. ```bash npx create-manifest@latest ``` ```bash yarn create manifest ``` ```bash npm run dev ``` -------------------------------- ### Get Help with Schematics Source: https://github.com/mnfst/manifest-baas/blob/master/packages/js-sdk/sandbox/README.md Run this command to see a list of available schematics for code generation, such as components, directives, or pipes. ```bash ng generate --help ``` -------------------------------- ### Get App Name Source: https://context7.com/mnfst/manifest-baas/llms.txt Public endpoint to retrieve the application's name from the manifest. ```bash curl http://localhost:1111/api/manifest/app-name ``` -------------------------------- ### Get a List of Items Source: https://github.com/mnfst/manifest-baas/blob/master/packages/js-sdk/README.md Retrieve all items from a specified entity (e.g., 'users'). ```javascript // Get all users. const users = await manifest.from('users').find() ``` -------------------------------- ### Get Full App Manifest Source: https://context7.com/mnfst/manifest-baas/llms.txt Admin-only endpoint to retrieve the complete application manifest, including entities, endpoints, and settings. ```bash curl http://localhost:1111/api/manifest \ -H "Authorization: Bearer " ``` -------------------------------- ### Develop Manifest Project Source: https://github.com/mnfst/manifest-baas/blob/master/packages/create-manifest/README.md Install dependencies and run the development script from a separate test folder to avoid conflicts with project files. Path issues are expected in a monorepo. ```bash npm install # Run from a test folder to prevent messing with project files. mkdir test-folder cd test-folder ../bin/dev.js ``` -------------------------------- ### Define Manifest Entities Source: https://github.com/mnfst/manifest-baas/blob/master/packages/core/manifest/README.md Example of a complete Manifest app schema defining 'Pokemon' and 'Trainer' entities with properties and relationships. ```yaml name: Pokemon app 🐣 entities: Pokemon 🐉: properties: - name - { name: type, type: choice, options: { values: [Fire, Water, Grass, Electric] } } - { name: level, type: number } belongsTo: - Trainer Trainer 🧑‍🎤: properties: - name - { name: isChampion, type: boolean } ``` -------------------------------- ### Get Current User Source: https://context7.com/mnfst/manifest-baas/llms.txt Retrieves the details of the currently authenticated user using their token. ```bash curl http://localhost:1111/api/auth/authors/me \ -H "Authorization: Bearer " ``` -------------------------------- ### Get Manifest for Specific Entity Source: https://context7.com/mnfst/manifest-baas/llms.txt Admin-only endpoint to retrieve the manifest configuration for a particular entity. ```bash curl http://localhost:1111/api/manifest/entities/posts \ -H "Authorization: Bearer " ``` -------------------------------- ### Get Current User Source: https://context7.com/mnfst/manifest-baas/llms.txt Retrieves the currently authenticated user's information. ```APIDOC ## Get Current User ### Description Fetch the details of the currently logged-in user. ### Method `client.from(entityName).me(): Promise` ### Endpoint N/A (SDK method) ### Parameters - **entityName** (string) - Required - The entity type of the user (e.g., 'authors'). ### Request Example ```typescript const me = await client.from('authors').me() console.log(me.email) ``` ### Response #### Success Response (User) - Returns the user object. #### Response Example ```json { "id": "user-uuid", "email": "alice@example.com", "name": "Alice" } ``` ``` -------------------------------- ### Define Entities and Policies in manifest.yml Source: https://context7.com/mnfst/manifest-baas/llms.txt The `manifest.yml` file defines the backend schema, including entities, properties, relationships, access policies, validation rules, and webhooks. This example shows a `Post` entity with various property types and policies. ```yaml # manifest.yml name: Blog API version: 1.0.0 entities: # Collection entity with all property types Post: properties: - title # shorthand: type defaults to string - { name: content, type: text } - { name: publishedAt, type: timestamp } - { name: coverPrice, type: money, options: { currency: USD } } - { name: status, type: choice, options: { values: [draft, published, archived] } } - { name: coverImage, type: image, options: { sizes: { thumb: { width: 120, height: 120 }, hero: { width: 1200, height: 630 } } } } - { name: attachment, type: file } - { name: isPublic, type: boolean, default: false } - { name: views, type: number, default: 0 } belongsTo: - Author # ManyToOne belongsToMany: - Tag # ManyToMany policies: create: [{ access: restricted, allow: Author }] read: [{ access: public }] update: [{ access: restricted, allow: Author }] delete: [{ access: admin }] validation: title: { required: true, minLength: 3, maxLength: 200 } content: { isNotEmpty: true } hooks: afterCreate: - { url: "https://hooks.example.com/new-post", method: POST, headers: { X-Secret: mytoken } } # Authenticable entity (gets /auth/:entity/login and /auth/:entity/signup endpoints) Author: authenticable: true properties: - { name: name, type: string } - { name: bio, type: text } policies: signup: [{ access: public }] read: [{ access: public }] Tag: properties: - name # Single entity: one record, no list endpoint SiteSettings: single: true properties: - { name: siteName, type: string } - { name: logoUrl, type: image } policies: read: [{ access: public }] update: [{ access: admin }] # Reusable property groups (nested entities) groups: Address: properties: - { name: street, type: string } - { name: city, type: string } - { name: zip, type: string } validation: city: { required: true } # Custom endpoints mapped to handler files endpoints: featuredPosts: path: /featured method: GET description: Returns the 5 most-viewed published posts. handler: featuredPosts policies: - { access: public } # App-level settings settings: rateLimits: - name: global limit: 100 ttl: 60000 ``` -------------------------------- ### Single Entities - Get, Update, Patch Source: https://context7.com/mnfst/manifest-baas/llms.txt Manage a single, unique entity in the system, such as site settings. ```APIDOC ## Single Entities - Get, Update, Patch ### Description Interact with single, unique entities in the system, like global site settings. The record is auto-created if it doesn't exist. ### Method `client.single(entityName).get(): Promise` `client.single(entityName).update(data: T): Promise` `client.single(entityName).patch(data: Partial): Promise` ### Endpoint N/A (SDK methods) ### Parameters - **entityName** (string) - Required - The name of the single entity (e.g., 'site-settings'). - **data** (object) - Required for update/patch - The data payload. ### Request Example ```typescript interface SiteSettings { siteName: string; logoUrl: Record } // Get the single record const settings = await client.single('site-settings').get() // Full update (PUT) await client.single('site-settings').update({ siteName: 'New Name', logoUrl: {} }) // Partial update (PATCH) await client.single('site-settings').patch({ siteName: 'Patched Name' }) ``` ### Response #### Success Response - Returns the single entity's data. #### Response Example ```json { "siteName": "My Blog", "logoUrl": { "default": "/path/to/logo.png" } } ``` ``` -------------------------------- ### Implement Middleware Handler (generateSlug.js) Source: https://context7.com/mnfst/manifest-baas/llms.txt JavaScript middleware handler that mutates `req.body` before a record is created. This example generates a URL-friendly slug from a post title. ```javascript // handlers/generateSlug.js module.exports = async (req, res, manifest) => { // Mutate req.body before the record is created if (req.body.title) { req.body.slug = req.body.title .toLowerCase() .replace(/[^a-z0-9]+/g, '-') .replace(/(^-|-$)/g, '') } } ``` -------------------------------- ### Get Single Entity Record Source: https://context7.com/mnfst/manifest-baas/llms.txt Retrieves the single record for a specified entity. The record is auto-created if it does not exist. ```bash curl http://localhost:1111/api/singles/site-settings ``` -------------------------------- ### Manage Single Entities with `client.single()` Source: https://context7.com/mnfst/manifest-baas/llms.txt Use `client.single()` to get, update (PUT), or patch (PATCH) a single, unique record. The record is auto-created if it does not exist. ```typescript import Manifest from '@mnfst/sdk' const client = new Manifest('http://localhost:1111') interface SiteSettings { siteName: string; logoUrl: Record } // Get the single record (auto-creates if missing) const settings = await client.single('site-settings').get() console.log(settings.siteName) // "My Blog" // Full update (PUT) await client.single('site-settings').update({ siteName: 'New Name', logoUrl: {} }) // Partial update (PATCH) await client.single('site-settings').patch({ siteName: 'Patched Name' }) ``` -------------------------------- ### Custom Endpoint: featuredPosts Source: https://context7.com/mnfst/manifest-baas/llms.txt This custom endpoint, defined in `manifest.yml`, retrieves the 5 most-viewed published posts. It is accessible via a GET request to the specified path. ```APIDOC ## GET /featured ### Description Returns the 5 most-viewed published posts. ### Method GET ### Endpoint /featured ### Policies - { access: public } ### Handler featuredPosts ``` -------------------------------- ### Create a New Manifest Project Source: https://github.com/mnfst/manifest-baas/blob/master/README.md Run this command to initialize a new project using Manifest. This is the first step to setting up your 1-file backend. ```bash # Using npx npx create-manifest@latest # Using Yarn yarn create manifest ``` -------------------------------- ### Initialize SvelteKit Application Source: https://github.com/mnfst/manifest-baas/blob/master/packages/create-manifest/assets/monorepo/web-readme.md Use this command to create a new SvelteKit application. ```bash npm create svelte@latest . ``` -------------------------------- ### Build Project Source: https://github.com/mnfst/manifest-baas/blob/master/packages/js-sdk/sandbox/README.md Execute this command to compile your project. Build artifacts are stored in the dist/ directory. Production builds are optimized for performance. ```bash ng build ``` -------------------------------- ### Get a Single Item by ID Source: https://github.com/mnfst/manifest-baas/blob/master/packages/js-sdk/README.md Retrieve a single item from a specified entity by its unique ID. ```javascript // Get cat with ID `2c4e6a8b-0d1f-4357-9ace-bdf024681357`. const cat = await manifest .from('cats') .findOneById('2c4e6a8b-0d1f-4357-9ace-bdf024681357') ``` -------------------------------- ### Create a New Manifest Project Source: https://github.com/mnfst/manifest-baas/blob/master/packages/create-manifest/README.md Use NPM or Yarn to create a new project. The CLI will prompt for the project name if not provided. ```bash # NPM npx create-manifest@latest ``` ```bash # Yarn yarn create manifest ``` -------------------------------- ### Publish Manifest Package Source: https://github.com/mnfst/manifest-baas/blob/master/packages/create-manifest/README.md Build the project and publish it to the registry using npm commands. ```bash npm run build npm publish ``` -------------------------------- ### Initialize Vite React Application Source: https://github.com/mnfst/manifest-baas/blob/master/packages/create-manifest/assets/monorepo/web-readme.md Use this command to create a new Vite-based React application with TypeScript. ```bash npm create vite@latest . -- --template react-ts ``` -------------------------------- ### Initialize Next.js Application Source: https://github.com/mnfst/manifest-baas/blob/master/packages/create-manifest/assets/monorepo/web-readme.md Use this command to create a new Next.js application with TypeScript and Tailwind CSS support. ```bash npx create-next-app@latest . --typescript --tailwind ``` -------------------------------- ### REST API: Get Single Collection Item Source: https://context7.com/mnfst/manifest-baas/llms.txt Auto-generated endpoint to retrieve a single item from a collection by its UUID. ```APIDOC ## GET /api/collections/:entity/:uuid ### Description Retrieves a single item from a specified collection using its unique identifier (UUID). ### Method GET ### Endpoint /api/collections/:entity/:uuid ### Parameters #### Path Parameters - **entity** (string) - Required - The name of the collection. - **uuid** (string) - Required - The UUID of the item to retrieve. ### Response #### Success Response (200) - **(object)** - The requested collection item with its properties. ### Request Example ```bash curl http://localhost:1111/api/collections/posts/550e8400-e29b-41d4-a716-446655440000 ``` ``` -------------------------------- ### Set Up AI Code Editor Rules Source: https://github.com/mnfst/manifest-baas/blob/master/packages/create-manifest/README.md Add flags to the create-manifest command to configure rules for specific AI code editors like Cursor, GitHub Copilot, or Windsurf. ```bash npx create-manifest@latest --cursor ``` ```bash npx create-manifest@latest --copilot ``` ```bash npx create-manifest@latest --windsurf ``` -------------------------------- ### Run Project Tests Source: https://github.com/mnfst/manifest-baas/blob/master/CONTRIBUTING.md Execute this command to run the project's test suite. ```bash npm run test ``` -------------------------------- ### Initialize Manifest SDK Client Source: https://github.com/mnfst/manifest-baas/blob/master/packages/js-sdk/README.md Import and initialize the Manifest client. You can specify a custom base URL for the API endpoint. ```javascript import Manifest from '@mnfst/sdk' // Initialize client (default: http://localhost:1111, or pass a custom base URL) const manifest = new Manifest('https://example.com') // Perform CRUD operations... const posts = await manifest.from('posts').find() ``` -------------------------------- ### Contribute to Manifest JS SDK Source: https://github.com/mnfst/manifest-baas/blob/master/packages/js-sdk/README.md Instructions for contributing to the SDK, including setting up the sandbox environment for development. ```bash cd sandbox npm install npm run start ``` -------------------------------- ### List All Posts with Pagination and Filtering Source: https://context7.com/mnfst/manifest-baas/llms.txt Demonstrates how to list all posts using the auto-generated REST API. Supports pagination, ordering, filtering with operator suffixes, and loading relations. ```bash # List all posts (paginated, 20 per page by default) curl http://localhost:1111/api/collections/posts # Response: # { # "data": [ { "id": "uuid", "title": "Hello", "isPublic": false, ... } ], # "currentPage": 1, # "lastPage": 3, # "from": 1, # "to": 20, # "total": 55, # "perPage": 20 # } # Pagination & ordering curl "http://localhost:1111/api/collections/posts?page=2&perPage=5&orderBy=views&order=DESC" # Filtering — every filter key must include an operator suffix (_eq, _gt, _gte, _lt, _lte, _ne, _like, _in, _null) curl "http://localhost:1111/api/collections/posts?status_eq=published&views_gte=100" # Load relations curl "http://localhost:1111/api/collections/posts?relations=author,tags" # Get a single record by UUID curl http://localhost:1111/api/collections/posts/550e8400-e29b-41d4-a716-446655440000 ``` -------------------------------- ### Collections - Read Operations Source: https://context7.com/mnfst/manifest-baas/llms.txt Demonstrates how to fetch collections of data using the SDK, including pagination, filtering, ordering, and loading related data. ```APIDOC ## Collections - Read Operations ### Description Fetch paginated lists of items from a collection, apply filters, order results, and load related entities. ### Method `client.from(collectionName).find(options?: { page?: number; perPage?: number }): Promise>` `client.from(collectionName).where(condition: string).andWhere(condition: string).orderBy(field: string, direction?: { asc?: boolean; desc?: boolean }): this` `client.from(collectionName).with(relations: string[]): this` ### Endpoint N/A (SDK methods) ### Parameters #### `find` method options - **page** (number) - Optional - The page number to retrieve. - **perPage** (number) - Optional - The number of items per page. #### `where` and `andWhere` conditions - Supports operators: `=`, `!=`, `>`, `>=`, `<`, `<=`, `LIKE`, `IN`, `IS NULL`. #### `orderBy` parameters - **field** (string) - Required - The field to sort by. - **direction** (object) - Optional - Sorting direction. Can be `{ desc: true }` or `{ asc: true }`. #### `with` parameters - **relations** (string[]) - Required - An array of relation names to load. ### Request Example ```typescript // Paginated list const result = await client.from('posts').find({ page: 1, perPage: 10 }) // Filtering and Ordering const published = await client .from('posts') .where('status = published') .andWhere('views >= 100') .orderBy('publishedAt', { desc: true }) .find() // Loading relations const withAuthor = await client .from('posts') .with(['author', 'tags']) .find() ``` ### Response #### Success Response (Paginator) - **data** (T[]) - An array of items. - **total** (number) - The total number of items across all pages. - **lastPage** (number) - The last page number. #### Response Example ```json { "data": [ { "id": "uuid", "title": "Post Title", "content": "Post Content" }, // ... more posts ], "total": 55, "lastPage": 6 } ``` ``` -------------------------------- ### User Signup Source: https://context7.com/mnfst/manifest-baas/llms.txt Registers a new user. This endpoint requires the signup policy for the entity to be set to 'public'. ```bash curl -X POST http://localhost:1111/api/auth/authors/signup \ -H "Content-Type: application/json" \ -d '{ "email": "bob@example.com", "password": "mypassword" }' ``` -------------------------------- ### Create Collection Item Source: https://context7.com/mnfst/manifest-baas/llms.txt Use this endpoint to create a new item in a collection. Ensure the Authorization header is set with a valid token. ```bash curl -X POST http://localhost:1111/api/collections/posts \ -H "Content-Type: application/json" \ -H "Authorization: Bearer " \ -d '{ "title": "My Post", "content": "Hello world", "isPublic": true }' ``` -------------------------------- ### Run Unit Tests Source: https://github.com/mnfst/manifest-baas/blob/master/packages/js-sdk/sandbox/README.md Use this command to execute unit tests with the Karma test runner. ```bash ng test ``` -------------------------------- ### Authentication Methods Source: https://context7.com/mnfst/manifest-baas/llms.txt Handles user authentication including login, signup, and logout. ```APIDOC ## Authentication Methods ### Description Manage user authentication within the application, including signing up new users, logging in existing users, and logging out. ### Method `client.login(entity: string, email: string, password: string): Promise<{ token: string }>` `client.signup(entity: string, email: string, password: string): Promise` `client.logout(): void` ### Endpoint N/A (SDK methods) ### Parameters - **entity** (string) - Required - The entity type for authentication (e.g., 'authors'). - **email** (string) - Required - The user's email address. - **password** (string) - Required - The user's password. ### Request Example ```typescript // Login const { token } = await client.login('authors', 'alice@example.com', 'secret123') // Signup await client.signup('authors', 'bob@example.com', 'mypassword') // Logout client.logout() ``` ### Response #### Success Response (Login) - **token** (string) - The authentication token. #### Success Response (Signup, Logout) - No content returned. #### Response Example (Login) ```json { "token": "your_jwt_token_here" } ``` ``` -------------------------------- ### Seed Dummy Data Source: https://github.com/mnfst/manifest-baas/blob/master/examples/main-demo/README.md Populates the project with dummy data for entities and properties. This command will delete any existing data before seeding. ```bash npm run seed ``` -------------------------------- ### Configure Manifest Environment Variables Source: https://context7.com/mnfst/manifest-baas/llms.txt Set environment variables in a .env file to configure the Manifest server, database connection, storage, file paths, and other operational settings. ```bash # Server PORT=1111 NODE_ENV=production # development | production BASE_URL=https://api.example.com TOKEN_SECRET_KEY=your-secret-key-replace-me # Database (SQLite by default; set DB_HOST to switch to PostgreSQL or MySQL) # SQLite (default) DB_PATH=.manifest/db.sqlite # PostgreSQL DB_HOST=localhost DB_PORT=5432 DB_USERNAME=postgres DB_PASSWORD=postgres DB_DATABASE=myapp DB_SSL=false # MySQL # DB_HOST=localhost # DB_PORT=3306 # DB_USERNAME=root # DB_PASSWORD=password # DB_DATABASE=myapp # S3-compatible storage (optional; falls back to local ./public/storage/) S3_BUCKET=my-bucket S3_ENDPOINT=https://s3.amazonaws.com S3_REGION=us-east-1 S3_ACCESS_KEY_ID=AKIAIOSFODNN7EXAMPLE S3_SECRET_ACCESS_KEY=wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY S3_FOLDER_PREFIX=uploads # Manifest file location (default: ./manifest.yml) MANIFEST_FILE_PATH=./manifest.yml # Handlers folder (default: ./handlers) MANIFEST_HANDLERS_FOLDER=./handlers # OpenAPI docs (always on in development; disable in production) OPEN_API_DOCS=false # Telemetry MANIFEST_TELEMETRY_DISABLED=true ``` -------------------------------- ### Admin Login Source: https://context7.com/mnfst/manifest-baas/llms.txt Logs in the built-in admin user. Default credentials are admin@manifest.build / admin. ```bash curl -X POST http://localhost:1111/api/auth/admins/login \ -H "Content-Type: application/json" \ -d '{ "email": "admin@manifest.build", "password": "admin" }' ``` -------------------------------- ### Run Manifest E2E Tests Source: https://github.com/mnfst/manifest-baas/blob/master/packages/core/manifest/e2e/README.md Execute the End-to-End tests for the Manifest core package using the npm script. ```bash npm run test:e2e ``` -------------------------------- ### Reference for Manifest Property Types Source: https://context7.com/mnfst/manifest-baas/llms.txt Lists all available property types for defining entities in manifest.yml, including their basic usage and common options. ```yaml entities: Example: properties: - { name: title, type: string } # Short text (default type) - { name: body, type: text } # Long text / textarea - { name: article, type: richText } # Rich text / HTML - { name: count, type: number } # Integer or float - { name: url, type: link } # URL string - { name: cost, type: money, options: { currency: EUR } } - { name: dob, type: date } # Date (YYYY-MM-DD) - { name: createdAt, type: timestamp } # ISO datetime - { name: contact, type: email } # Email address - { name: active, type: boolean } # true/false - { name: secret, type: password } # Hashed on save, never returned - { name: tier, type: choice, options: { values: [free, pro, enterprise] } } - { name: coords, type: location } # { lat, lng } - { name: resume, type: file } # File upload - { name: avatar, type: image, options: { sizes: { sm: { width: 64, height: 64 } } } } - { name: address, type: group, options: { group: AddressGroup, multiple: false } } ``` -------------------------------- ### Authentication Methods Source: https://context7.com/mnfst/manifest-baas/llms.txt Manage user authentication using `client.login()`, `client.signup()`, and `client.logout()`. `client.from('entity').me()` retrieves the currently logged-in user. ```typescript import Manifest from '@mnfst/sdk' const client = new Manifest('http://localhost:1111') // Login — stores Bearer token internally for subsequent requests const { token } = await client.login('authors', 'alice@example.com', 'secret123') // Signup — also logs the user in await client.signup('authors', 'bob@example.com', 'mypassword') // Get current user const me = await client.from('authors').me() console.log(me.email) // "alice@example.com" // Logout — removes the Authorization header client.logout() ``` -------------------------------- ### Configure Webhooks for Entity Events in manifest.yml Source: https://context7.com/mnfst/manifest-baas/llms.txt Set up webhooks to trigger HTTP requests on entity lifecycle events like `afterCreate` or `beforeDelete`. Specify the URL, method, and headers for the webhook. ```yaml entities: Order: properties: - { name: total, type: money, options: { currency: USD } } - { name: status, type: choice, options: { values: [pending, shipped, delivered] } } hooks: afterCreate: - url: "https://notifications.example.com/webhook" method: POST headers: Authorization: "Bearer secret-token" X-Source: manifest afterUpdate: - url: "https://analytics.example.com/events" method: POST beforeDelete: - url: "https://audit.example.com/log" method: GET ``` -------------------------------- ### User Login Source: https://context7.com/mnfst/manifest-baas/llms.txt Authenticates a user and returns a JWT token. Requires the entity to have authentication policies enabled. ```bash curl -X POST http://localhost:1111/api/auth/authors/login \ -H "Content-Type: application/json" \ -d '{ "email": "alice@example.com", "password": "secret123" }' ``` -------------------------------- ### File and Image Uploads Source: https://context7.com/mnfst/manifest-baas/llms.txt Upload files or images using `client.from().upload()` and `client.from().uploadImage()`. Use `client.imageUrl()` to construct absolute URLs for stored images. ```typescript import Manifest from '@mnfst/sdk' const client = new Manifest('http://localhost:1111') await client.login('authors', 'alice@example.com', 'secret123') // Upload a file (Blob / File) const fileInput = document.querySelector('#file-input')! const { path } = await client.from('posts').upload('attachment', fileInput.files![0]) console.log(path) // "http://localhost:1111/storage/posts/attachment/Jan2025/abc-document.pdf" // Upload an image — returns an object with one key per configured size const imgInput = document.querySelector('#image-input')! const imagePaths = await client.from('posts').uploadImage('coverImage', imgInput.files![0]) console.log(imagePaths) // { thumb: "http://.../.../xyz-thumb.jpg", hero: "http://.../.../xyz-hero.jpg" } // Helper to build the absolute URL for a stored image const absoluteUrl = client.imageUrl(imagePaths, 'hero') console.log(absoluteUrl) // "http://localhost:1111/storage/posts/cover-image/Jan2025/xyz-hero.jpg" ``` -------------------------------- ### Implement Custom Endpoint Handler (createOrder.js) Source: https://context7.com/mnfst/manifest-baas/llms.txt JavaScript handler for creating an order. It uses a try-catch block to handle potential errors during the creation process and returns the created order or an error message. ```javascript // handlers/createOrder.js module.exports = async (req, res, manifest) => { try { const order = await manifest.from('orders').create({ total: req.body.total, status: 'pending', userId: req.body.userId }) res.status(201).json(order) } catch (err) { res.status(400).json({ error: err.message }) } } ``` -------------------------------- ### Generate New Component Source: https://github.com/mnfst/manifest-baas/blob/master/packages/js-sdk/sandbox/README.md Use this command to generate a new component using Angular CLI's code scaffolding tools. ```bash ng generate component component-name ``` -------------------------------- ### Custom Endpoints Source: https://context7.com/mnfst/manifest-baas/llms.txt Define custom API routes in `manifest.yml` and implement their logic in JavaScript handler files. ```APIDOC ## GET /featured ### Description Returns top 5 published posts by views. ### Method GET ### Endpoint /featured ### Policies - access: public ### Handler featuredPosts ## POST /orders/create ### Description Creates a new order. ### Method POST ### Endpoint /orders/create ### Policies - access: restricted allow: User ### Handler createOrder ``` -------------------------------- ### Upload Image Source: https://context7.com/mnfst/manifest-baas/llms.txt Uploads an image, automatically resizing it into all configured sizes. Uses multipart/form-data encoding. ```bash curl -X POST http://localhost:1111/api/upload/image \ -H "Authorization: Bearer " \ -F "image=@/path/to/photo.jpg" \ -F "entity=posts" \ -F "property=coverImage" ``` -------------------------------- ### Define Custom Endpoints in manifest.yml Source: https://context7.com/mnfst/manifest-baas/llms.txt Define custom API routes in manifest.yml, specifying the path, method, description, handler function, and access policies. ```yaml # manifest.yml endpoints: featuredPosts: path: /featured method: GET description: Returns top 5 published posts by views. handler: featuredPosts policies: - { access: public } createOrder: path: /orders/create method: POST handler: createOrder policies: - { access: restricted, allow: User } ``` -------------------------------- ### Webhooks (Hooks) Source: https://context7.com/mnfst/manifest-baas/llms.txt Configure webhooks to trigger HTTP requests on entity lifecycle events. ```APIDOC ## Order Entity Webhooks ### Hooks - `afterCreate`: - url: "https://notifications.example.com/webhook" method: POST headers: Authorization: "Bearer secret-token" X-Source: manifest - `afterUpdate`: - url: "https://analytics.example.com/events" method: POST - `beforeDelete`: - url: "https://audit.example.com/log" method: GET ``` -------------------------------- ### Store Relations for a New Item Source: https://github.com/mnfst/manifest-baas/blob/master/packages/js-sdk/README.md Create a new item and associate it with existing related entities by providing their IDs. ```javascript // Store a new player with relations Team and Skill. const newPlayer = await manifest.from('players').create({ name: 'Mike', teamId: 'e4d5c6b7-a890-4123-9876-543210fedcba', skillIds: [ '12345678-1234-5678-9abc-123456789012', '3f2504e0-4f89-11d3-9a0c-0305e82c3301' ] }) ``` -------------------------------- ### Run End-to-End Tests Source: https://github.com/mnfst/manifest-baas/blob/master/packages/js-sdk/sandbox/README.md Execute end-to-end tests. Angular CLI does not include an end-to-end testing framework by default. ```bash ng e2e ``` -------------------------------- ### File and Image Upload Source: https://context7.com/mnfst/manifest-baas/llms.txt Handles uploading files and images to storage, with specific support for image resizing. ```APIDOC ## File and Image Upload ### Description Upload files and images to the Manifest BaaS storage. Image uploads can generate multiple resized versions. ### Method `client.from(collectionName).upload(storagePath: string, file: Blob | File): Promise<{ path: string }>` `client.from(collectionName).uploadImage(storagePath: string, file: Blob | File): Promise>` `client.imageUrl(imagePaths: Record, size: string): string` ### Endpoint N/A (SDK methods) ### Parameters - **collectionName** (string) - Required - The name of the collection associated with the upload. - **storagePath** (string) - Required - The path within the storage bucket. - **file** (Blob | File) - Required - The file to upload. - **size** (string) - Required for `imageUrl` - The desired image size (e.g., 'thumb', 'hero'). ### Request Example ```typescript // Upload a file const fileInput = document.querySelector('#file-input')! const { path } = await client.from('posts').upload('attachment', fileInput.files![0]) // Upload an image (generates multiple sizes) const imgInput = document.querySelector('#image-input')! const imagePaths = await client.from('posts').uploadImage('coverImage', imgInput.files![0]) // Get absolute URL for a specific image size const absoluteUrl = client.imageUrl(imagePaths, 'hero') ``` ### Response #### Success Response (upload) - **path** (string) - The absolute URL of the uploaded file. #### Success Response (uploadImage) - An object where keys are image size names and values are their respective URLs. #### Response Example (upload) ```json { "path": "http://localhost:1111/storage/posts/attachment/Jan2025/abc-document.pdf" } ``` #### Response Example (uploadImage) ```json { "thumb": "http://.../.../xyz-thumb.jpg", "hero": "http://.../.../xyz-hero.jpg" } ``` ``` -------------------------------- ### Create a New Item Source: https://github.com/mnfst/manifest-baas/blob/master/packages/js-sdk/README.md Create a new item in a specified entity (e.g., 'pokemons') with provided data. ```javascript // Create a new item in the "pokemons" entity. const newPokemon = await manifest.from('pokemons').create({ name: 'Pikachu', type: 'electric', level: 3 }) ``` -------------------------------- ### Read, Filter, and Load Relations for Collections Source: https://context7.com/mnfst/manifest-baas/llms.txt Use `client.from()` to fetch paginated lists of records, filter them using `where()` and `andWhere()`, and load related data with `with()`. Supports various comparison operators and ordering. ```typescript import Manifest from '@mnfst/sdk' const client = new Manifest('http://localhost:1111') // --- Read --- // Paginated list (returns Paginator) const result = await client.from('posts').find({ page: 1, perPage: 10 }) console.log(result.data) // Post[] console.log(result.total) // 55 console.log(result.lastPage) // 6 // Filtering with where() / andWhere() — supports =, !=, >, >=, <, <=, LIKE, IN, IS NULL const published = await client .from('posts') .where('status = published') .andWhere('views >= 100') .orderBy('publishedAt', { desc: true }) .find() // Load relations const withAuthor = await client .from('posts') .with(['author', 'tags']) .find() // Find by UUID const post = await client.from('posts').findOneById('550e8400-e29b-41d4-a716-446655440000') ``` -------------------------------- ### Write Operations for Collections Source: https://context7.com/mnfst/manifest-baas/llms.txt Perform create, update, patch, and delete operations on collection entities using `client.from()`. Requires prior authentication via `client.login()`. ```typescript await client.login('authors', 'alice@example.com', 'secret123') const newPost = await client.from('posts').create({ title: 'Hello Manifest', content: 'Getting started...', isPublic: true }) const updated = await client.from('posts').update(newPost.id, { title: 'Updated Title', content: 'Full replacement.', isPublic: false }) const patched = await client.from('posts').patch(newPost.id, { views: 99 }) await client.from('posts').delete(newPost.id) ``` -------------------------------- ### File and Image Upload Source: https://context7.com/mnfst/manifest-baas/llms.txt Endpoints for uploading files and images, with automatic resizing for images. ```APIDOC ## POST /api/upload/file ### Description Uploads a file to a specified entity property. ### Method POST ### Endpoint /api/upload/file ### Headers - **Authorization** (string) - Required - Bearer token. ### Form Data - **file** (file) - Required - The file to upload. - **entity** (string) - Required - The entity the file belongs to. - **property** (string) - Required - The property of the entity for the file. ### Response #### Success Response (200) - **path** (string) - The URL path to the uploaded file. ### Response Example ```json { "path": "http://localhost:1111/storage/posts/attachment/Jan2025/abc123-document.pdf" } ``` ## POST /api/upload/image ### Description Uploads an image, which is automatically resized into all configured sizes. ### Method POST ### Endpoint /api/upload/image ### Headers - **Authorization** (string) - Required - Bearer token. ### Form Data - **image** (file) - Required - The image file to upload. - **entity** (string) - Required - The entity the image belongs to. - **property** (string) - Required - The property of the entity for the image. ### Response #### Success Response (200) - **thumb** (string) - URL path to the thumbnail version of the image. - **hero** (string) - URL path to the hero version of the image. ### Response Example ```json { "thumb": "http://localhost:1111/storage/posts/cover-image/Jan2025/xyz-thumb.jpg", "hero": "http://localhost:1111/storage/posts/cover-image/Jan2025/xyz-hero.jpg" } ``` ``` -------------------------------- ### Implement Custom Endpoint Handler (featuredPosts.js) Source: https://context7.com/mnfst/manifest-baas/llms.txt JavaScript handler function for a custom endpoint. It receives request, response, and manifest objects, and uses the BackendSDK to query data. ```javascript // handlers/featuredPosts.js // Receives (req, res, manifest) — manifest is the BackendSDK instance module.exports = async (req, res, manifest) => { const result = await manifest .from('posts') .where('status = published') .orderBy('views', { desc: true }) .find({ perPage: 5 }) res.json(result.data) } ``` -------------------------------- ### Load Relations for Items Source: https://github.com/mnfst/manifest-baas/blob/master/packages/js-sdk/README.md Fetch items along with their related entities. Supports loading multiple and nested relations. ```javascript // Fetch entities with 2 relations. const cities = await manifest.from('cities').with(['region', 'mayor']).find() // Fetch nested relations. const cities = await manifest .from('cities') .with(['region', 'region.country', 'region.country.planet']) .find() ``` -------------------------------- ### Upload File Source: https://context7.com/mnfst/manifest-baas/llms.txt Uploads a file to a specified entity and property. Uses multipart/form-data encoding. ```bash curl -X POST http://localhost:1111/api/upload/file \ -H "Authorization: Bearer " \ -F "file=@/path/to/document.pdf" \ -F "entity=posts" \ -F "property=attachment" ``` -------------------------------- ### Middleware Handlers Source: https://context7.com/mnfst/manifest-baas/llms.txt Implement server-side logic to run before or after CRUD operations using middleware handlers. ```APIDOC ## Post Entity Middlewares ### Middlewares - `beforeCreate`: - handler: generateSlug - `afterCreate`: - handler: sendWelcomeEmail ``` -------------------------------- ### Authentication Endpoints Source: https://context7.com/mnfst/manifest-baas/llms.txt Endpoints for user authentication, including login, signup, and retrieving current user information. ```APIDOC ## POST /api/auth/:entity/login ### Description Logs in a user and returns a JWT token. ### Method POST ### Endpoint /api/auth/:entity/login ### Request Body - **email** (string) - Required - The user's email address. - **password** (string) - Required - The user's password. ### Request Example ```json { "email": "alice@example.com", "password": "secret123" } ``` ### Response #### Success Response (200) - **token** (string) - The JWT token. ### Response Example ```json { "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..." } ``` ## POST /api/auth/:entity/signup ### Description Signs up a new user. Requires the signup policy to be public. ### Method POST ### Endpoint /api/auth/:entity/signup ### Request Body - **email** (string) - Required - The user's email address. - **password** (string) - Required - The user's password. ### Request Example ```json { "email": "bob@example.com", "password": "mypassword" } ``` ### Response #### Success Response (200) - **token** (string) - The JWT token for the newly created user. ## GET /api/auth/:entity/me ### Description Retrieves information about the currently authenticated user. ### Method GET ### Endpoint /api/auth/:entity/me ### Headers - **Authorization** (string) - Required - Bearer token. ### Response #### Success Response (200) - **id** (string) - The user's ID. - **email** (string) - The user's email address. - **name** (string) - The user's name. ### Response Example ```json { "id": "uuid", "email": "alice@example.com", "name": "Alice" } ``` ``` -------------------------------- ### Define Middleware Handlers in manifest.yml Source: https://context7.com/mnfst/manifest-baas/llms.txt Configure middleware functions to run server-side logic before or after CRUD operations on an entity. Specify the handler name for events like `beforeCreate` or `afterCreate`. ```yaml entities: Post: properties: - title - { name: slug, type: string } middlewares: beforeCreate: - handler: generateSlug afterCreate: - handler: sendWelcomeEmail ``` -------------------------------- ### Full Update Collection Item Source: https://context7.com/mnfst/manifest-baas/llms.txt Use PUT to replace an entire existing item in a collection. Fields not included in the request body will be cleared. ```bash curl -X PUT http://localhost:1111/api/collections/posts/550e8400-e29b-41d4-a716-446655440000 \ -H "Content-Type: application/json" \ -H "Authorization: Bearer " \ -d '{ "title": "Updated Title", "content": "New content", "isPublic": true }' ``` -------------------------------- ### Collections - Write Operations Source: https://context7.com/mnfst/manifest-baas/llms.txt Enables creating, updating, patching, and deleting records within a collection. Requires authentication. ```APIDOC ## Collections - Write Operations ### Description Perform create, update, patch, and delete operations on records within a collection. Authentication is required. ### Method `client.from(collectionName).create(data: Partial): Promise` `client.from(collectionName).update(id: string, data: Partial): Promise` `client.from(collectionName).patch(id: string, data: Partial): Promise` `client.from(collectionName).delete(id: string): Promise` ### Endpoint N/A (SDK methods) ### Parameters - **id** (string) - Required - The UUID of the item to update, patch, or delete. - **data** (object) - Required - The data payload for create, update, or patch operations. ### Request Example ```typescript // Create a new post const newPost = await client.from('posts').create({ title: 'Hello Manifest', content: 'Getting started...', isPublic: true }) // Update a post const updated = await client.from('posts').update(newPost.id, { title: 'Updated Title', content: 'Full replacement.', isPublic: false }) // Patch a post const patched = await client.from('posts').patch(newPost.id, { views: 99 }) // Delete a post await client.from('posts').delete(newPost.id) ``` ### Response #### Success Response (Create, Update, Patch) - Returns the created, updated, or patched item. #### Success Response (Delete) - Returns `void` (no content). #### Response Example (Create/Update/Patch) ```json { "id": "generated-uuid", "title": "Hello Manifest", "content": "Getting started...", "isPublic": true } ``` ```