Edit Page

api/

This folder contains the vast majority of your app's back-end logic. It is home to the 'M' and 'C' in MVC Framework.

In it you will find the following:

  • Controllers: Actions contain back-end logic that handle incoming requests (like handling a form submission or responding with personalized, server-rendered HTML).
  • Helpers: Helpers are shared functions that can be called from anywhere in your app.
  • Models: Models are the structures that contain data for your Sails App.
  • Policies: Policies are middleware that restrict access to certain actions in your app.

You may also find these folders, which are not always generated by default in new Sails apps:

  • Hooks: Hooks are modules that add functionality to Sails core. You can use hooks to run custom code when your app lifts and before handling every incoming request. Hooks can also be installed as plugins, but the hooks in this folder are always custom for your application.
  • Responses: Custom responses can help maintain consistent HTTP status codes and behavior across your app. (Since not every Sails application needs to define its own custom responses, this folder is sometimes excluded.)
  • Services: Services are shared utilities common in Sails apps written before version 1.0. They can be just about anything, so for new apps, it's recommended that you use helpers instead.

Want to see for yourself?

An example of this directory can be found in our sample app repo, here.

Sails logo
  • Home
  • Get started
  • Support
  • Documentation
  • Documentation

For a better experience on sailsjs.com, update your browser.

Check out the full Sailsconf 2022 playlist on Youtube

Tweet Follow @sailsjs

Documentation

Reference Concepts App structure | Upgrading Contribution guide | Tutorials More

App Structure


  • api
    • controllers
      • .gitkeep
    • helpers
      • .gitkeep
    • models
      • .gitkeep
    • policies
      • .gitkeep
  • assets
    • dependencies
      • sails.io.js
    • images
      • .gitkeep
    • js
      • .gitkeep
    • styles
      • importer.less
    • templates
      • .gitkeep
    • .eslintrc
    • favicon.ico
  • config
    • env
      • production.js
    • locales
      • de.json
      • en.json
      • es.json
      • fr.json
    • blueprints.js
    • bootstrap.js
    • custom.js
    • datastores.js
    • globals.js
    • http.js
    • i18n.js
    • local.js
    • log.js
    • models.js
    • policies.js
    • routes.js
    • security.js
    • session.js
    • sockets.js
    • views.js
  • tasks
    • config
      • babel.js
      • clean.js
      • coffee.js
      • concat.js
      • copy.js
      • cssmin.js
      • hash.js
      • jst.js
      • less.js
      • sails-linker.js
      • sync.js
      • uglify.js
      • watch.js
    • register
      • build.js
      • buildProd.js
      • compileAssets.js
      • default.js
      • linkAssets.js
      • linkAssetsBuild.js
      • linkAssetsBuildProd.js
      • polyfill.js
      • prod.js
      • syncAssets.js
    • pipeline.js
  • views
    • layouts
      • layout.ejs
    • pages
      • homepage.ejs
    • .eslintrc
    • 404.ejs
    • 500.ejs
  • .editorconfig
  • .eslintignore
  • .eslintrc
  • .gitignore
  • .htmlhintrc
  • .sailsrc
  • app.js
  • Gruntfile.js
  • package.json
  • README.md

Built with Love

The Sails framework is built by a web & mobile shop in Austin, TX, with the help of our contributors. We created Sails in 2012 to assist us on Node.js projects. Naturally we open-sourced it. We hope it makes your life a little bit easier!

Sails:
  • What is Sails?
  • Community
  • News
  • For business
About:
  • Our company
  • Security
  • Legal
  • Logos/artwork
Help:
  • Get started
  • Documentation
  • Docs
  • Contribute
  • Take a class

© 2012-2023 The Sails Company. 
The Sails framework is free and open-source under the MIT License. 
Illustrations by Edamame.