",
13 | "license": "Apache 2.0",
14 | "preferGlobal": true,
15 | "main": "index.js",
16 | "repository": {
17 | "type": "git",
18 | "url": "https://github.com/swagger-api/swagger-node.git"
19 | },
20 | "dependencies": {
21 | "async": "^2.1.4",
22 | "commander": "^2.7.1",
23 | "connect": "^3.3.5",
24 | "debug": "^2.1.3",
25 | "fs-extra": "^1.0.0",
26 | "inquirer": "^1.2.3",
27 | "js-yaml": "^3.3.0",
28 | "lodash": "^4.17.2",
29 | "mocha": "^3.2.0",
30 | "nodemon": "^1.3.7",
31 | "serve-static": "^1.9.2",
32 | "swagger-converter": "^1.4.1",
33 | "swagger-editor": "^2.9.2",
34 | "swagger-test-templates": "^1.2.0",
35 | "swagger-tools": "^0.10.1"
36 | },
37 | "devDependencies": {
38 | "chai": "^3.0.0",
39 | "mock-stdin": "^0.3.0",
40 | "proxyquire": "^1.4.0",
41 | "should": "^11.1.1",
42 | "sinon": "^1.15.4",
43 | "superagent": "^3.1.0",
44 | "supertest": "^2.0.1",
45 | "tmp": "^0.0.31",
46 | "z-schema": "^3.14.0"
47 | },
48 | "scripts": {
49 | "test": "mocha -u exports -R spec test/config.js test/util test/commands test/commands/project test/project-skeletons",
50 | "coverage": "istanbul cover _mocha -- -u exports -R spec test/config.js test/util test/commands test/commands/project test/project-skeletons",
51 | "start": "node app.js"
52 | },
53 | "bin": {
54 | "swagger": "bin/swagger.js",
55 | "swagger-project": "bin/swagger-project.js"
56 | }
57 | }
--------------------------------------------------------------------------------
/project-skeletons/connect/.gitignore:
--------------------------------------------------------------------------------
1 | # IDE files
2 | .idea
3 |
4 | # Logs
5 | logs
6 | *.log
7 |
8 | # Runtime data
9 | pids
10 | *.pid
11 | *.seed
12 |
13 | # Directory for instrumented libs generated by jscoverage/JSCover
14 | lib-cov
15 |
16 | # Coverage directory used by tools like istanbul
17 | coverage
18 |
19 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
20 | .grunt
21 |
22 | # Compiled binary addons (http://nodejs.org/api/addons.html)
23 | build/Release
24 |
25 | # Dependency directory
26 | # Commenting this out is preferred by some people, see
27 | # https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git
28 | node_modules
29 |
30 | # Users Environment Variables
31 | .lock-wscript
32 |
33 | # Runtime configuration for swagger app
34 | config/runtime.yaml
35 |
--------------------------------------------------------------------------------
/project-skeletons/connect/README.md:
--------------------------------------------------------------------------------
1 | # Skeleton project for Swagger
2 |
--------------------------------------------------------------------------------
/project-skeletons/connect/api/controllers/README.md:
--------------------------------------------------------------------------------
1 | Place your controllers in this directory.
2 |
--------------------------------------------------------------------------------
/project-skeletons/connect/api/controllers/hello_world.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | /*
3 | 'use strict' is not required but helpful for turning syntactical errors into true errors in the program flow
4 | https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode
5 | */
6 |
7 | /*
8 | Modules make it possible to import JavaScript files into your application. Modules are imported
9 | using 'require' statements that give you a reference to the module.
10 |
11 | It is a good idea to list the modules that your application depends on in the package.json in the project root
12 | */
13 | var util = require('util');
14 |
15 | /*
16 | Once you 'require' a module you can reference the things that it exports. These are defined in module.exports.
17 |
18 | For a controller in a127 (which this is) you should export the functions referenced in your Swagger document by name.
19 |
20 | Either:
21 | - The HTTP Verb of the corresponding operation (get, put, post, delete, etc)
22 | - Or the operationId associated with the operation in your Swagger document
23 |
24 | In the starter/skeleton project the 'get' operation on the '/hello' path has an operationId named 'hello'. Here,
25 | we specify that in the exports of this module that 'hello' maps to the function named 'hello'
26 | */
27 | module.exports = {
28 | hello: hello
29 | };
30 |
31 | /*
32 | Functions in a127 controllers used for operations should take two parameters:
33 |
34 | Param 1: a handle to the request object
35 | Param 2: a handle to the response object
36 | */
37 | function hello(req, res) {
38 | // variables defined in the Swagger document can be referenced using req.swagger.params.{parameter_name}
39 | var name = req.swagger.params.name.value || 'stranger';
40 | var hello = util.format('Hello, %s!', name);
41 |
42 | // this sends back a JSON response which is a single string
43 | res.json({ "message": hello });
44 | }
45 |
--------------------------------------------------------------------------------
/project-skeletons/connect/api/helpers/README.md:
--------------------------------------------------------------------------------
1 | Place helper files in this directory.
2 |
--------------------------------------------------------------------------------
/project-skeletons/connect/api/mocks/README.md:
--------------------------------------------------------------------------------
1 | Place controllers for mock mode in this directory.
2 |
--------------------------------------------------------------------------------
/project-skeletons/connect/api/swagger/swagger.yaml:
--------------------------------------------------------------------------------
1 | swagger: "2.0"
2 | info:
3 | version: "0.0.1"
4 | title: Hello World App
5 | # during dev, should point to your local machine
6 | host: localhost:10010
7 | # basePath prefixes all resource paths
8 | basePath: /
9 | #
10 | schemes:
11 | # tip: remove http to make production-grade
12 | - http
13 | - https
14 | # format of bodies a client can send (Content-Type)
15 | consumes:
16 | - application/json
17 | # format of the responses to the client (Accepts)
18 | produces:
19 | - application/json
20 | paths:
21 | /hello:
22 | # binds a127 app logic to a route
23 | x-swagger-router-controller: hello_world
24 | get:
25 | description: Returns 'Hello' to the caller
26 | # used as the method name of the controller
27 | operationId: hello
28 | parameters:
29 | - name: name
30 | in: query
31 | description: The name of the person to whom to say hello
32 | required: false
33 | type: string
34 | responses:
35 | "200":
36 | description: Success
37 | schema:
38 | # a pointer to a definition
39 | $ref: "#/definitions/HelloWorldResponse"
40 | # responses may fall through to errors
41 | default:
42 | description: Error
43 | schema:
44 | $ref: "#/definitions/ErrorResponse"
45 | /swagger:
46 | x-swagger-pipe: swagger_raw
47 | # complex objects have schema definitions
48 | definitions:
49 | HelloWorldResponse:
50 | type: string
51 | ErrorResponse:
52 | required:
53 | - message
54 | properties:
55 | message:
56 | type: string
57 |
--------------------------------------------------------------------------------
/project-skeletons/connect/app.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var SwaggerConnect = require('swagger-connect');
4 | var app = require('connect')();
5 | // export setup Promis for testing
6 | module.exports = new Promise(function (resolve, reject) {
7 | var config = {
8 | appRoot: __dirname // required config
9 | };
10 |
11 | SwaggerConnect.create(config, function (err, swaggerConnect) {
12 | if (err) { throw err; }
13 |
14 | // install middleware
15 | swaggerConnect.register(app);
16 |
17 | var port = process.env.PORT || 10010;
18 | app.listen(port);
19 |
20 | if (swaggerConnect.runner.swagger.paths['/hello']) {
21 | console.log('try this:\ncurl http://127.0.0.1:' + port + '/hello?name=Scott');
22 | }
23 | resolve(app);
24 | });
25 | });
--------------------------------------------------------------------------------
/project-skeletons/connect/config/README.md:
--------------------------------------------------------------------------------
1 | Place configuration files in this directory.
2 |
--------------------------------------------------------------------------------
/project-skeletons/connect/config/default.yaml:
--------------------------------------------------------------------------------
1 | # swagger configuration file
2 |
3 | # values in the swagger hash are system configuration for swagger-node
4 | swagger:
5 |
6 | fittingsDirs: [ api/fittings ]
7 | defaultPipe: null
8 | swaggerControllerPipe: swagger_controllers # defines the standard processing pipe for controllers
9 |
10 | # values defined in the bagpipes key are the bagpipes pipes and fittings definitions
11 | # (see https://github.com/apigee-127/bagpipes)
12 | bagpipes:
13 |
14 | _router:
15 | name: swagger_router
16 | mockMode: false
17 | mockControllersDirs: [ api/mocks ]
18 | controllersDirs: [ api/controllers ]
19 |
20 | _swagger_validate:
21 | name: swagger_validator
22 | validateResponse: true
23 |
24 | # pipe for all swagger-node controllers
25 | swagger_controllers:
26 | - onError: json_error_handler
27 | - cors
28 | - swagger_params_parser
29 | - swagger_security
30 | - _swagger_validate
31 | - express_compatibility
32 | - _router
33 |
34 | # pipe to serve swagger (endpoint is in swagger.yaml)
35 | swagger_raw:
36 | name: swagger_raw
37 |
38 | # any other values in this file are just loaded into the config for application access...
39 |
--------------------------------------------------------------------------------
/project-skeletons/connect/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "swagger-app",
3 | "version": "0.0.1",
4 | "private": true,
5 | "description": "New Swagger API Project",
6 | "keywords": [],
7 | "author": "",
8 | "license": "",
9 | "main": "app.js",
10 | "dependencies": {
11 | "connect": "^3.6.0",
12 | "swagger-connect": "^0.7.0"
13 | },
14 | "devDependencies": {
15 | "should": "^11.2.1",
16 | "supertest": "^3.0.0"
17 | },
18 | "scripts": {
19 | "start": "node app.js",
20 | "test": "swagger project test"
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/project-skeletons/connect/test/api/controllers/README.md:
--------------------------------------------------------------------------------
1 | Place your controller tests in this directory.
2 |
--------------------------------------------------------------------------------
/project-skeletons/connect/test/api/controllers/hello_world.js:
--------------------------------------------------------------------------------
1 | var should = require('should');
2 | var request = require('supertest');
3 | var server = require('../../../app');
4 |
5 | describe('controllers', function() {
6 |
7 | describe('hello_world', function() {
8 |
9 | describe('GET /hello', function() {
10 |
11 | it('should return a default string', function(done) {
12 |
13 | request(server)
14 | .get('/hello')
15 | .set('Accept', 'application/json')
16 | .expect('Content-Type', /json/)
17 | .expect(200)
18 | .end(function(err, res) {
19 | should.not.exist(err);
20 |
21 | res.body.should.eql({ "message": "Hello, stranger!" });
22 |
23 | done();
24 | });
25 | });
26 |
27 | it('should accept a name parameter', function(done) {
28 |
29 | request(server)
30 | .get('/hello')
31 | .query({ name: 'Scott'})
32 | .set('Accept', 'application/json')
33 | .expect('Content-Type', /json/)
34 | .expect(200)
35 | .end(function(err, res) {
36 | should.not.exist(err);
37 |
38 | res.body.should.eql({ "message": "Hello, Scott!" });
39 |
40 | done();
41 | });
42 | });
43 |
44 | });
45 |
46 | });
47 |
48 | });
49 |
--------------------------------------------------------------------------------
/project-skeletons/connect/test/api/helpers/README.md:
--------------------------------------------------------------------------------
1 | Place your helper tests in this directory.
2 |
--------------------------------------------------------------------------------
/project-skeletons/express/app.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var SwaggerExpress = require('swagger-express-mw');
4 | var app = require('express')();
5 | // export setup Promis for testing
6 | module.exports = new Promise(function (resolve, reject) {
7 |
8 | var config = {
9 | appRoot: __dirname // required config
10 | };
11 |
12 | SwaggerExpress.create(config, function (err, swaggerExpress) {
13 | if (err) { throw err; }
14 |
15 | // install middleware
16 | swaggerExpress.register(app);
17 |
18 | var port = process.env.PORT || 10010;
19 | app.listen(port, function() {
20 | if (swaggerExpress.runner.swagger.paths['/hello']) {
21 | console.log('try this:\ncurl http://127.0.0.1:' + port + '/hello?name=Scott');
22 | }
23 | resolve(app);
24 | });
25 | });
26 | });
--------------------------------------------------------------------------------
/project-skeletons/express/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "swagger-app",
3 | "version": "0.0.1",
4 | "private": true,
5 | "description": "New Swagger API Project",
6 | "keywords": [],
7 | "author": "",
8 | "license": "",
9 | "main": "app.js",
10 | "dependencies": {
11 | "express": "^4.15.2",
12 | "swagger-express-mw": "^0.7.0"
13 | },
14 | "devDependencies": {
15 | "should": "^11.2.1",
16 | "supertest": "^3.0.0"
17 | },
18 | "scripts": {
19 | "start": "node app.js",
20 | "test": "swagger project test"
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/project-skeletons/hapi/app.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var SwaggerHapi = require('swagger-hapi');
4 | var Hapi = require('hapi');
5 | var app = new Hapi.Server();
6 |
7 | // export setup Promis for testing
8 | module.exports = new Promise(function (resolve, reject) {
9 |
10 | var config = {
11 | appRoot: __dirname // required config
12 | };
13 |
14 | SwaggerHapi.create(config, function (err, swaggerHapi) {
15 | if (err) { throw err; }
16 |
17 | var port = process.env.PORT || 10010;
18 | app.connection({ port: port });
19 | app.address = function () {
20 | return { port: port };
21 | };
22 |
23 | app.register(swaggerHapi.plugin, function (err) {
24 | if (err) {
25 | console.error('Failed to load plugin:', err);
26 | reject(err);
27 | }
28 | app.start(function () {
29 | if (swaggerHapi.runner.swagger.paths['/hello']) {
30 | console.log('try this:\ncurl http://127.0.0.1:' + port + '/hello?name=Scott');
31 | }
32 | resolve(app);
33 | });
34 | });
35 | });
36 | });
37 |
--------------------------------------------------------------------------------
/project-skeletons/hapi/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "swagger-app",
3 | "version": "0.0.1",
4 | "private": true,
5 | "description": "New Swagger API Project",
6 | "keywords": [],
7 | "author": "",
8 | "license": "",
9 | "main": "app.js",
10 | "dependencies": {
11 | "hapi": "^16.1.1",
12 | "swagger-hapi": "^0.7.0"
13 | },
14 | "devDependencies": {
15 | "should": "^11.2.1",
16 | "supertest": "^3.0.0"
17 | },
18 | "scripts": {
19 | "start": "node app.js",
20 | "test": "swagger project test"
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/project-skeletons/restify/app.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var SwaggerRestify = require('swagger-restify-mw');
4 | var restify = require('restify');
5 | var app = restify.createServer();
6 |
7 | // export setup Promis for testing
8 | module.exports = new Promise(function (resolve, reject) {
9 |
10 | var config = {
11 | appRoot: __dirname // required config
12 | };
13 |
14 | SwaggerRestify.create(config, function (err, swaggerRestify) {
15 | if (err) { throw err; }
16 |
17 | swaggerRestify.register(app);
18 |
19 | var port = process.env.PORT || 10010;
20 | app.listen(port, function () {
21 | if (swaggerRestify.runner.swagger.paths['/hello']) {
22 | console.log('try this:\ncurl http://127.0.0.1:' + port + '/hello?name=Scott');
23 | }
24 | resolve(app);
25 | });
26 | });
27 | });
--------------------------------------------------------------------------------
/project-skeletons/restify/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "swagger-app",
3 | "version": "0.0.1",
4 | "private": true,
5 | "description": "New Swagger API Project",
6 | "keywords": [],
7 | "author": "",
8 | "license": "",
9 | "main": "app.js",
10 | "dependencies": {
11 | "restify": "^4.3.0",
12 | "swagger-restify-mw": "^0.7.0"
13 | },
14 | "devDependencies": {
15 | "should": "^11.2.1",
16 | "supertest": "^3.0.0"
17 | },
18 | "scripts": {
19 | "start": "node app.js",
20 | "test": "swagger project test"
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/project-skeletons/sails/.editorconfig:
--------------------------------------------------------------------------------
1 | # editorconfig.org
2 | root = true
3 |
4 | [*]
5 | indent_style = space
6 | indent_size = 2
7 | end_of_line = lf
8 | charset = utf-8
9 | trim_trailing_whitespace = true
10 | insert_final_newline = true
11 |
--------------------------------------------------------------------------------
/project-skeletons/sails/.gitignore:
--------------------------------------------------------------------------------
1 | ################################################
2 | ############### .gitignore ##################
3 | ################################################
4 | #
5 | # This file is only relevant if you are using git.
6 | #
7 | # Files which match the splat patterns below will
8 | # be ignored by git. This keeps random crap and
9 | # sensitive credentials from being uploaded to
10 | # your repository. It allows you to configure your
11 | # app for your machine without accidentally
12 | # committing settings which will smash the local
13 | # settings of other developers on your team.
14 | #
15 | # Some reasonable defaults are included below,
16 | # but, of course, you should modify/extend/prune
17 | # to fit your needs!
18 | ################################################
19 |
20 |
21 |
22 |
23 | ################################################
24 | # Local Configuration
25 | #
26 | # Explicitly ignore files which contain:
27 | #
28 | # 1. Sensitive information you'd rather not push to
29 | # your git repository.
30 | # e.g., your personal API keys or passwords.
31 | #
32 | # 2. Environment-specific configuration
33 | # Basically, anything that would be annoying
34 | # to have to change every time you do a
35 | # `git pull`
36 | # e.g., your local development database, or
37 | # the S3 bucket you're using for file uploads
38 | # development.
39 | #
40 | ################################################
41 |
42 | config/local.js
43 |
44 |
45 |
46 |
47 |
48 | ################################################
49 | # Dependencies
50 | #
51 | # When releasing a production app, you may
52 | # consider including your node_modules and
53 | # bower_components directory in your git repo,
54 | # but during development, its best to exclude it,
55 | # since different developers may be working on
56 | # different kernels, where dependencies would
57 | # need to be recompiled anyway.
58 | #
59 | # More on that here about node_modules dir:
60 | # http://www.futurealoof.com/posts/nodemodules-in-git.html
61 | # (credit Mikeal Rogers, @mikeal)
62 | #
63 | # About bower_components dir, you can see this:
64 | # http://addyosmani.com/blog/checking-in-front-end-dependencies/
65 | # (credit Addy Osmani, @addyosmani)
66 | #
67 | ################################################
68 |
69 | node_modules
70 | bower_components
71 |
72 |
73 |
74 |
75 | ################################################
76 | # Sails.js / Waterline / Grunt
77 | #
78 | # Files generated by Sails and Grunt, or related
79 | # tasks and adapters.
80 | ################################################
81 | .tmp
82 | dump.rdb
83 |
84 |
85 |
86 |
87 |
88 | ################################################
89 | # Node.js / NPM
90 | #
91 | # Common files generated by Node, NPM, and the
92 | # related ecosystem.
93 | ################################################
94 | lib-cov
95 | *.seed
96 | *.log
97 | *.out
98 | *.pid
99 | npm-debug.log
100 |
101 |
102 |
103 |
104 |
105 | ################################################
106 | # Miscellaneous
107 | #
108 | # Common files generated by text editors,
109 | # operating systems, file systems, etc.
110 | ################################################
111 |
112 | *~
113 | *#
114 | .DS_STORE
115 | .netbeans
116 | nbproject
117 | .idea
118 | .node_history
119 | .vscode
120 | .DS_STORE
--------------------------------------------------------------------------------
/project-skeletons/sails/.sailsrc:
--------------------------------------------------------------------------------
1 | {
2 | "generators": {
3 | "modules": {}
4 | }
5 | }
--------------------------------------------------------------------------------
/project-skeletons/sails/Gruntfile.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Gruntfile
3 | *
4 | * This Node script is executed when you run `grunt` or `sails lift`.
5 | * It's purpose is to load the Grunt tasks in your project's `tasks`
6 | * folder, and allow you to add and remove tasks as you see fit.
7 | * For more information on how this works, check out the `README.md`
8 | * file that was generated in your `tasks` folder.
9 | *
10 | * WARNING:
11 | * Unless you know what you're doing, you shouldn't change this file.
12 | * Check out the `tasks` directory instead.
13 | */
14 |
15 | module.exports = function(grunt) {
16 |
17 |
18 | // Load the include-all library in order to require all of our grunt
19 | // configurations and task registrations dynamically.
20 | var includeAll;
21 | try {
22 | includeAll = require('include-all');
23 | } catch (e0) {
24 | try {
25 | includeAll = require('sails/node_modules/include-all');
26 | } catch (e1) {
27 | console.error('Could not find `include-all` module.');
28 | console.error('Skipping grunt tasks...');
29 | console.error('To fix this, please run:');
30 | console.error('npm install include-all --save`');
31 | console.error();
32 |
33 | grunt.registerTask('default', []);
34 | return;
35 | }
36 | }
37 |
38 |
39 | /**
40 | * Loads Grunt configuration modules from the specified
41 | * relative path. These modules should export a function
42 | * that, when run, should either load/configure or register
43 | * a Grunt task.
44 | */
45 | function loadTasks(relPath) {
46 | return includeAll({
47 | dirname: require('path').resolve(__dirname, relPath),
48 | filter: /(.+)\.js$/,
49 | excludeDirs: /^\.(git|svn)$/
50 | }) || {};
51 | }
52 |
53 | /**
54 | * Invokes the function from a Grunt configuration module with
55 | * a single argument - the `grunt` object.
56 | */
57 | function invokeConfigFn(tasks) {
58 | for (var taskName in tasks) {
59 | if (tasks.hasOwnProperty(taskName)) {
60 | tasks[taskName](grunt);
61 | }
62 | }
63 | }
64 |
65 |
66 |
67 | // Load task functions
68 | var taskConfigurations = loadTasks('./tasks/config'),
69 | registerDefinitions = loadTasks('./tasks/register');
70 |
71 | // (ensure that a default task exists)
72 | if (!registerDefinitions.default) {
73 | registerDefinitions.default = function(grunt) {
74 | grunt.registerTask('default', []);
75 | };
76 | }
77 |
78 | // Run task functions to configure Grunt.
79 | invokeConfigFn(taskConfigurations);
80 | invokeConfigFn(registerDefinitions);
81 |
82 | };
83 |
--------------------------------------------------------------------------------
/project-skeletons/sails/README.md:
--------------------------------------------------------------------------------
1 | # A [Swagger](https://www.npmjs.com/package/swagger) / [Sails](http://sailsjs.org) application
2 |
--------------------------------------------------------------------------------
/project-skeletons/sails/api/controllers/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/swagger-api/swagger-node/fc777a61ccaf54076d0a3ffcfafedc347abc15ba/project-skeletons/sails/api/controllers/.gitkeep
--------------------------------------------------------------------------------
/project-skeletons/sails/api/controllers/hello_world.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | /*
3 | 'use strict' is not required but helpful for turning syntactical errors into true errors in the program flow
4 | https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode
5 | */
6 |
7 | /*
8 | Modules make it possible to import JavaScript files into your application. Modules are imported
9 | using 'require' statements that give you a reference to the module.
10 |
11 | It is a good idea to list the modules that your application depends on in the package.json in the project root
12 | */
13 | var util = require('util');
14 |
15 | /*
16 | Once you 'require' a module you can reference the things that it exports. These are defined in module.exports.
17 |
18 | For a controller in a127 (which this is) you should export the functions referenced in your Swagger document by name.
19 |
20 | Either:
21 | - The HTTP Verb of the corresponding operation (get, put, post, delete, etc)
22 | - Or the operationId associated with the operation in your Swagger document
23 |
24 | In the starter/skeleton project the 'get' operation on the '/hello' path has an operationId named 'hello'. Here,
25 | we specify that in the exports of this module that 'hello' maps to the function named 'hello'
26 | */
27 | module.exports = {
28 | hello: hello
29 | };
30 |
31 | /*
32 | Functions in a127 controllers used for operations should take two parameters:
33 |
34 | Param 1: a handle to the request object
35 | Param 2: a handle to the response object
36 | */
37 | function hello(req, res) {
38 | // variables defined in the Swagger document can be referenced using req.swagger.params.{parameter_name}
39 | var name = req.swagger.params.name.value || 'stranger';
40 | var hello = util.format('Hello, %s!', name);
41 |
42 | // this sends back a JSON response which is a single string
43 | res.json({ "message": hello });
44 | }
45 |
--------------------------------------------------------------------------------
/project-skeletons/sails/api/mocks/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/swagger-api/swagger-node/fc777a61ccaf54076d0a3ffcfafedc347abc15ba/project-skeletons/sails/api/mocks/.gitkeep
--------------------------------------------------------------------------------
/project-skeletons/sails/api/models/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/swagger-api/swagger-node/fc777a61ccaf54076d0a3ffcfafedc347abc15ba/project-skeletons/sails/api/models/.gitkeep
--------------------------------------------------------------------------------
/project-skeletons/sails/api/policies/sessionAuth.js:
--------------------------------------------------------------------------------
1 | /**
2 | * sessionAuth
3 | *
4 | * @module :: Policy
5 | * @description :: Simple policy to allow any authenticated user
6 | * Assumes that your login action in one of your controllers sets `req.session.authenticated = true;`
7 | * @docs :: http://sailsjs.org/#!/documentation/concepts/Policies
8 | *
9 | */
10 | module.exports = function(req, res, next) {
11 |
12 | // User is allowed, proceed to the next policy,
13 | // or if this is the last policy, the controller
14 | if (req.session.authenticated) {
15 | return next();
16 | }
17 |
18 | // User is not allowed
19 | // (default res.forbidden() behavior can be overridden in `config/403.js`)
20 | return res.forbidden('You are not permitted to perform this action.');
21 | };
22 |
--------------------------------------------------------------------------------
/project-skeletons/sails/api/responses/badRequest.js:
--------------------------------------------------------------------------------
1 | /**
2 | * 400 (Bad Request) Handler
3 | *
4 | * Usage:
5 | * return res.badRequest();
6 | * return res.badRequest(data);
7 | * return res.badRequest(data, 'some/specific/badRequest/view');
8 | *
9 | * e.g.:
10 | * ```
11 | * return res.badRequest(
12 | * 'Please choose a valid `password` (6-12 characters)',
13 | * 'trial/signup'
14 | * );
15 | * ```
16 | */
17 |
18 | module.exports = function badRequest(data, options) {
19 |
20 | // Get access to `req`, `res`, & `sails`
21 | var req = this.req;
22 | var res = this.res;
23 | var sails = req._sails;
24 |
25 | // Set status code
26 | res.status(400);
27 |
28 | // Log error to console
29 | if (data !== undefined) {
30 | sails.log.verbose('Sending 400 ("Bad Request") response: \n',data);
31 | }
32 | else sails.log.verbose('Sending 400 ("Bad Request") response');
33 |
34 | // Only include errors in response if application environment
35 | // is not set to 'production'. In production, we shouldn't
36 | // send back any identifying information about errors.
37 | if (sails.config.environment === 'production' && sails.config.keepResponseErrors !== true) {
38 | data = undefined;
39 | }
40 |
41 | // If the user-agent wants JSON, always respond with JSON
42 | // If views are disabled, revert to json
43 | if (req.wantsJSON || sails.config.hooks.views === false) {
44 | return res.jsonx(data);
45 | }
46 |
47 | // If second argument is a string, we take that to mean it refers to a view.
48 | // If it was omitted, use an empty object (`{}`)
49 | options = (typeof options === 'string') ? { view: options } : options || {};
50 |
51 | // Attempt to prettify data for views, if it's a non-error object
52 | var viewData = data;
53 | if (!(viewData instanceof Error) && 'object' == typeof viewData) {
54 | try {
55 | viewData = require('util').inspect(data, {depth: null});
56 | }
57 | catch(e) {
58 | viewData = undefined;
59 | }
60 | }
61 |
62 | // If a view was provided in options, serve it.
63 | // Otherwise try to guess an appropriate view, or if that doesn't
64 | // work, just send JSON.
65 | if (options.view) {
66 | return res.view(options.view, { data: viewData, title: 'Bad Request' });
67 | }
68 |
69 | // If no second argument provided, try to serve the implied view,
70 | // but fall back to sending JSON(P) if no view can be inferred.
71 | else return res.guessView({ data: viewData, title: 'Bad Request' }, function couldNotGuessView () {
72 | return res.jsonx(data);
73 | });
74 |
75 | };
76 |
77 |
--------------------------------------------------------------------------------
/project-skeletons/sails/api/responses/created.js:
--------------------------------------------------------------------------------
1 | /**
2 | * 201 (CREATED) Response
3 | *
4 | * Usage:
5 | * return res.created();
6 | * return res.created(data);
7 | * return res.created(data, 'auth/login');
8 | *
9 | * @param {Object} data
10 | * @param {String|Object} options
11 | * - pass string to render specified view
12 | */
13 |
14 | module.exports = function created (data, options) {
15 |
16 | // Get access to `req`, `res`, & `sails`
17 | var req = this.req;
18 | var res = this.res;
19 | var sails = req._sails;
20 |
21 | sails.log.silly('res.created() :: Sending 201 ("CREATED") response');
22 |
23 | // Set status code
24 | res.status(201);
25 |
26 | // If appropriate, serve data as JSON(P)
27 | // If views are disabled, revert to json
28 | if (req.wantsJSON || sails.config.hooks.views === false) {
29 | return res.jsonx(data);
30 | }
31 |
32 | // If second argument is a string, we take that to mean it refers to a view.
33 | // If it was omitted, use an empty object (`{}`)
34 | options = (typeof options === 'string') ? { view: options } : options || {};
35 |
36 | // Attempt to prettify data for views, if it's a non-error object
37 | var viewData = data;
38 | if (!(viewData instanceof Error) && 'object' == typeof viewData) {
39 | try {
40 | viewData = require('util').inspect(data, {depth: null});
41 | }
42 | catch(e) {
43 | viewData = undefined;
44 | }
45 | }
46 |
47 | // If a view was provided in options, serve it.
48 | // Otherwise try to guess an appropriate view, or if that doesn't
49 | // work, just send JSON.
50 | if (options.view) {
51 | return res.view(options.view, { data: viewData, title: 'Created' });
52 | }
53 |
54 | // If no second argument provided, try to serve the implied view,
55 | // but fall back to sending JSON(P) if no view can be inferred.
56 | else return res.guessView({ data: viewData, title: 'Created' }, function couldNotGuessView () {
57 | return res.jsonx(data);
58 | });
59 |
60 | };
61 |
--------------------------------------------------------------------------------
/project-skeletons/sails/api/responses/forbidden.js:
--------------------------------------------------------------------------------
1 | /**
2 | * 403 (Forbidden) Handler
3 | *
4 | * Usage:
5 | * return res.forbidden();
6 | * return res.forbidden(err);
7 | * return res.forbidden(err, 'some/specific/forbidden/view');
8 | *
9 | * e.g.:
10 | * ```
11 | * return res.forbidden('Access denied.');
12 | * ```
13 | */
14 |
15 | module.exports = function forbidden (data, options) {
16 |
17 | // Get access to `req`, `res`, & `sails`
18 | var req = this.req;
19 | var res = this.res;
20 | var sails = req._sails;
21 |
22 | // Set status code
23 | res.status(403);
24 |
25 | // Log error to console
26 | if (data !== undefined) {
27 | sails.log.verbose('Sending 403 ("Forbidden") response: \n',data);
28 | }
29 | else sails.log.verbose('Sending 403 ("Forbidden") response');
30 |
31 | // Only include errors in response if application environment
32 | // is not set to 'production'. In production, we shouldn't
33 | // send back any identifying information about errors.
34 | if (sails.config.environment === 'production' && sails.config.keepResponseErrors !== true) {
35 | data = undefined;
36 | }
37 |
38 | // If the user-agent wants JSON, always respond with JSON
39 | // If views are disabled, revert to json
40 | if (req.wantsJSON || sails.config.hooks.views === false) {
41 | return res.jsonx(data);
42 | }
43 |
44 | // If second argument is a string, we take that to mean it refers to a view.
45 | // If it was omitted, use an empty object (`{}`)
46 | options = (typeof options === 'string') ? { view: options } : options || {};
47 |
48 | // Attempt to prettify data for views, if it's a non-error object
49 | var viewData = data;
50 | if (!(viewData instanceof Error) && 'object' == typeof viewData) {
51 | try {
52 | viewData = require('util').inspect(data, {depth: null});
53 | }
54 | catch(e) {
55 | viewData = undefined;
56 | }
57 | }
58 |
59 | // If a view was provided in options, serve it.
60 | // Otherwise try to guess an appropriate view, or if that doesn't
61 | // work, just send JSON.
62 | if (options.view) {
63 | return res.view(options.view, { data: viewData, title: 'Forbidden' });
64 | }
65 |
66 | // If no second argument provided, try to serve the default view,
67 | // but fall back to sending JSON(P) if any errors occur.
68 | else return res.view('403', { data: viewData, title: 'Forbidden' }, function (err, html) {
69 |
70 | // If a view error occured, fall back to JSON(P).
71 | if (err) {
72 | //
73 | // Additionally:
74 | // • If the view was missing, ignore the error but provide a verbose log.
75 | if (err.code === 'E_VIEW_FAILED') {
76 | sails.log.verbose('res.forbidden() :: Could not locate view for error page (sending JSON instead). Details: ',err);
77 | }
78 | // Otherwise, if this was a more serious error, log to the console with the details.
79 | else {
80 | sails.log.warn('res.forbidden() :: When attempting to render error page view, an error occured (sending JSON instead). Details: ', err);
81 | }
82 | return res.jsonx(data);
83 | }
84 |
85 | return res.send(html);
86 | });
87 |
88 | };
89 |
90 |
--------------------------------------------------------------------------------
/project-skeletons/sails/api/responses/notFound.js:
--------------------------------------------------------------------------------
1 | /**
2 | * 404 (Not Found) Handler
3 | *
4 | * Usage:
5 | * return res.notFound();
6 | * return res.notFound(err);
7 | * return res.notFound(err, 'some/specific/notfound/view');
8 | *
9 | * e.g.:
10 | * ```
11 | * return res.notFound();
12 | * ```
13 | *
14 | * NOTE:
15 | * If a request doesn't match any explicit routes (i.e. `config/routes.js`)
16 | * or route blueprints (i.e. "shadow routes", Sails will call `res.notFound()`
17 | * automatically.
18 | */
19 |
20 | module.exports = function notFound (data, options) {
21 |
22 | // Get access to `req`, `res`, & `sails`
23 | var req = this.req;
24 | var res = this.res;
25 | var sails = req._sails;
26 |
27 | // Set status code
28 | res.status(404);
29 |
30 | // Log error to console
31 | if (data !== undefined) {
32 | sails.log.verbose('Sending 404 ("Not Found") response: \n',data);
33 | }
34 | else sails.log.verbose('Sending 404 ("Not Found") response');
35 |
36 | // Only include errors in response if application environment
37 | // is not set to 'production'. In production, we shouldn't
38 | // send back any identifying information about errors.
39 | if (sails.config.environment === 'production' && sails.config.keepResponseErrors !== true) {
40 | data = undefined;
41 | }
42 |
43 | // If the user-agent wants JSON, always respond with JSON
44 | // If views are disabled, revert to json
45 | if (req.wantsJSON || sails.config.hooks.views === false) {
46 | return res.jsonx(data);
47 | }
48 |
49 | // If second argument is a string, we take that to mean it refers to a view.
50 | // If it was omitted, use an empty object (`{}`)
51 | options = (typeof options === 'string') ? { view: options } : options || {};
52 |
53 | // Attempt to prettify data for views, if it's a non-error object
54 | var viewData = data;
55 | if (!(viewData instanceof Error) && 'object' == typeof viewData) {
56 | try {
57 | viewData = require('util').inspect(data, {depth: null});
58 | }
59 | catch(e) {
60 | viewData = undefined;
61 | }
62 | }
63 |
64 | // If a view was provided in options, serve it.
65 | // Otherwise try to guess an appropriate view, or if that doesn't
66 | // work, just send JSON.
67 | if (options.view) {
68 | return res.view(options.view, { data: viewData, title: 'Not Found' });
69 | }
70 |
71 | // If no second argument provided, try to serve the default view,
72 | // but fall back to sending JSON(P) if any errors occur.
73 | else return res.view('404', { data: viewData, title: 'Not Found' }, function (err, html) {
74 |
75 | // If a view error occured, fall back to JSON(P).
76 | if (err) {
77 | //
78 | // Additionally:
79 | // • If the view was missing, ignore the error but provide a verbose log.
80 | if (err.code === 'E_VIEW_FAILED') {
81 | sails.log.verbose('res.notFound() :: Could not locate view for error page (sending JSON instead). Details: ',err);
82 | }
83 | // Otherwise, if this was a more serious error, log to the console with the details.
84 | else {
85 | sails.log.warn('res.notFound() :: When attempting to render error page view, an error occured (sending JSON instead). Details: ', err);
86 | }
87 | return res.jsonx(data);
88 | }
89 |
90 | return res.send(html);
91 | });
92 |
93 | };
94 |
95 |
--------------------------------------------------------------------------------
/project-skeletons/sails/api/responses/ok.js:
--------------------------------------------------------------------------------
1 | /**
2 | * 200 (OK) Response
3 | *
4 | * Usage:
5 | * return res.ok();
6 | * return res.ok(data);
7 | * return res.ok(data, 'auth/login');
8 | *
9 | * @param {Object} data
10 | * @param {String|Object} options
11 | * - pass string to render specified view
12 | */
13 |
14 | module.exports = function sendOK (data, options) {
15 |
16 | // Get access to `req`, `res`, & `sails`
17 | var req = this.req;
18 | var res = this.res;
19 | var sails = req._sails;
20 |
21 | sails.log.silly('res.ok() :: Sending 200 ("OK") response');
22 |
23 | // Set status code
24 | res.status(200);
25 |
26 | // If appropriate, serve data as JSON(P)
27 | // If views are disabled, revert to json
28 | if (req.wantsJSON || sails.config.hooks.views === false) {
29 | return res.jsonx(data);
30 | }
31 |
32 | // If second argument is a string, we take that to mean it refers to a view.
33 | // If it was omitted, use an empty object (`{}`)
34 | options = (typeof options === 'string') ? { view: options } : options || {};
35 |
36 | // Attempt to prettify data for views, if it's a non-error object
37 | var viewData = data;
38 | if (!(viewData instanceof Error) && 'object' == typeof viewData) {
39 | try {
40 | viewData = require('util').inspect(data, {depth: null});
41 | }
42 | catch(e) {
43 | viewData = undefined;
44 | }
45 | }
46 |
47 | // If a view was provided in options, serve it.
48 | // Otherwise try to guess an appropriate view, or if that doesn't
49 | // work, just send JSON.
50 | if (options.view) {
51 | return res.view(options.view, { data: viewData, title: 'OK' });
52 | }
53 |
54 | // If no second argument provided, try to serve the implied view,
55 | // but fall back to sending JSON(P) if no view can be inferred.
56 | else return res.guessView({ data: viewData, title: 'OK' }, function couldNotGuessView () {
57 | return res.jsonx(data);
58 | });
59 |
60 | };
61 |
--------------------------------------------------------------------------------
/project-skeletons/sails/api/responses/serverError.js:
--------------------------------------------------------------------------------
1 | /**
2 | * 500 (Server Error) Response
3 | *
4 | * Usage:
5 | * return res.serverError();
6 | * return res.serverError(err);
7 | * return res.serverError(err, 'some/specific/error/view');
8 | *
9 | * NOTE:
10 | * If something throws in a policy or controller, or an internal
11 | * error is encountered, Sails will call `res.serverError()`
12 | * automatically.
13 | */
14 |
15 | module.exports = function serverError (data, options) {
16 |
17 | // Get access to `req`, `res`, & `sails`
18 | var req = this.req;
19 | var res = this.res;
20 | var sails = req._sails;
21 |
22 | // Set status code
23 | res.status(500);
24 |
25 | // Log error to console
26 | if (data !== undefined) {
27 | sails.log.error('Sending 500 ("Server Error") response: \n',data);
28 | }
29 | else sails.log.error('Sending empty 500 ("Server Error") response');
30 |
31 | // Only include errors in response if application environment
32 | // is not set to 'production'. In production, we shouldn't
33 | // send back any identifying information about errors.
34 | if (sails.config.environment === 'production' && sails.config.keepResponseErrors !== true) {
35 | data = undefined;
36 | }
37 |
38 | // If the user-agent wants JSON, always respond with JSON
39 | // If views are disabled, revert to json
40 | if (req.wantsJSON || sails.config.hooks.views === false) {
41 | return res.jsonx(data);
42 | }
43 |
44 | // If second argument is a string, we take that to mean it refers to a view.
45 | // If it was omitted, use an empty object (`{}`)
46 | options = (typeof options === 'string') ? { view: options } : options || {};
47 |
48 | // Attempt to prettify data for views, if it's a non-error object
49 | var viewData = data;
50 | if (!(viewData instanceof Error) && 'object' == typeof viewData) {
51 | try {
52 | viewData = require('util').inspect(data, {depth: null});
53 | }
54 | catch(e) {
55 | viewData = undefined;
56 | }
57 | }
58 |
59 | // If a view was provided in options, serve it.
60 | // Otherwise try to guess an appropriate view, or if that doesn't
61 | // work, just send JSON.
62 | if (options.view) {
63 | return res.view(options.view, { data: viewData, title: 'Server Error' });
64 | }
65 |
66 | // If no second argument provided, try to serve the default view,
67 | // but fall back to sending JSON(P) if any errors occur.
68 | else return res.view('500', { data: viewData, title: 'Server Error' }, function (err, html) {
69 |
70 | // If a view error occured, fall back to JSON(P).
71 | if (err) {
72 | //
73 | // Additionally:
74 | // • If the view was missing, ignore the error but provide a verbose log.
75 | if (err.code === 'E_VIEW_FAILED') {
76 | sails.log.verbose('res.serverError() :: Could not locate view for error page (sending JSON instead). Details: ',err);
77 | }
78 | // Otherwise, if this was a more serious error, log to the console with the details.
79 | else {
80 | sails.log.warn('res.serverError() :: When attempting to render error page view, an error occured (sending JSON instead). Details: ', err);
81 | }
82 | return res.jsonx(data);
83 | }
84 |
85 | return res.send(html);
86 | });
87 |
88 | };
89 |
90 |
--------------------------------------------------------------------------------
/project-skeletons/sails/api/services/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/swagger-api/swagger-node/fc777a61ccaf54076d0a3ffcfafedc347abc15ba/project-skeletons/sails/api/services/.gitkeep
--------------------------------------------------------------------------------
/project-skeletons/sails/api/swagger/swagger.yaml:
--------------------------------------------------------------------------------
1 | swagger: "2.0"
2 | info:
3 | version: "0.0.1"
4 | title: Hello World App
5 | # during dev, should point to your local machine
6 | host: localhost:10010
7 | # basePath prefixes all resource paths
8 | basePath: /
9 | #
10 | schemes:
11 | # tip: remove http to make production-grade
12 | - http
13 | - https
14 | # format of bodies a client can send (Content-Type)
15 | consumes:
16 | - application/json
17 | # format of the responses to the client (Accepts)
18 | produces:
19 | - application/json
20 | paths:
21 | /hello:
22 | # binds a127 app logic to a route
23 | x-swagger-router-controller: hello_world
24 | get:
25 | description: Returns 'Hello' to the caller
26 | # used as the method name of the controller
27 | operationId: hello
28 | parameters:
29 | - name: name
30 | in: query
31 | description: The name of the person to whom to say hello
32 | required: false
33 | type: string
34 | responses:
35 | "200":
36 | description: Success
37 | schema:
38 | # a pointer to a definition
39 | $ref: "#/definitions/HelloWorldResponse"
40 | # responses may fall through to errors
41 | default:
42 | description: Error
43 | schema:
44 | $ref: "#/definitions/ErrorResponse"
45 | /swagger:
46 | x-swagger-pipe: swagger_raw
47 | # complex objects have schema definitions
48 | definitions:
49 | HelloWorldResponse:
50 | required:
51 | - message
52 | properties:
53 | message:
54 | type: string
55 | ErrorResponse:
56 | required:
57 | - message
58 | properties:
59 | message:
60 | type: string
61 |
--------------------------------------------------------------------------------
/project-skeletons/sails/app.js:
--------------------------------------------------------------------------------
1 | /**
2 | * app.js
3 | *
4 | * Use `app.js` to run your app without `sails lift`.
5 | * To start the server, run: `node app.js`.
6 | *
7 | * This is handy in situations where the sails CLI is not relevant or useful.
8 | *
9 | * For example:
10 | * => `node app.js`
11 | * => `forever start app.js`
12 | * => `node debug app.js`
13 | * => `modulus deploy`
14 | * => `heroku scale`
15 | *
16 | *
17 | * The same command-line arguments are supported, e.g.:
18 | * `node app.js --silent --port=80 --prod`
19 | */
20 |
21 |
22 | // Ensure we're in the project directory, so cwd-relative paths work as expected
23 | // no matter where we actually lift from.
24 | // > Note: This is not required in order to lift, but it is a convenient default.
25 | process.chdir(__dirname);
26 |
27 | // Attempt to import `sails`.
28 | var sails;
29 | try {
30 | sails = require('sails');
31 | } catch (e) {
32 | console.error('To run an app using `node app.js`, you usually need to have a version of `sails` installed in the same directory as your app.');
33 | console.error('To do that, run `npm install sails`');
34 | console.error('');
35 | console.error('Alternatively, if you have sails installed globally (i.e. you did `npm install -g sails`), you can use `sails lift`.');
36 | console.error('When you run `sails lift`, your app will still use a local `./node_modules/sails` dependency if it exists,');
37 | console.error('but if it doesn\'t, the app will run with the global sails instead!');
38 | return;
39 | }
40 |
41 | // --•
42 | // Try to get `rc` dependency (for loading `.sailsrc` files).
43 | var rc;
44 | try {
45 | rc = require('rc');
46 | } catch (e0) {
47 | try {
48 | rc = require('sails/node_modules/rc');
49 | } catch (e1) {
50 | console.error('Could not find dependency: `rc`.');
51 | console.error('Your `.sailsrc` file(s) will be ignored.');
52 | console.error('To resolve this, run:');
53 | console.error('npm install rc --save');
54 | rc = function () { return {}; };
55 | }
56 | }
57 |
58 |
59 | // Start server
60 | sails.lift(rc('sails'));
61 |
--------------------------------------------------------------------------------
/project-skeletons/sails/assets/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/swagger-api/swagger-node/fc777a61ccaf54076d0a3ffcfafedc347abc15ba/project-skeletons/sails/assets/favicon.ico
--------------------------------------------------------------------------------
/project-skeletons/sails/assets/images/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/swagger-api/swagger-node/fc777a61ccaf54076d0a3ffcfafedc347abc15ba/project-skeletons/sails/assets/images/.gitkeep
--------------------------------------------------------------------------------
/project-skeletons/sails/assets/robots.txt:
--------------------------------------------------------------------------------
1 | # The robots.txt file is used to control how search engines index your live URLs.
2 | # See http://sailsjs.org/documentation/anatomy/my-app/assets/robots-txt for more information.
3 |
4 |
5 |
6 | # To prevent search engines from seeing the site altogether, uncomment the next two lines:
7 | # User-Agent: *
8 | # Disallow: /
9 |
--------------------------------------------------------------------------------
/project-skeletons/sails/assets/styles/importer.less:
--------------------------------------------------------------------------------
1 | /**
2 | * importer.less
3 | *
4 | * By default, new Sails projects are configured to compile this file
5 | * from LESS to CSS. Unlike CSS files, LESS files are not compiled and
6 | * included automatically unless they are imported below.
7 | *
8 | * The LESS files imported below are compiled and included in the order
9 | * they are listed. Mixins, variables, etc. should be imported first
10 | * so that they can be accessed by subsequent LESS stylesheets.
11 | *
12 | * (Just like the rest of the asset pipeline bundled in Sails, you can
13 | * always omit, customize, or replace this behavior with SASS, SCSS,
14 | * or any other Grunt tasks you like.)
15 | */
16 |
17 |
18 |
19 | // For example:
20 | //
21 | // @import 'variables/colors.less';
22 | // @import 'mixins/foo.less';
23 | // @import 'mixins/bar.less';
24 | // @import 'mixins/baz.less';
25 | //
26 | // @import 'styleguide.less';
27 | // @import 'pages/login.less';
28 | // @import 'pages/signup.less';
29 | //
30 | // etc.
31 |
--------------------------------------------------------------------------------
/project-skeletons/sails/assets/templates/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/swagger-api/swagger-node/fc777a61ccaf54076d0a3ffcfafedc347abc15ba/project-skeletons/sails/assets/templates/.gitkeep
--------------------------------------------------------------------------------
/project-skeletons/sails/config/bootstrap.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Bootstrap
3 | * (sails.config.bootstrap)
4 | *
5 | * An asynchronous bootstrap function that runs before your Sails app gets lifted.
6 | * This gives you an opportunity to set up your data model, run jobs, or perform some special logic.
7 | *
8 | * For more information on bootstrapping your app, check out:
9 | * http://sailsjs.org/#!/documentation/reference/sails.config/sails.config.bootstrap.html
10 | */
11 |
12 | module.exports.bootstrap = function(cb) {
13 |
14 | // It's very important to trigger this callback method when you are finished
15 | // with the bootstrap! (otherwise your server will never lift, since it's waiting on the bootstrap)
16 | cb();
17 | };
18 |
--------------------------------------------------------------------------------
/project-skeletons/sails/config/cors.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Cross-Origin Resource Sharing (CORS) Settings
3 | * (sails.config.cors)
4 | *
5 | * CORS is like a more modern version of JSONP-- it allows your server/API
6 | * to successfully respond to requests from client-side JavaScript code
7 | * running on some other domain (e.g. google.com)
8 | * Unlike JSONP, it works with POST, PUT, and DELETE requests
9 | *
10 | * For more information on CORS, check out:
11 | * http://en.wikipedia.org/wiki/Cross-origin_resource_sharing
12 | *
13 | * Note that any of these settings (besides 'allRoutes') can be changed on a per-route basis
14 | * by adding a "cors" object to the route configuration:
15 | *
16 | * '/get foo': {
17 | * controller: 'foo',
18 | * action: 'bar',
19 | * cors: {
20 | * origin: 'http://foobar.com,https://owlhoot.com'
21 | * }
22 | * }
23 | *
24 | * For more information on this configuration file, see:
25 | * http://sailsjs.org/#!/documentation/reference/sails.config/sails.config.cors.html
26 | *
27 | */
28 |
29 | module.exports.cors = {
30 |
31 | /***************************************************************************
32 | * *
33 | * Allow CORS on all routes by default? If not, you must enable CORS on a *
34 | * per-route basis by either adding a "cors" configuration object to the *
35 | * route config, or setting "cors:true" in the route config to use the *
36 | * default settings below. *
37 | * *
38 | ***************************************************************************/
39 |
40 | // allRoutes: false,
41 |
42 | /***************************************************************************
43 | * *
44 | * Which domains which are allowed CORS access? This can be a *
45 | * comma-delimited list of hosts (beginning with http:// or https://) or *
46 | * "*" to allow all domains CORS access. *
47 | * *
48 | ***************************************************************************/
49 |
50 | // origin: '*',
51 |
52 | /***************************************************************************
53 | * *
54 | * Allow cookies to be shared for CORS requests? *
55 | * *
56 | ***************************************************************************/
57 |
58 | // credentials: true,
59 |
60 | /***************************************************************************
61 | * *
62 | * Which methods should be allowed for CORS requests? This is only used in *
63 | * response to preflight requests (see article linked above for more info) *
64 | * *
65 | ***************************************************************************/
66 |
67 | // methods: 'GET, POST, PUT, DELETE, OPTIONS, HEAD',
68 |
69 | /***************************************************************************
70 | * *
71 | * Which headers should be allowed for CORS requests? This is only used in *
72 | * response to preflight requests. *
73 | * *
74 | ***************************************************************************/
75 |
76 | // headers: 'content-type'
77 |
78 | };
79 |
--------------------------------------------------------------------------------
/project-skeletons/sails/config/csrf.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Cross-Site Request Forgery Protection Settings
3 | * (sails.config.csrf)
4 | *
5 | * CSRF tokens are like a tracking chip. While a session tells the server that a user
6 | * "is who they say they are", a csrf token tells the server "you are where you say you are".
7 | *
8 | * When enabled, all non-GET requests to the Sails server must be accompanied by
9 | * a special token, identified as the '_csrf' parameter.
10 | *
11 | * This option protects your Sails app against cross-site request forgery (or CSRF) attacks.
12 | * A would-be attacker needs not only a user's session cookie, but also this timestamped,
13 | * secret CSRF token, which is refreshed/granted when the user visits a URL on your app's domain.
14 | *
15 | * This allows us to have certainty that our users' requests haven't been hijacked,
16 | * and that the requests they're making are intentional and legitimate.
17 | *
18 | * This token has a short-lived expiration timeline, and must be acquired by either:
19 | *
20 | * (a) For traditional view-driven web apps:
21 | * Fetching it from one of your views, where it may be accessed as
22 | * a local variable, e.g.:
23 | *
26 | *
27 | * or (b) For AJAX/Socket-heavy and/or single-page apps:
28 | * Sending a GET request to the `/csrfToken` route, where it will be returned
29 | * as JSON, e.g.:
30 | * { _csrf: 'ajg4JD(JGdajhLJALHDa' }
31 | *
32 | *
33 | * Enabling this option requires managing the token in your front-end app.
34 | * For traditional web apps, it's as easy as passing the data from a view into a form action.
35 | * In AJAX/Socket-heavy apps, just send a GET request to the /csrfToken route to get a valid token.
36 | *
37 | * For more information on CSRF, check out:
38 | * http://en.wikipedia.org/wiki/Cross-site_request_forgery
39 | *
40 | * For more information on this configuration file, including info on CSRF + CORS, see:
41 | * http://sailsjs.org/#!/documentation/reference/sails.config/sails.config.csrf.html
42 | *
43 | */
44 |
45 | /****************************************************************************
46 | * *
47 | * Enabled CSRF protection for your site? *
48 | * *
49 | ****************************************************************************/
50 |
51 | // module.exports.csrf = false;
52 |
53 | /****************************************************************************
54 | * *
55 | * You may also specify more fine-grained settings for CSRF, including the *
56 | * domains which are allowed to request the CSRF token via AJAX. These *
57 | * settings override the general CORS settings in your config/cors.js file. *
58 | * *
59 | ****************************************************************************/
60 |
61 | // module.exports.csrf = {
62 | // grantTokenViaAjax: true,
63 | // origin: ''
64 | // }
65 |
--------------------------------------------------------------------------------
/project-skeletons/sails/config/default.yaml:
--------------------------------------------------------------------------------
1 | # swagger configuration file
2 |
3 | # values in the swagger hash are system configuration for swagger-node
4 | swagger:
5 |
6 | fittingsDirs: [ api/fittings ]
7 | defaultPipe: null
8 | swaggerControllerPipe: swagger_controllers # defines the standard processing pipe for controllers
9 |
10 | # values defined in the bagpipes key are the bagpipes pipes and fittings definitions
11 | # (see https://github.com/apigee-127/bagpipes)
12 | bagpipes:
13 |
14 | _router:
15 | name: swagger_router
16 | mockMode: false
17 | mockControllersDirs: [ api/mocks ]
18 | controllersDirs: [ api/controllers ]
19 |
20 | _swagger_validate:
21 | name: swagger_validator
22 | validateResponse: true
23 |
24 | # pipe for all swagger-node controllers
25 | swagger_controllers:
26 | - onError: json_error_handler
27 | - cors
28 | - swagger_params_parser
29 | - swagger_security
30 | - _swagger_validate
31 | - express_compatibility
32 | - _router
33 |
34 | # pipe to serve swagger (endpoint is in swagger.yaml)
35 | swagger_raw:
36 | name: swagger_raw
37 |
38 | # any other values in this file are just loaded into the config for application access...
39 |
--------------------------------------------------------------------------------
/project-skeletons/sails/config/env/development.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Development environment settings
3 | *
4 | * This file can include shared settings for a development team,
5 | * such as API keys or remote database passwords. If you're using
6 | * a version control solution for your Sails app, this file will
7 | * be committed to your repository unless you add it to your .gitignore
8 | * file. If your repository will be publicly viewable, don't add
9 | * any private information to this file!
10 | *
11 | */
12 |
13 | module.exports = {
14 |
15 | /***************************************************************************
16 | * Set the default database connection for models in the development *
17 | * environment (see config/connections.js and config/models.js ) *
18 | ***************************************************************************/
19 |
20 | port: 10010
21 |
22 | // models: {
23 | // connection: 'someMongodbServer'
24 | // }
25 |
26 | };
27 |
--------------------------------------------------------------------------------
/project-skeletons/sails/config/env/production.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Production environment settings
3 | *
4 | * This file can include shared settings for a production environment,
5 | * such as API keys or remote database passwords. If you're using
6 | * a version control solution for your Sails app, this file will
7 | * be committed to your repository unless you add it to your .gitignore
8 | * file. If your repository will be publicly viewable, don't add
9 | * any private information to this file!
10 | *
11 | */
12 |
13 | module.exports = {
14 |
15 | /***************************************************************************
16 | * Set the default database connection for models in the production *
17 | * environment (see config/connections.js and config/models.js ) *
18 | ***************************************************************************/
19 |
20 | // models: {
21 | // connection: 'someMysqlServer'
22 | // },
23 |
24 | /***************************************************************************
25 | * Set the port in the production environment to 80 *
26 | ***************************************************************************/
27 |
28 | // port: 80,
29 |
30 | /***************************************************************************
31 | * Set the log level in production environment to "silent" *
32 | ***************************************************************************/
33 |
34 | // log: {
35 | // level: "silent"
36 | // }
37 |
38 | };
39 |
--------------------------------------------------------------------------------
/project-skeletons/sails/config/globals.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Global Variable Configuration
3 | * (sails.config.globals)
4 | *
5 | * Configure which global variables which will be exposed
6 | * automatically by Sails.
7 | *
8 | * For more information on configuration, check out:
9 | * http://sailsjs.org/#!/documentation/reference/sails.config/sails.config.globals.html
10 | */
11 | module.exports.globals = {
12 |
13 | /****************************************************************************
14 | * *
15 | * Expose the lodash installed in Sails core as a global variable. If this *
16 | * is disabled, like any other node module you can always run npm install *
17 | * lodash --save, then var _ = require('lodash') at the top of any file. *
18 | * *
19 | ****************************************************************************/
20 |
21 | // _: true,
22 |
23 | /****************************************************************************
24 | * *
25 | * Expose the async installed in Sails core as a global variable. If this is *
26 | * disabled, like any other node module you can always run npm install async *
27 | * --save, then var async = require('async') at the top of any file. *
28 | * *
29 | ****************************************************************************/
30 |
31 | // async: true,
32 |
33 | /****************************************************************************
34 | * *
35 | * Expose the sails instance representing your app. If this is disabled, you *
36 | * can still get access via req._sails. *
37 | * *
38 | ****************************************************************************/
39 |
40 | // sails: true,
41 |
42 | /****************************************************************************
43 | * *
44 | * Expose each of your app's services as global variables (using their *
45 | * "globalId"). E.g. a service defined in api/models/NaturalLanguage.js *
46 | * would have a globalId of NaturalLanguage by default. If this is disabled, *
47 | * you can still access your services via sails.services.* *
48 | * *
49 | ****************************************************************************/
50 |
51 | // services: true,
52 |
53 | /****************************************************************************
54 | * *
55 | * Expose each of your app's models as global variables (using their *
56 | * "globalId"). E.g. a model defined in api/models/User.js would have a *
57 | * globalId of User by default. If this is disabled, you can still access *
58 | * your models via sails.models.*. *
59 | * *
60 | ****************************************************************************/
61 |
62 | // models: true
63 | };
64 |
--------------------------------------------------------------------------------
/project-skeletons/sails/config/http.js:
--------------------------------------------------------------------------------
1 | /**
2 | * HTTP Server Settings
3 | * (sails.config.http)
4 | *
5 | * Configuration for the underlying HTTP server in Sails.
6 | * Only applies to HTTP requests (not WebSockets)
7 | *
8 | * For more information on configuration, check out:
9 | * http://sailsjs.org/#!/documentation/reference/sails.config/sails.config.http.html
10 | */
11 |
12 | module.exports.http = {
13 |
14 | /****************************************************************************
15 | * *
16 | * Express middleware to use for every Sails request. To add custom *
17 | * middleware to the mix, add a function to the middleware config object and *
18 | * add its key to the "order" array. The $custom key is reserved for *
19 | * backwards-compatibility with Sails v0.9.x apps that use the *
20 | * `customMiddleware` config option. *
21 | * *
22 | ****************************************************************************/
23 |
24 | middleware: {
25 |
26 | /***************************************************************************
27 | * *
28 | * The order in which middleware should be run for HTTP request. (the Sails *
29 | * router is invoked by the "router" middleware below.) *
30 | * *
31 | ***************************************************************************/
32 |
33 | // order: [
34 | // 'startRequestTimer',
35 | // 'cookieParser',
36 | // 'session',
37 | // 'myRequestLogger',
38 | // 'bodyParser',
39 | // 'handleBodyParserError',
40 | // 'compress',
41 | // 'methodOverride',
42 | // 'poweredBy',
43 | // '$custom',
44 | // 'router',
45 | // 'www',
46 | // 'favicon',
47 | // '404',
48 | // '500'
49 | // ],
50 |
51 | /****************************************************************************
52 | * *
53 | * Example custom middleware; logs each request to the console. *
54 | * *
55 | ****************************************************************************/
56 |
57 | // myRequestLogger: function (req, res, next) {
58 | // console.log("Requested :: ", req.method, req.url);
59 | // return next();
60 | // }
61 |
62 |
63 | /***************************************************************************
64 | * *
65 | * The body parser that will handle incoming multipart HTTP requests. By *
66 | * default as of v0.10, Sails uses *
67 | * [skipper](http://github.com/balderdashy/skipper). See *
68 | * http://www.senchalabs.org/connect/multipart.html for other options. *
69 | * *
70 | * Note that Sails uses an internal instance of Skipper by default; to *
71 | * override it and specify more options, make sure to "npm install skipper" *
72 | * in your project first. You can also specify a different body parser or *
73 | * a custom function with req, res and next parameters (just like any other *
74 | * middleware function). *
75 | * *
76 | ***************************************************************************/
77 |
78 | // bodyParser: require('skipper')({strict: true})
79 |
80 | },
81 |
82 | /***************************************************************************
83 | * *
84 | * The number of seconds to cache flat files on disk being served by *
85 | * Express static middleware (by default, these files are in `.tmp/public`) *
86 | * *
87 | * The HTTP static cache is only active in a 'production' environment, *
88 | * since that's the only time Express will cache flat-files. *
89 | * *
90 | ***************************************************************************/
91 |
92 | // cache: 31557600000
93 | };
94 |
--------------------------------------------------------------------------------
/project-skeletons/sails/config/i18n.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Internationalization / Localization Settings
3 | * (sails.config.i18n)
4 | *
5 | * If your app will touch people from all over the world, i18n (or internationalization)
6 | * may be an important part of your international strategy.
7 | *
8 | *
9 | * For more informationom i18n in Sails, check out:
10 | * http://sailsjs.org/#!/documentation/concepts/Internationalization
11 | *
12 | * For a complete list of i18n options, see:
13 | * https://github.com/mashpie/i18n-node#list-of-configuration-options
14 | *
15 | *
16 | */
17 |
18 | module.exports.i18n = {
19 |
20 | /***************************************************************************
21 | * *
22 | * Which locales are supported? *
23 | * *
24 | ***************************************************************************/
25 |
26 | // locales: ['en', 'es', 'fr', 'de'],
27 |
28 | /****************************************************************************
29 | * *
30 | * What is the default locale for the site? Note that this setting will be *
31 | * overridden for any request that sends an "Accept-Language" header (i.e. *
32 | * most browsers), but it's still useful if you need to localize the *
33 | * response for requests made by non-browser clients (e.g. cURL). *
34 | * *
35 | ****************************************************************************/
36 |
37 | // defaultLocale: 'en',
38 |
39 | /****************************************************************************
40 | * *
41 | * Automatically add new keys to locale (translation) files when they are *
42 | * encountered during a request? *
43 | * *
44 | ****************************************************************************/
45 |
46 | // updateFiles: false,
47 |
48 | /****************************************************************************
49 | * *
50 | * Path (relative to app root) of directory to store locale (translation) *
51 | * files in. *
52 | * *
53 | ****************************************************************************/
54 |
55 | // localesDirectory: '/config/locales'
56 |
57 | };
58 |
--------------------------------------------------------------------------------
/project-skeletons/sails/config/local.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Local environment settings
3 | *
4 | * Use this file to specify configuration settings for use while developing
5 | * the app on your personal system: for example, this would be a good place
6 | * to store database or email passwords that apply only to you, and shouldn't
7 | * be shared with others in your organization.
8 | *
9 | * These settings take precedence over all other config files, including those
10 | * in the env/ subfolder.
11 | *
12 | * PLEASE NOTE:
13 | * local.js is included in your .gitignore, so if you're using git
14 | * as a version control solution for your Sails app, keep in mind that
15 | * this file won't be committed to your repository!
16 | *
17 | * Good news is, that means you can specify configuration for your local
18 | * machine in this file without inadvertently committing personal information
19 | * (like database passwords) to the repo. Plus, this prevents other members
20 | * of your team from commiting their local configuration changes on top of yours.
21 | *
22 | * In a production environment, you probably want to leave this file out
23 | * entirely and leave all your settings in env/production.js
24 | *
25 | *
26 | * For more information, check out:
27 | * http://sailsjs.org/#!/documentation/anatomy/myApp/config/local.js.html
28 | */
29 |
30 | module.exports = {
31 |
32 | /***************************************************************************
33 | * Your SSL certificate and key, if you want to be able to serve HTTP *
34 | * responses over https:// and/or use websockets over the wss:// protocol *
35 | * (recommended for HTTP, strongly encouraged for WebSockets) *
36 | * *
37 | * In this example, we'll assume you created a folder in your project, *
38 | * `config/ssl` and dumped your certificate/key files there: *
39 | ***************************************************************************/
40 |
41 | // ssl: {
42 | // ca: require('fs').readFileSync(__dirname + './ssl/my_apps_ssl_gd_bundle.crt'),
43 | // key: require('fs').readFileSync(__dirname + './ssl/my_apps_ssl.key'),
44 | // cert: require('fs').readFileSync(__dirname + './ssl/my_apps_ssl.crt')
45 | // },
46 |
47 | /***************************************************************************
48 | * The `port` setting determines which TCP port your app will be *
49 | * deployed on. *
50 | * *
51 | * Ports are a transport-layer concept designed to allow many different *
52 | * networking applications run at the same time on a single computer. *
53 | * More about ports: *
54 | * http://en.wikipedia.org/wiki/Port_(computer_networking) *
55 | * *
56 | * By default, if it's set, Sails uses the `PORT` environment variable. *
57 | * Otherwise it falls back to port 1337. *
58 | * *
59 | * In env/production.js, you'll probably want to change this setting *
60 | * to 80 (http://) or 443 (https://) if you have an SSL certificate *
61 | ***************************************************************************/
62 |
63 | // port: process.env.PORT || 1337,
64 |
65 | /***************************************************************************
66 | * The runtime "environment" of your Sails app is either typically *
67 | * 'development' or 'production'. *
68 | * *
69 | * In development, your Sails app will go out of its way to help you *
70 | * (for instance you will receive more descriptive error and *
71 | * debugging output) *
72 | * *
73 | * In production, Sails configures itself (and its dependencies) to *
74 | * optimize performance. You should always put your app in production mode *
75 | * before you deploy it to a server. This helps ensure that your Sails *
76 | * app remains stable, performant, and scalable. *
77 | * *
78 | * By default, Sails sets its environment using the `NODE_ENV` environment *
79 | * variable. If NODE_ENV is not set, Sails will run in the *
80 | * 'development' environment. *
81 | ***************************************************************************/
82 |
83 | // environment: process.env.NODE_ENV || 'development'
84 |
85 | };
86 |
--------------------------------------------------------------------------------
/project-skeletons/sails/config/locales/_README.md:
--------------------------------------------------------------------------------
1 | # Internationalization / Localization Settings
2 |
3 | > Also see the official docs on internationalization/localization:
4 | > http://links.sailsjs.org/docs/config/locales
5 |
6 | ## Locales
7 | All locale files live under `config/locales`. Here is where you can add translations
8 | as JSON key-value pairs. The name of the file should match the language that you are supporting, which allows for automatic language detection based on request headers.
9 |
10 | Here is an example locale stringfile for the Spanish language (`config/locales/es.json`):
11 | ```json
12 | {
13 | "Hello!": "Hola!",
14 | "Hello %s, how are you today?": "¿Hola %s, como estas?",
15 | }
16 | ```
17 | ## Usage
18 | Locales can be accessed in controllers/policies through `res.i18n()`, or in views through the `__(key)` or `i18n(key)` functions.
19 | Remember that the keys are case sensitive and require exact key matches, e.g.
20 |
21 | ```ejs
22 | <%= __('Welcome to PencilPals!') %>
23 | <%= i18n('Hello %s, how are you today?', 'Pencil Maven') %>
24 | <%= i18n('That\'s right-- you can use either i18n() or __()') %>
25 | ```
26 |
27 | ## Configuration
28 | Localization/internationalization config can be found in `config/i18n.js`, from where you can set your supported locales.
29 |
--------------------------------------------------------------------------------
/project-skeletons/sails/config/locales/de.json:
--------------------------------------------------------------------------------
1 | {
2 | "Welcome": "Willkommen",
3 | "A brand new app.": "Eine neue App."
4 | }
5 |
--------------------------------------------------------------------------------
/project-skeletons/sails/config/locales/en.json:
--------------------------------------------------------------------------------
1 | {
2 | "Welcome": "Welcome",
3 | "A brand new app.": "A brand new app."
4 | }
5 |
--------------------------------------------------------------------------------
/project-skeletons/sails/config/locales/es.json:
--------------------------------------------------------------------------------
1 | {
2 | "Welcome": "Bienvenido",
3 | "A brand new app.": "Una nueva aplicación."
4 | }
5 |
--------------------------------------------------------------------------------
/project-skeletons/sails/config/locales/fr.json:
--------------------------------------------------------------------------------
1 | {
2 | "Welcome": "Bienvenue",
3 | "A brand new app.": "Une toute nouvelle application."
4 | }
5 |
--------------------------------------------------------------------------------
/project-skeletons/sails/config/log.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Built-in Log Configuration
3 | * (sails.config.log)
4 | *
5 | * Configure the log level for your app, as well as the transport
6 | * (Underneath the covers, Sails uses Winston for logging, which
7 | * allows for some pretty neat custom transports/adapters for log messages)
8 | *
9 | * For more information on the Sails logger, check out:
10 | * http://sailsjs.org/#!/documentation/concepts/Logging
11 | */
12 |
13 | module.exports.log = {
14 |
15 | /***************************************************************************
16 | * *
17 | * Valid `level` configs: i.e. the minimum log level to capture with *
18 | * sails.log.*() *
19 | * *
20 | * The order of precedence for log levels from lowest to highest is: *
21 | * silly, verbose, info, debug, warn, error *
22 | * *
23 | * You may also set the level to "silent" to suppress all logs. *
24 | * *
25 | ***************************************************************************/
26 |
27 | // level: 'info'
28 |
29 | };
30 |
--------------------------------------------------------------------------------
/project-skeletons/sails/config/models.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Default model configuration
3 | * (sails.config.models)
4 | *
5 | * Unless you override them, the following properties will be included
6 | * in each of your models.
7 | *
8 | * For more info on Sails models, see:
9 | * http://sailsjs.org/#!/documentation/concepts/ORM
10 | */
11 |
12 | module.exports.models = {
13 |
14 | /***************************************************************************
15 | * *
16 | * Your app's default connection. i.e. the name of one of your app's *
17 | * connections (see `config/connections.js`) *
18 | * *
19 | ***************************************************************************/
20 | // connection: 'localDiskDb',
21 |
22 | /***************************************************************************
23 | * *
24 | * How and whether Sails will attempt to automatically rebuild the *
25 | * tables/collections/etc. in your schema. *
26 | * *
27 | * See http://sailsjs.org/#!/documentation/concepts/ORM/model-settings.html *
28 | * *
29 | ***************************************************************************/
30 | // migrate: 'alter'
31 |
32 | };
33 |
--------------------------------------------------------------------------------
/project-skeletons/sails/config/policies.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Policy Mappings
3 | * (sails.config.policies)
4 | *
5 | * Policies are simple functions which run **before** your controllers.
6 | * You can apply one or more policies to a given controller, or protect
7 | * its actions individually.
8 | *
9 | * Any policy file (e.g. `api/policies/authenticated.js`) can be accessed
10 | * below by its filename, minus the extension, (e.g. "authenticated")
11 | *
12 | * For more information on how policies work, see:
13 | * http://sailsjs.org/#!/documentation/concepts/Policies
14 | *
15 | * For more information on configuring policies, check out:
16 | * http://sailsjs.org/#!/documentation/reference/sails.config/sails.config.policies.html
17 | */
18 |
19 |
20 | module.exports.policies = {
21 |
22 | /***************************************************************************
23 | * *
24 | * Default policy for all controllers and actions (`true` allows public *
25 | * access) *
26 | * *
27 | ***************************************************************************/
28 |
29 | // '*': true,
30 |
31 | /***************************************************************************
32 | * *
33 | * Here's an example of mapping some policies to run before a controller *
34 | * and its actions *
35 | * *
36 | ***************************************************************************/
37 | // RabbitController: {
38 |
39 | // Apply the `false` policy as the default for all of RabbitController's actions
40 | // (`false` prevents all access, which ensures that nothing bad happens to our rabbits)
41 | // '*': false,
42 |
43 | // For the action `nurture`, apply the 'isRabbitMother' policy
44 | // (this overrides `false` above)
45 | // nurture : 'isRabbitMother',
46 |
47 | // Apply the `isNiceToAnimals` AND `hasRabbitFood` policies
48 | // before letting any users feed our rabbits
49 | // feed : ['isNiceToAnimals', 'hasRabbitFood']
50 | // }
51 | };
52 |
--------------------------------------------------------------------------------
/project-skeletons/sails/config/routes.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Route Mappings
3 | * (sails.config.routes)
4 | *
5 | * Your routes map URLs to views and controllers.
6 | *
7 | * If Sails receives a URL that doesn't match any of the routes below,
8 | * it will check for matching files (images, scripts, stylesheets, etc.)
9 | * in your assets directory. e.g. `http://localhost:1337/images/foo.jpg`
10 | * might match an image file: `/assets/images/foo.jpg`
11 | *
12 | * Finally, if those don't match either, the default 404 handler is triggered.
13 | * See `api/responses/notFound.js` to adjust your app's 404 logic.
14 | *
15 | * Note: Sails doesn't ACTUALLY serve stuff from `assets`-- the default Gruntfile in Sails copies
16 | * flat files from `assets` to `.tmp/public`. This allows you to do things like compile LESS or
17 | * CoffeeScript for the front-end.
18 | *
19 | * For more information on configuring custom routes, check out:
20 | * http://sailsjs.org/#!/documentation/concepts/Routes/RouteTargetSyntax.html
21 | */
22 |
23 | module.exports.routes = {
24 |
25 | /***************************************************************************
26 | * *
27 | * Make the view located at `views/homepage.ejs` (or `views/homepage.jade`, *
28 | * etc. depending on your default view engine) your home page. *
29 | * *
30 | * (Alternatively, remove this and add an `index.html` file in your *
31 | * `assets` directory) *
32 | * *
33 | ***************************************************************************/
34 |
35 | '/': {
36 | view: 'homepage'
37 | }
38 |
39 | /***************************************************************************
40 | * *
41 | * Custom routes here... *
42 | * *
43 | * If a request to a URL doesn't match any of the custom routes above, it *
44 | * is matched against Sails route blueprints. See `config/blueprints.js` *
45 | * for configuration options and examples. *
46 | * *
47 | ***************************************************************************/
48 |
49 | };
50 |
--------------------------------------------------------------------------------
/project-skeletons/sails/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "swagger-app",
3 | "version": "0.0.1",
4 | "private": true,
5 | "description": "New Swagger API Project",
6 | "keywords": [],
7 | "author": "",
8 | "license": "",
9 | "main": "app.js",
10 | "dependencies": {
11 | "ejs": "2.5.5",
12 | "grunt": "1.0.1",
13 | "grunt-contrib-clean": "1.0.0",
14 | "grunt-contrib-coffee": "1.0.0",
15 | "grunt-contrib-concat": "1.0.1",
16 | "grunt-contrib-copy": "1.0.0",
17 | "grunt-contrib-cssmin": "1.0.1",
18 | "grunt-contrib-jst": "1.0.0",
19 | "grunt-contrib-less": "1.3.0",
20 | "grunt-contrib-uglify": "1.0.1",
21 | "grunt-contrib-watch": "1.0.0",
22 | "grunt-sails-linker": "~0.10.1",
23 | "grunt-sync": "0.5.2",
24 | "include-all": "^1.0.0",
25 | "rc": "1.0.1",
26 | "sails": "~0.12.13",
27 | "sails-disk": "~0.10.9",
28 | "swagger-sails-hook": "^0.7.0"
29 | },
30 | "devDependencies": {
31 | "should": "^11.2.1",
32 | "supertest": "^3.0.0"
33 | },
34 | "scripts": {
35 | "start": "node app.js",
36 | "debug": "node debug app.js",
37 | "test": "swagger project test"
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/project-skeletons/sails/tasks/README.md:
--------------------------------------------------------------------------------
1 | # About the `tasks` folder
2 |
3 | The `tasks` directory is a suite of Grunt tasks and their configurations, bundled for your convenience. The Grunt integration is mainly useful for bundling front-end assets, (like stylesheets, scripts, & markup templates) but it can also be used to run all kinds of development tasks, from browserify compilation to database migrations.
4 |
5 | If you haven't used [Grunt](http://gruntjs.com/) before, be sure to check out the [Getting Started](http://gruntjs.com/getting-started) guide, as it explains how to create a [Gruntfile](http://gruntjs.com/sample-gruntfile) as well as install and use Grunt plugins. Once you're familiar with that process, read on!
6 |
7 |
8 | ### How does this work?
9 |
10 | The asset pipeline bundled in Sails is a set of Grunt tasks configured with conventional defaults designed to make your project more consistent and productive.
11 |
12 | The entire front-end asset workflow in Sails is completely customizable-- while it provides some suggestions out of the box, Sails makes no pretense that it can anticipate all of the needs you'll encounter building the browser-based/front-end portion of your application. Who's to say you're even building an app for a browser?
13 |
14 |
15 |
16 | ### What tasks does Sails run automatically?
17 |
18 | Sails runs some of these tasks (the ones in the `tasks/register` folder) automatically when you run certain commands.
19 |
20 | ###### `sails lift`
21 |
22 | Runs the `default` task (`tasks/register/default.js`).
23 |
24 | ###### `sails lift --prod`
25 |
26 | Runs the `prod` task (`tasks/register/prod.js`).
27 |
28 | ###### `sails www`
29 |
30 | Runs the `build` task (`tasks/register/build.js`).
31 |
32 | ###### `sails www --prod` (production)
33 |
34 | Runs the `buildProd` task (`tasks/register/buildProd.js`).
35 |
36 |
37 | ### Can I customize this for SASS, Angular, client-side Jade templates, etc?
38 |
39 | You can modify, omit, or replace any of these Grunt tasks to fit your requirements. You can also add your own Grunt tasks- just add a `someTask.js` file in the `grunt/config` directory to configure the new task, then register it with the appropriate parent task(s) (see files in `grunt/register/*.js`).
40 |
41 |
42 | ### Do I have to use Grunt?
43 |
44 | Nope! To disable Grunt integration in Sails, just delete your Gruntfile or disable the Grunt hook.
45 |
46 |
47 | ### What if I'm not building a web frontend?
48 |
49 | That's ok! A core tenant of Sails is client-agnosticism-- it's especially designed for building APIs used by all sorts of clients; native Android/iOS/Cordova, serverside SDKs, etc.
50 |
51 | You can completely disable Grunt by following the instructions above.
52 |
53 | If you still want to use Grunt for other purposes, but don't want any of the default web front-end stuff, just delete your project's `assets` folder and remove the front-end oriented tasks from the `grunt/register` and `grunt/config` folders. You can also run `sails new myCoolApi --no-frontend` to omit the `assets` folder and front-end-oriented Grunt tasks for future projects. You can also replace your `sails-generate-frontend` module with alternative community generators, or create your own. This allows `sails new` to create the boilerplate for native iOS apps, Android apps, Cordova apps, SteroidsJS apps, etc.
54 |
55 |
--------------------------------------------------------------------------------
/project-skeletons/sails/tasks/config/clean.js:
--------------------------------------------------------------------------------
1 | /**
2 | * `clean`
3 | *
4 | * ---------------------------------------------------------------
5 | *
6 | * Remove the files and folders in your Sails app's web root
7 | * (conventionally a hidden directory called `.tmp/public`).
8 | *
9 | * For usage docs see:
10 | * https://github.com/gruntjs/grunt-contrib-clean
11 | *
12 | */
13 | module.exports = function(grunt) {
14 |
15 | grunt.config.set('clean', {
16 | dev: ['.tmp/public/**'],
17 | build: ['www']
18 | });
19 |
20 | grunt.loadNpmTasks('grunt-contrib-clean');
21 | };
22 |
--------------------------------------------------------------------------------
/project-skeletons/sails/tasks/config/coffee.js:
--------------------------------------------------------------------------------
1 | /**
2 | * `coffee`
3 | *
4 | * ---------------------------------------------------------------
5 | *
6 | * Compile CoffeeScript files located in `assets/js` into Javascript
7 | * and generate new `.js` files in `.tmp/public/js`.
8 | *
9 | * For usage docs see:
10 | * https://github.com/gruntjs/grunt-contrib-coffee
11 | *
12 | */
13 | module.exports = function(grunt) {
14 |
15 | grunt.config.set('coffee', {
16 | dev: {
17 | options: {
18 | bare: true,
19 | sourceMap: true,
20 | sourceRoot: './'
21 | },
22 | files: [{
23 | expand: true,
24 | cwd: 'assets/js/',
25 | src: ['**/*.coffee'],
26 | dest: '.tmp/public/js/',
27 | ext: '.js'
28 | }]
29 | }
30 | });
31 |
32 | grunt.loadNpmTasks('grunt-contrib-coffee');
33 | };
34 |
--------------------------------------------------------------------------------
/project-skeletons/sails/tasks/config/concat.js:
--------------------------------------------------------------------------------
1 | /**
2 | * `concat`
3 | *
4 | * ---------------------------------------------------------------
5 | *
6 | * Concatenates the contents of multiple JavaScript and/or CSS files
7 | * into two new files, each located at `concat/production.js` and
8 | * `concat/production.css` respectively in `.tmp/public/concat`.
9 | *
10 | * This is used as an intermediate step to generate monolithic files
11 | * that can then be passed in to `uglify` and/or `cssmin` for minification.
12 | *
13 | * For usage docs see:
14 | * https://github.com/gruntjs/grunt-contrib-concat
15 | *
16 | */
17 | module.exports = function(grunt) {
18 |
19 | grunt.config.set('concat', {
20 | js: {
21 | src: require('../pipeline').jsFilesToInject,
22 | dest: '.tmp/public/concat/production.js'
23 | },
24 | css: {
25 | src: require('../pipeline').cssFilesToInject,
26 | dest: '.tmp/public/concat/production.css'
27 | }
28 | });
29 |
30 | grunt.loadNpmTasks('grunt-contrib-concat');
31 | };
32 |
--------------------------------------------------------------------------------
/project-skeletons/sails/tasks/config/copy.js:
--------------------------------------------------------------------------------
1 | /**
2 | * `copy`
3 | *
4 | * ---------------------------------------------------------------
5 | *
6 | * Copy files and/or folders from your `assets/` directory into
7 | * the web root (`.tmp/public`) so they can be served via HTTP,
8 | * and also for further pre-processing by other Grunt tasks.
9 | *
10 | * #### Normal usage (`sails lift`)
11 | * Copies all directories and files (except CoffeeScript and LESS)
12 | * from the `assets/` folder into the web root -- conventionally a
13 | * hidden directory located `.tmp/public`.
14 | *
15 | * #### Via the `build` tasklist (`sails www`)
16 | * Copies all directories and files from the .tmp/public directory into a www directory.
17 | *
18 | * For usage docs see:
19 | * https://github.com/gruntjs/grunt-contrib-copy
20 | *
21 | */
22 | module.exports = function(grunt) {
23 |
24 | grunt.config.set('copy', {
25 | dev: {
26 | files: [{
27 | expand: true,
28 | cwd: './assets',
29 | src: ['**/*.!(coffee|less)'],
30 | dest: '.tmp/public'
31 | }]
32 | },
33 | build: {
34 | files: [{
35 | expand: true,
36 | cwd: '.tmp/public',
37 | src: ['**/*'],
38 | dest: 'www'
39 | }]
40 | }
41 | });
42 |
43 | grunt.loadNpmTasks('grunt-contrib-copy');
44 | };
45 |
--------------------------------------------------------------------------------
/project-skeletons/sails/tasks/config/cssmin.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Compress CSS files.
3 | *
4 | * ---------------------------------------------------------------
5 | *
6 | * Minify the intermediate concatenated CSS stylesheet which was
7 | * prepared by the `concat` task at `.tmp/public/concat/production.css`.
8 | *
9 | * Together with the `concat` task, this is the final step that minifies
10 | * all CSS files from `assets/styles/` (and potentially your LESS importer
11 | * file from `assets/styles/importer.less`)
12 | *
13 | * For usage docs see:
14 | * https://github.com/gruntjs/grunt-contrib-cssmin
15 | *
16 | */
17 | module.exports = function(grunt) {
18 |
19 | grunt.config.set('cssmin', {
20 | dist: {
21 | src: ['.tmp/public/concat/production.css'],
22 | dest: '.tmp/public/min/production.min.css'
23 | }
24 | });
25 |
26 | grunt.loadNpmTasks('grunt-contrib-cssmin');
27 | };
28 |
--------------------------------------------------------------------------------
/project-skeletons/sails/tasks/config/jst.js:
--------------------------------------------------------------------------------
1 | /**
2 | * `jst`
3 | *
4 | * ---------------------------------------------------------------
5 | *
6 | * Precompile HTML templates using Underscore/Lodash notation into
7 | * functions, creating a `.jst` file. This can be brought into your HTML
8 | * via a