由 Tobias W. 出售

Sails.js is an enterprise-grade MVC framework for Node.js that makes it easy to build data-oriented web apps and REST APIs with realtime capabilities, built on Express and Socket.io.
This block contains the full Sails.js framework source (lib/), the MVC web framework built on Node.js, Express, and Socket.io. It exposes a singleton app instance plus a constructor for creating isolated Sails applications, complete with hooks for blueprints, ORM, HTTP, sessions, security, i18n, pubsub, and more. Typical buyers are teams embedding or extending Sails programmatically rather than using the CLI.
index.js — Entry point; exports a default Sails singleton and the Sails constructorapp/ — Core Sails application class: lift, load, lower, routing, actions, configurationapp/Sails.js — The Sails class definitionapp/configuration/ — Default config merging, hook resolution, .sailsrc loadingapp/private/ — Internal helpers: bootstrap, globals, hook loading, JSON inspectionhooks/ — All built-in hooks (blueprints, HTTP, session, security, views, i18n, etc.)hooks/blueprints/ — Auto-generated REST/socket routes for Waterline modelshooks/http/ — Express server setup and middleware pipelinehooks/pubsub/ — WebSocket room management via Socket.iohooks/security/ — CORS, CSRF (via @sailshq/csurf), and header hardeningrouter/ — Sails router: binds string routes to middleware/actionsutil/ — Internal utility helpers shared across the frameworkEVENTS.md — Documents all lifecycle events emitted by a Sails appREADME.md — Upstream project readmenpm install user@example.com
npm install @sailshq/lodash @sailshq/router @sailshq/csurf
npm install async captains-log chalk commander
npm install common-js-file-extensions compression connect
npm install cookie cookie-parser cookie-signature
npm install ejs express express-session
npm install flaverr glob i18n-2 include-all
npm install machine machine-as-action
npm install machinepack-process machinepack-redis
npm install merge-defaults pluralize sails-stringfile
No native build steps, pod installs, or binary linking are required. All dependencies are pure JavaScript.
Copy the directory into your project, e.g. .
启动隔离沙箱并在服务器端直接运行 — 无需本地配置。
此版本的 Tetrees AI Review
This JavaScript cli / script completed archive review with strong static results. Structure, dependency manifests, documentation, functional source, and common risk patterns were checked by the Tetrees verification pipeline; runtime phases are stated separately.
Deterministic AVCP artifact review
管道 avcp-2026-08-04.1 · SHA-256 7da9f4663f180917…
This version-scoped review deterministically inspects the submitted archive for structure, dependencies, documentation, functional source, and common malicious or high-risk signals. Build and test phases are reported as passed only after an isolated sandbox audition. It is not a guarantee of perfect security.
审查日期 2026年8月4日
将此产品直接导入你的 AI IDE、网页构建器或云端 IDE。
将 Tetrees 连接到兼容的 AI IDE,列出你拥有的产品并获取已验证 ZIP,同时不会开放卖家上传权限。
暂无评价。
Sign in to join the discussion
Loading discussion…
source/src/sails-lib/The source is CommonJS. If your project uses TypeScript, add a path alias in tsconfig.json:
{
"compilerOptions": {
"paths": {
"sails-lib": ["./src/sails-lib/index.js"]
}
}
}
Use ts-node -r tsconfig-paths/register or module-alias at runtime.
Set required environment variables before lifting:
NODE_ENV=development # or production / staging
PORT=1337 # HTTP port
Optional .sailsrc in your project root controls which hooks load and overrides config:
{
"hooks": { "grunt": false },
"port": 3000
}
Point appPath to your project root when calling sails.load() or sails.lift() programmatically (see examples below).
module.exports (default singleton)import sails = require('./source/index');
// sails is an instance of Sails
sails.lift(config: object, cb: (err: Error | null) => void): void;
sails.load(config: object, cb: (err: Error | null) => void): void;
sails.lower(cb?: (err: Error | null) => void): void;
The default export is a pre-instantiated Sails app. Use sails.lift() to start the HTTP server and all hooks, sails.load() to initialize without binding a port, and sails.lower() to gracefully shut down.
Sails (constructor)import { Sails } = require('./source/index');
// or:
const Sails = require('./source/index').Sails;
const app: SailsApp = new Sails();
app.lift({ appPath: __dirname, port: 3000 }, (err) => { ... });
Use the constructor when you need multiple isolated Sails instances in the same process — for example, in tests or multi-tenant scenarios. Each new Sails() carries its own config, hooks, and router.
SailsFactory (functional factory from app/index.js)const SailsFactory = require('./source/app/index');
const app = SailsFactory(); // returns new Sails()
// Static helpers bound to an internal singleton:
SailsFactory.isLocalSailsValid(localSailsPath: string, appPath: string): boolean;
SailsFactory.isSailsAppSync(dirPath: string): boolean;
SailsFactory can be called as a function (no new) for convenience. isLocalSailsValid is useful when building CLI tooling that detects whether a project directory has a valid local Sails install. isSailsAppSync synchronously checks if a directory looks like a Sails project.
Embed a Sails server inside an existing Node.js process without the CLI. Useful for testing or embedding Sails inside a larger orchestration layer.
const { Sails } = require('./source/index');
const app = new Sails();
app.lift(
{
appPath: __dirname,
port: 1337,
environment: 'development',
hooks: {
grunt: false, // disable asset pipeline
},
log: { level: 'warn' },
},
(err) => {
if (err) {
console.error('Failed to lift:', err);
process.exit(1);
}
console.log(`Sails lifted on port ${app.config.port}`);
}
);
Use sails.load() to initialize all hooks and the ORM without binding a TCP port. Ideal for running model-level tests or seeding a database.
const { Sails } = require('./source/index');
let app: any;
beforeAll((done) => {
app = new Sails();
app.load(
{
appPath: __dirname,
environment: 'test',
hooks: { grunt: false, views: false, blueprints: false },
orm: { migrate: 'safe' },
},
done
);
});
afterAll((done) => {
app.lower(done);
});
test('User model exists', () => {
expect(app.models.user).toBeDefined();
});
Use the static helpers exposed by SailsFactory to build tooling that validates project directories before attempting to lift.
const SailsFactory = require('./source/app/index');
const path = require('path');
const targetDir = path.resolve(process.argv[2] || '.');
if (!SailsFactory.isSailsAppSync(targetDir)) {
console.error(`${targetDir} does not appear to be a Sails app.`);
process.exit(1);
}
if (!SailsFactory.isLocalSailsValid(targetDir, targetDir)) {
console.warn('Local Sails install may be outdated or missing.');
}
console.log('Project looks valid. Proceeding...');
index.js — Instantiates and exports a Sails singleton; also exports the Sails constructor as .Sails and .constructor.app/index.js — SailsFactory callable factory; exposes isLocalSailsValid and isSailsAppSync as static methods.app/Sails.js — The core Sails class with all instance methods attached.app/lift.js — Implements sails.lift(): loads hooks then starts the HTTP server.app/load.js — Implements sails.load(): runs configuration, loads hooks, skips HTTP bind.app/lower.js — Graceful shutdown: closes server, tears down hooks.app/configuration/ — Merges defaults, resolves hook paths, reads .sailsrc.app/configuration/default-hooks.js — Canonical list of built-in hooks by identity.app/private/ — Internal lifecycle helpers (bootstrap, global exposure, hook loading).hooks/index.js — Hook constructor; all built-in hooks are instances of this.hooks/blueprints/ — Generates implicit CRUD + association REST routes for models.hooks/http/ — Configures the Express app, middleware stack, and static file serving.hooks/session/ — Express-session integration with configurable store.hooks/security/ — CORS policy, CSRF token middleware, clickjacking headers.hooks/pubsub/ — Socket.io room helpers (subscribe, publish, unsubscribe).hooks/views/ — Template engine configuration (EJS by default).hooks/policies/ — Loads and applies policy middleware to routes.hooks/i18n/ — Locale detection and translation via i18n-2.router/ — Core route binding layer between string patterns and middleware.util/ — Shared internal utilities used across hooks and the app module.appPath missing causes a fatal error — always pass appPath: __dirname (or the project root) in config; the framework throws synchronously if it is absent.sails.lift() calls on the singleton — the default export is a shared singleton; use new Sails() for each isolated instance in tests or you will get port-conflict errors.NODE_ENV not set — without userconfig hook or explicit environment config, the framework defaults to 'development'; set it explicitly in production to avoid config leaks.config or middleware properties reserved — defining a custom hook method named config or middleware throws E_INVALID_HOOK_CONFIG; rename your method.require() or createRequire from ESM; import sails from 'sails' will not resolve the named Sails export correctly without an interop shim.sails-hook-orm plus an adapter (sails-disk, sails-mysql, etc.) before expecting CRUD routes.I have the Sails.js framework source in `source/` (sails@1.5.17, lib/ directory)
and a usage guide in `USAGE.md`. I want you to integrate this into my existing
Node.js/TypeScript project step by step.
Context:
- Source root: source/ (index.js exports a Sails singleton and Sails constructor)
- Upstream package: user@example.com
- Guide: USAGE.md (read it first for real API signatures and import paths)
Tasks:
1. Install all dependencies listed in USAGE.md ## Required dependencies.
2. Create a `server.ts` (or `server.js`) that imports `Sails` from `./source/index`,
constructs a new instance, and calls `.lift()` with appPath set to the project root,
respecting the PORT environment variable.
3. Create a `test/sails.test.ts` that uses `sails.load()` (no HTTP) to test a model.
4. Wire the path alias in tsconfig.json if TypeScript is used.
5. Add a `start` and `test` script in package.json.
6. Show me every file you create or modify, with full content.
Do not invent any Sails APIs; use only the symbols documented in USAGE.md.
Sails.js is released under the MIT License. See source/LICENSE if present, or the official repository at https://github.com/balderdashy/sails. Upstream npm package: sails. Website and documentation: https://sailsjs.com.
This product’s unique contribution is clean room implementation of valuable code block into AVCP compatible standard.
完整安装指南与集成提示词将在购买后解锁。
Automation, Utilities & Developer Tools
免费