{"id":15051,"library":"warp-server","title":"Warp Server ORM","description":"Warp Server is an Object-Relational Mapper (ORM) designed for scalable web applications, currently at version 6.8.7. It provides a structured approach to defining database schemas, including tables, columns with validation, and triggers for pre- and post-operation hooks. Developers can build complex queries, implement server-side functions for custom business logic, and enforce access restrictions based on user roles. A key differentiator is its built-in support for implementing RESTful APIs via an Express middleware. As of now, it exclusively supports MySQL, with the roadmap indicating plans for additional database adapters in future releases. The project maintains a stable release cadence, with version 6.x being the current focus, explicitly differentiating its documentation and usage from older versions 5.x and legacy releases.","status":"active","version":"6.8.7","language":"javascript","source_language":"en","source_url":"https://github.com/dividedbyzeroco/warp-server","tags":["javascript","warp","server","typescript"],"install":[{"cmd":"npm install warp-server","lang":"bash","label":"npm"},{"cmd":"yarn add warp-server","lang":"bash","label":"yarn"},{"cmd":"pnpm add warp-server","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Required for decorator-based class definition and metadata reflection in TypeScript.","package":"reflect-metadata","optional":false},{"reason":"Commonly used for building RESTful APIs with Warp's middleware functionality.","package":"express","optional":true}],"imports":[{"note":"Warp is primarily designed for ESM environments, especially with TypeScript. CommonJS require() may lead to undefined or incorrect module resolution if not configured properly with tools like Babel or TypeScript's `esModuleInterop`.","wrong":"const Warp = require('warp-server');","symbol":"Warp","correct":"import Warp from 'warp-server';"},{"note":"Decorators like `@Class` and `@Key` are used for defining schemas. While often placed in a 'decorators' subpath, the primary module export is indicated here. This import path is inferred based on common ORM patterns and requires review as not explicitly shown in the truncated README.","wrong":"import { Class } from 'warp-server/decorators';","symbol":"Class","correct":"import { Class, Key } from 'warp-server';"},{"note":"This is a side-effect import and should be done once, ideally at the entry point of your application, to enable decorator metadata emission.","symbol":"reflect-metadata","correct":"import 'reflect-metadata';"}],"quickstart":{"code":"import 'reflect-metadata';\nimport Warp from 'warp-server';\n\n// Replace with your actual database connection string\nconst databaseURI = 'mysql://youruser:password@yourserver.com:3306/yourdatabase?charset=utf8';\n\nconst service = new Warp({ databaseURI });\n\nasync function startService() {\n  try {\n    await service.initialize();\n    console.log('Warp service initialized successfully. You can now define and interact with your models.');\n    // Example: You would define your classes and start querying here.\n    // @Class()\n    // class User {\n    //   @Key({ primary: true, autoIncrement: true }) id: number;\n    //   @Key() name: string;\n    // }\n    // service.define(User);\n    // const newUser = await service.create(User, { name: 'John Doe' });\n    // console.log('New user created:', newUser);\n  } catch (error) {\n    console.error('Failed to initialize Warp service:', error);\n  }\n}\n\nstartService();","lang":"typescript","description":"Initializes a Warp service instance with a MySQL database connection, demonstrating the basic setup and asynchronous initialization."},"warnings":[{"fix":"Refer to the `readme-v6.md` (or relevant version) documentation for migration guides and updated API usage. Do not mix dependencies from different major versions.","message":"Warp Server versions 6.x introduce significant changes and are not backward compatible with versions 5.x or legacy versions. Consult the version-specific documentation to avoid issues.","severity":"breaking","affected_versions":">=6.0.0"},{"fix":"Add or ensure the presence of `\"experimentalDecorators\": true` and `\"emitDecoratorMetadata\": true` in your `tsconfig.json`'s `\"compilerOptions\"`.","message":"To utilize decorators (e.g., for class and key definitions), your `tsconfig.json` must have `\"experimentalDecorators\": true` and `\"emitDecoratorMetadata\": true` configured under `\"compilerOptions\"`.","severity":"gotcha","affected_versions":">=6.0.0"},{"fix":"Install `reflect-metadata` via `npm install --save reflect-metadata` and add `import 'reflect-metadata';` at the very top of your main application file (e.g., `index.ts`).","message":"The `reflect-metadata` library is a mandatory peer dependency for Warp Server when using TypeScript decorators. It must be installed and imported once at the application's entry point.","severity":"gotcha","affected_versions":">=6.0.0"},{"fix":"Ensure your `databaseURI` is configured for a MySQL connection. Check the documentation for updates on support for other database systems if needed.","message":"Currently, Warp Server officially supports only MySQL databases. While other adapters are planned, direct usage with other database systems is not supported and will result in errors.","severity":"gotcha","affected_versions":">=6.0.0"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"Ensure `import 'reflect-metadata';` is at the top of your main application file and `\"emitDecoratorMetadata\": true` is in your `tsconfig.json`.","cause":"`reflect-metadata` library was not imported or `emitDecoratorMetadata` is not enabled.","error":"ReferenceError: Reflect is not defined"},{"fix":"Use ES Module `import Warp from 'warp-server';` syntax. If using Node.js, ensure your package.json has `\"type\": \"module\"` or your file uses the `.mjs` extension, and/or your TypeScript compiler options (`moduleResolution`, `esModuleInterop`) are correctly set for ESM.","cause":"Attempting to use CommonJS `require()` syntax or incorrect module resolution when `warp-server` is an ES Module.","error":"TypeError: Warp is not a constructor"}],"ecosystem":"npm"}