sails.js

Sails.JS HTTP + HTTPS

▼魔方 西西 提交于 2019-11-30 13:13:59
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 HTTPS requests. Has anyone figured out how to get this done, without creating a separate HTTP only server

Bcrypt: invalid ELF header with Docker and Sails.JS

a 夏天 提交于 2019-11-30 13:08:20
My Node Dockfile : # Set the base image to ubuntu FROM ubuntu # Define working directory ADD . /src WORKDIR /src # Install Node.js & other dependencies RUN apt-get update && \ apt-get -y install curl && \ apt-get -y install sudo && \ curl -sL https://deb.nodesource.com/setup_0.12 | sudo bash - && \ apt-get -y install python build-essential nodejs RUN npm install -g node-gyp && \ node-gyp clean && \ npm cache clean RUN node -v # Install nodemon RUN npm install -g nodemon ADD package.json /src/package.json RUN cd /src && npm install # Expose port EXPOSE 8080 # Run app using nodemon CMD npm

How do I subscribe to a model instance in Sails.JS?

房东的猫 提交于 2019-11-30 11:06:50
问题 I am attempting to use the subscribe function described here. However, when editing /assets/js/app.js , I am getting this error: Uncaught ReferenceError: Room is not defined So, I am not entirely sure why, but it cannot find my model. Here is my code: Room.subscribe(req, [{id: "5278861ab9a0d2cd0e000001"}], function (response) { console.log('subscribed?'); console.log(response); }); and here is is in the context of app.js (function (io) { // as soon as this file is loaded, connect

Node.js (sails.js) wysiwyg editor - images

别来无恙 提交于 2019-11-30 10:24:43
Is there a way to use any WYSIWYG/html editor in the sails app? I can't find any manuals to do that. Seems like Mercury is well-supported in Node but I can't find a way to adapt sails for it either. :( Please guide me OK now, it turned up to be easy to connect TinyMCE (just as easy as described on http://www.tinymce.com/wiki.php/Installation ). So now another major question comes out: is there any Node.js connector to any editor for uploading images and stuff? Or just how can I allow user to upload an image and insert it to a post body? Thanks Yay! Finally did it! At last I used the CKEditor

Best way to migrate table changes to production sailsjs tables

走远了吗. 提交于 2019-11-30 09:26:15
I just lost 11,000 records from my database just running the command for sailsjs without the --prod part in it, So I thought I should ask whats the best way to change the tables on production server when the Model.js has been changed ? Thanks Automated migration should never be done in production. This a common-sense practice that applies to any production system with important data. There are a few solutions available for migrating a sails.js database. sails-db-migrate : db-migrate integration for sails.js db-migrate integration for Sails.js. This is a fairly simple wrapper, which provides

Inherit attributes and lifecycle functions of Sails.js models

狂风中的少年 提交于 2019-11-30 08:34:41
问题 I want to create a custom set of attributes and lifecycle methods that are shared between all my Sails.js models. Sails.js automatically creates and registers the model objects by calling the Waterline.Collection.extend() method and providing the model definition found inside the /api/models directory. What would be the best way to extend my model definition from a parent? I already tried using _.extend(sails.config.model.parentModel, childModel) but sadly the sails object is not exposed

Sails.js flash message for user registration

北城以北 提交于 2019-11-30 07:29:58
I am following Sail.js tutorial from http://irlnathan.github.io/sailscasts/blog/2013/08/27/building-a-sails-application-ep4-handling-validation-errors-with-a-flash-message/ However I ran into a small problem. In the tutorial the author uses registration files inside his user folder and assigns routes in the user controller. He then sends validation errors using flash to the user. However in my project, the registration files lies in the root folder and I assign the routes from the routes.js file like so module.exports.routes = { '/': { view: 'index' }, '/register': { view: 'register' } }; Now

Handling database environment configuration in Sails.js

你。 提交于 2019-11-30 07:26:19
The issue I have is related to the following quote from the official documentation : Note If any connection to an adapter is used by a model, then all connections to that adapter will be loaded on sails.lift, whether or not models are actually using them. In the example above, if a model was configured to use the localMysql connection, then both localMysql and remoteMysql would attempt to connect at run time. It is therefore good practice to split your connection configurations up by environment and save them to the appropriate environment-specific config files, or else comment out any

How do I convert an image to a base64-encoded data URL in sails.js or generally in the servers side JavaScript?

痞子三分冷 提交于 2019-11-30 07:04:03
问题 I am making a small app in sails.js and I need to store images in database. For that, I need to convert an image to a base64-encoded data URL so that I can save it as a string in my sails models. However, I don't know how to convert it in this form. All the older questions asked about converting an image to base64-encoded data URLs, and they answer this about doing it on the client side. However, I want to do it on the server side while I will be getting the image through a post request. How

Change field name for CreatedAt / UpdateAt Attributes

拜拜、爱过 提交于 2019-11-30 06:48:01
I am attempting to model an existing MSSQL table in SailsJS. Unsurprisingly the tables in the existing database have a createdAt and updatedAt column similar to what is generated by the SailsJS framework. Is there a way to assign the value of the property generated by the SailsJS framework to an attribute that I have defined? For example: attributes: { ... creationDate:{ columnName:'cre_dt', type:'datetime', defaultsTo: this.createdAt } ... } sgress454 No, but you can turn off the auto-generated property entirely and use your own: autoCreatedAt: false, autoUpdatedAt: false, attributes: {