sails.js

sails logging to file

孤者浪人 提交于 2019-11-30 02:20:05
Can someone provide an example of how to configure sails.js to log to a file? It seems like it should be straightforward, but I'm having trouble finding examples online. I'm looking at changes in the config/log.js or the config/sockets.js files. According to the source code , for v0.9.x , you just have to set the filePath in your config/log.js : module.exports = { log: { level: 'info', filePath: 'application.log' } }; djsadinoff Logging to a file doesn't work out of the box. You need to invoke functionality in libraries two levels down. See the documentation for winston. first install winston

How to configure partials and layouts for Handlebars in Sails.js?

拜拜、爱过 提交于 2019-11-30 00:47:58
I run Sails 0.9.7 and have installed Handlebars which is supported by Consolidate.js and therefore is supported by Sails I can serve pages from .handlebars files, it works just fine. I can't figure where, in Sails workflow, and in a Sails way , I should register partials, helpers etc... I'm more looking for best practices than just a working solution but any help will be appreciated. I'm running v0.10 beta but this shouldn't affect how I got it working below: Engine should be handlebars as expected Routes need to explicitly define controller and action. Setting view won't work. (Unless there's

How to connect with mongodb using sailsjs v0.10?

怎甘沉沦 提交于 2019-11-30 00:23:02
Now Using sailsjs v0.10 . Configure connections.js and models.js and change it to connection: 'localMongodbServer' ,installed npm install sails-mongo. Aftet all this it shows error var des = Object.keys(dbs[collectionName].schema).length === 0 ? ^ TypeError: Cannot read property 'schema' of undefined at Object.module.exports.adapter.describe (app1_test/node_modules/sails-mongo/lib/adapter.js:70:48) If change collections.js to adapter.js shows error [err] In model (model1), invalid connection :: someMongodbServer [err] Must contain an `adapter` key referencing the adapter to use. Without seeing

How to use Sequelize in SailsJs

筅森魡賤 提交于 2019-11-29 22:39:46
Waterline is an excellent ORM but I noticed that there are many features that are not present yet on waterline but Sequelize already have. So I have decided to switch to sequelize but still using Sails for the others things. I have search tutorial how to switch to sequelize but nothing. How can I replace Waterline for sequelize in sails Js? I've moved forward with sequelize as well, there are two project that came out really recently, so i would like to announce them. sails-hook-sequelize: It follows the answer by Manuel Darveau, it will fetch all your models, import through sequelize and

Argument must be a string in nodejs

岁酱吖の 提交于 2019-11-29 20:22:32
问题 I'm having the following code: var objectid = infos[i].id; var name = infos[i].name; return collection.aggregate([ {$match: {app: new ObjectId(objectid)}}, {$group: {_id: "$uid", amt: {$sum: 1}}} ]) Previously this code was working fine, but recently I started getting the below stacktrace in sails: error: TypeError: Argument must be a string at TypeError (native) at Buffer.write (buffer.js:791:21) at serializeObjectId (/Users/user/git/pivot/code/node_modules/sails-mongo/node_modules/bson/lib

Node.js Web Application examples/tutorials [closed]

与世无争的帅哥 提交于 2019-11-29 18:36:12
So I finished watching Douglas Crockford's excellent series on Javascript, and in the final episode (so far), loopage he lays out why Node.js is a near perfect solution for server side code. He talks about keeping state, not in the database, but in closures running in Node.js, he also states that templating systems (like JSP, PHP, and ASP) are a poor abstraction for more complicated Web Applications and that node.js provides a solution to this. And I am ready to buy in, but I can't find any examples of Web Applications using this pattern, or any books or tutorials about how to go about doing

Sails.JS HTTP + HTTPS

岁酱吖の 提交于 2019-11-29 18:20:13
问题 I am trying to figure out how to lift a sails app that responds to both HTTP and HTTPS requests. I used the config/local.js method of configuring express like so (detailed here): var fs = require('fs'); module.exports = { port: process.env.PORT || 1337, environment: process.env.NODE_ENV || 'development', express: { serverOptions : { key: fs.readFileSync('ssl/key.pem'), cert: fs.readFileSync('ssl/cert.pem') }} }; However, while this works, it results in the server only being able to serve

Mocha tests, clean disk database before every file runs

本秂侑毒 提交于 2019-11-29 17:21:01
I am using Sails 1.x. Is it possible to reset the Sails.js database before each test file runs? I want it to be in state after sails.lift() completes before each run. I followed the docs here - https://sailsjs.com/documentation/concepts/testing - but did not end up with any solution like this. The only solution I'm having right now is to change the lifecyle.test.js before and after to run beforeEvery and afterEvery - https://sailsjs.com/documentation/concepts/testing - so this is lifting everytime before test. But it takes a long time to lift. This is very simple to do. You just need to

how to configure https in sails.js

こ雲淡風輕ζ 提交于 2019-11-29 17:18:21
问题 I am trying to setup a local HTTPS server for testing in Sails.js? I am not able to find any pointer how to do that in sails.js? For express, var express = require('express'); var https = require('https'); var http = require('http'); var fs = require('fs'); // This line is from the Node.js HTTPS documentation. var options = { key: fs.readFileSync('test/fixtures/keys/agent2-key.pem'), cert: fs.readFileSync('test/fixtures/keys/agent2-cert.pem') }; // Create a service (the app object is just a

How to render a view to a string?

狂风中的少年 提交于 2019-11-29 16:31:06
I want to render a specific view in a sailsjs controller/action which should be sent out as email. I have the following sample action: function registerAction(req, res) { // handle user registration // email user sendEmail({ to: newUser.email, subject: "Welcome", text: /* VIEW RENDER HERE */ }); // render view to the user return res.view({ user: newUser }); } How can I render a view-template with the tools sailsjs provides so that I don't need to hardcode an email text or use other libraries? Thanks in advance! Express' res.render() is still accessible in your res object. function