{"id":16203,"library":"sails-generate-api","title":"Sails API Generator","description":"sails-generate-api is a command-line interface (CLI) generator for the Sails.js framework, designed to scaffold boilerplate files for API models and controllers. Specifically, it creates `api/models/Foo.js` and `api/controllers/FooController.js` for a given API name. This package is from the 0.x era of Sails.js, with its last publication being 9 years ago and current version 0.10.1. The current stable version of Sails.js is 1.5.x, which introduced significant breaking changes from its 0.x predecessors, including a revamped generator architecture. Therefore, `sails-generate-api` is not compatible with modern Sails.js applications (v1.x and above) and should be considered abandoned.","status":"abandoned","version":"0.10.1","language":"javascript","source_language":"en","source_url":null,"tags":["javascript","controller","model","api","generator","sails","generate","plugin"],"install":[{"cmd":"npm install sails-generate-api","lang":"bash","label":"npm"},{"cmd":"yarn add sails-generate-api","lang":"bash","label":"yarn"},{"cmd":"pnpm add sails-generate-api","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Runtime dependency as it's a generator specifically for the Sails.js framework. Requires a pre-1.0 version of Sails.js.","package":"sails","optional":false}],"imports":[{"note":"This package is a CommonJS module from the 0.x era. It exports an object defining the generator's behavior (e.g., targets, templates). Direct programmatic use is uncommon as it's primarily consumed by the Sails CLI system.","symbol":"generatorDefinition","correct":"const generatorDefinition = require('sails-generate-api');"},{"note":"While a generator typically defines a 'generate' process, direct named export of such a function is not standard for this type of Sails 0.x generator module. This illustrates accessing a hypothetical internal method via CommonJS destructuring. ESM imports (`import`) are not supported.","wrong":"import { generate } from 'sails-generate-api';","symbol":"generate","correct":"const { generate } = require('sails-generate-api'); // If an internal `generate` function were exposed"},{"note":"Sails generators are integrated by configuring the `.sailsrc` file to map a generator name (e.g., 'api') to its npm package. There is no typical 'default import' symbol for developers to use in their application code; the Sails CLI internally handles loading the generator module.","wrong":"import ApiGeneratorModule from 'sails-generate-api';","symbol":"ApiGeneratorModule","correct":"// No direct application-level import for CLI generators.\n// Configured via .sailsrc instead."}],"quickstart":{"code":"{\n  \"generators\": {\n    \"modules\": {\n      \"api\": \"sails-generate-api\"\n    }\n  }\n}\n\n// Save the above JSON to ./.sailsrc in your project directory\n// or ~/.sailsrc for global use.\n\n// Then, from your Sails project directory:\n// $ npm install sails-generate-api\n// $ sails generate api foobar\n\n// This will create:\n// - api/models/Foobar.js\n// - api/controllers/FoobarController.js","lang":"javascript","description":"Demonstrates how to install, configure, and use the `sails-generate-api` generator to create new API files in a Sails 0.x project."},"warnings":[{"fix":"For Sails v1.x+, use the built-in `sails generate api` command, or implement a custom generator following the v1.x generator conventions which are significantly different.","message":"This package is designed for Sails.js versions 0.x and is incompatible with Sails.js v1.x and later. Major architectural changes, especially regarding the generator system, occurred in Sails v1.0.","severity":"breaking","affected_versions":">=1.0.0 of Sails.js"},{"fix":"Avoid using this package in new projects. For existing Sails 0.x projects, consider migrating to a newer Sails version or manually creating the required API files.","message":"The `sails-generate-api` package has not been updated in 9 years and is considered abandoned. Its dependencies and internal logic may rely on outdated Node.js features or insecure third-party packages.","severity":"deprecated","affected_versions":">=0.10.1"},{"fix":"Refer to the official Sails.js v1.x documentation for current generator configuration and extension practices.","message":"The `.sailsrc` configuration method for overriding or adding generators, as described in this package's README, is primarily for Sails 0.x. While `.sailsrc` still exists in Sails v1.x, the generator module structure and registration process have changed substantially.","severity":"gotcha","affected_versions":">=0.10.1"}],"env_vars":null,"last_verified":"2026-04-21T00:00:00.000Z","next_check":"2026-07-20T00:00:00.000Z","problems":[{"fix":"Ensure you are using Sails.js v0.x (specifically, within the ~0.10.0 range) with this generator. For example, `npm install sails@~0.10.0` globally or locally alongside the generator.","cause":"Attempting to install or use `sails-generate-api` with a newer version of Sails.js (e.g., v1.x+) or without any Sails.js installation, which is a peer dependency.","error":"Error: sails-generate-api@0.10.1 requires a peer of sails@~0.10.0 but none was installed."},{"fix":"Verify that `sails-generate-api` is installed and that your `.sailsrc` file (either local `./.sailsrc` or global `~/.sailsrc`) correctly maps `\"api\": \"sails-generate-api\"` within the `generators.modules` section. Ensure the `sails generate` command is executed from a directory where the `.sailsrc` configuration is active.","cause":"The `sails-generate-api` package was installed but the `.sailsrc` file was not correctly configured to point to it, or it was configured for a local installation but `sails generate` was run in a different directory.","error":"Error: sails-generate-api not found.\nError: Generator \"api\" could not be loaded from \"sails-generate-api\""}],"ecosystem":"npm"}