Browse Source

Sails starts up and passes the JSON test

Zane Kansil 10 years ago
parent
commit
f354952414

+ 1 - 0
.travis.yml

@@ -86,6 +86,7 @@ env:
     - "TESTDIR=JavaScript/nodejs"
     - "TESTDIR=JavaScript/ringojs"
     - "TESTDIR=JavaScript/ringojs-convenient"
+    - "TESTDIR=JavaScript/sailsjs"
     - "TESTDIR=Lua/lapis"
     - "TESTDIR=Lua/openresty"
     - "TESTDIR=Nim/jester"

+ 21 - 0
frameworks/JavaScript/sailsjs/api/controllers/JsonTestController.js

@@ -0,0 +1,21 @@
+/**
+ * JsonTestController
+ *
+ * @description :: Server-side logic for managing Jsontests
+ * @help        :: See http://links.sailsjs.org/docs/controllers
+ */
+
+module.exports = {
+	
+
+
+  /**
+   * Test 1: JSON Serialization
+   */
+  get: function (req, res) {
+    return res.json({
+      message: 'Hello, World!'
+    });
+  }
+};
+

+ 15 - 0
frameworks/JavaScript/sailsjs/api/models/JsonTest.js

@@ -0,0 +1,15 @@
+/**
+* JsonTest.js
+*
+* @description :: TODO: You might write a short summary of how this model works and what it represents here.
+* @docs        :: http://sailsjs.org/#!documentation/models
+*/
+
+module.exports = {
+
+  attributes: {
+
+    message : { type: 'string' }
+  }
+};
+

+ 28 - 0
frameworks/JavaScript/sailsjs/benchmark_config.json

@@ -0,0 +1,28 @@
+{
+  "framework": "sailsjs",
+  "tests": [{
+    "default": {
+      "setup_file": "setup",
+      "json_url": "/json",
+      "db_url": "/db",
+      "query_url": "/queries?queries=",
+      "fortune_url": "/fortunes",
+      "update_url": "/updates?queries=",
+      "plaintext_url": "/plaintext",
+      "port": 8080,
+      "approach": "Realistic",
+      "classification": "Fullstack",
+      "database": "MySQL",
+      "framework": "sailsjs",
+      "language": "JavaScript",
+      "orm": "Waterline",
+      "platform": "nodejs",
+      "webserver": "None",
+      "os": "Linux",
+      "database_os": "Linux",
+      "display_name": "Sails.js",
+      "notes": "",
+      "versus": "node"
+    }
+  }]
+}

+ 14 - 5
frameworks/JavaScript/sailsjs/config/http.js

@@ -21,7 +21,7 @@ module.exports.http = {
   *                                                                           *
   ****************************************************************************/
 
-  // middleware: {
+  middleware: {
 
   /***************************************************************************
   *                                                                          *
@@ -30,7 +30,7 @@ module.exports.http = {
   *                                                                          *
   ***************************************************************************/
 
-    // order: [
+    order: [
     //   'startRequestTimer',
     //   'cookieParser',
     //   'session',
@@ -40,13 +40,22 @@ module.exports.http = {
     //   'compress',
     //   'methodOverride',
     //   'poweredBy',
+      'disablePoweredBy',
     //   '$custom',
-    //   'router',
+      'router'
     //   'www',
     //   'favicon',
     //   '404',
     //   '500'
-    // ],
+    ],
+
+    // Replacing the x-powered-by header with the expected
+    // server header for TFB
+    disablePoweredBy: function(req, res, next) {
+      res.removeHeader("x-powered-by")
+      res.set('Server', 'Sails <sailsjs.org>');
+      next();
+    },
 
   /****************************************************************************
   *                                                                           *
@@ -71,7 +80,7 @@ module.exports.http = {
 
     // bodyParser: require('skipper')
 
-  // },
+  },
 
   /***************************************************************************
   *                                                                          *

+ 1 - 1
frameworks/JavaScript/sailsjs/config/models.js

@@ -27,6 +27,6 @@ module.exports.models = {
   * See http://sailsjs.org/#/documentation/concepts/ORM/model-settings.html  *
   *                                                                          *
   ***************************************************************************/
-  // migrate: 'alter'
+  migrate: 'safe'
 
 };

+ 3 - 1
frameworks/JavaScript/sailsjs/config/routes.js

@@ -34,7 +34,9 @@ module.exports.routes = {
 
   '/': {
     view: 'homepage'
-  }
+  },
+
+  'get /json': 'JsonTestController.get'
 
   /***************************************************************************
   *                                                                          *

+ 3 - 0
frameworks/JavaScript/sailsjs/install.sh

@@ -0,0 +1,3 @@
+#!/bin/bash
+
+fw_depends nvm

+ 17 - 0
frameworks/JavaScript/sailsjs/setup.sh

@@ -0,0 +1,17 @@
+## put sed here later
+
+export NVM_HOME=${IROOT}/nvm
+
+# Used to avoid nvm's return 2 error.
+# Sourcing this functions if 0 is returned.
+source $NVM_HOME/nvm.sh || 0
+nvm install 0.12.2
+nvm use 0.12.2
+
+# update npm before app init
+npm install -g npm
+npm install -g sails
+
+# run app
+npm install
+sails lift --port 8080 &

+ 3 - 0
frameworks/JavaScript/sailsjs/views/layout.ejs

@@ -29,6 +29,7 @@
     -->
 
     <!--STYLES-->
+    <link rel="stylesheet" href="/styles/importer.css">
     <!--STYLES END-->
   </head>
 
@@ -59,6 +60,7 @@
     -->
 
     <!--TEMPLATES-->
+    
     <!--TEMPLATES END-->
 
 
@@ -86,6 +88,7 @@
     -->
 
     <!--SCRIPTS-->
+    <script src="/js/dependencies/sails.io.js"></script>
     <!--SCRIPTS END-->
   </body>
 </html>