Module for Sailsjs - node.js

I am facing a new project that will be probably made with sails.js. Is there any way to write 'modules' for Sails, so I can isolate specific views, controllers, models, services, etc. in a module (folder) I can add or remove easily? If not, any idea / hack to achieve this?
Thanks in advance

As we all know sails.js is built over node.js and express.js. We can write modules for node.js and then include them in our sails projects..
Here is a beautiful tutorial on how to write and publish node modules..

Related

Is it possible to have MVC in sub folders when using node.js express framework?

Is it possible to have MVC in sub folders (modules) when using node.js express framework?
Today I have this structure of my project:
Controllers
Blog/*
Poll/*
And many more
Models
Blog/*
Poll/*
And many more
View
Blog/*
Poll/*
And many more
Routes
Blog
Poll
And many more
Should it be possible to have this structure in a module way instead?:
Blog
Controllers/*
Models/*
View/*
routes.js
Poll
Controllers/*
Models/*
View/*
routes.js
And more modules
When I develop I feel I mostly work with one part of the project at the time. When I the current structure its a lot of moving between folders. However most of the time I only focus on "module". It will also be easier to remove as module just to delete the sub folder and all it files are removed. If a project has more 30 modules it will be hard to find the file (Its possible to search but should be nice just have it in same folder). I been working with Drupal before that has this type of module system where you can easy add and remove modules (Might be that am used to to it and not yet familiar with this new this way of doing it). What are the main benefits of the first approach over the module way?
Is this possible to achieve in the express framework? If so any tutorials on how to set it up? Any other node.js framework support this?

Angular2 and NodeJs

I'm trying to create an Angular2 project with a REST service, using NodeJs. Although I found some tutorials/sample codes doing this kind of applications, the organization of the code/project is different form each other. I'm trying to figure out what's the best way so far to do that.
Basically,
what is the best approach to creating Angular2 project with NodeJs back end?
what should be the folder structure?
where to put the Angular code(with TypeScript)?
how to use Bower/Gulp?
A sample of Angular2 + NodeJS and a few other things: http://thejackalofjavascript.com/developing-a-mean-app-with-angular-2-0/
You can use Angular-Cli to create the initial project structure: https://github.com/angular/angular-cli
Gulp tutorial: https://scotch.io/tutorials/automate-your-tasks-easily-with-gulp-js
I do not recommend using bower. Use npm instead, as it is more stable, and has more support from the tools.

Codeigniter Or Node js?

I am building a web app for redirection.The web app could have more than 500 concurrent user.
I had developed so many of projects in codeigniter but as per speed is concern, some people suggest me to switch to node js. Please help me out , would it be good to switch to node js ? What could be advantage of it ?
If you need something easily extensible, which has numbers of libraries built and open sourced that are easily added into your codebase then use CodeIgnitor, it is a great place to start.Pair it with Nginx instead of Apache (and code smart, damnit) and you'll get solid speed.
And if you're building a single page site, you're really great at Javascript, then you can go with Node.
Node js is asynchronous,so it serves request faster,if you are good at JS then node is a good option i think !
look at this link
http://www.toptal.com/nodejs/why-the-hell-would-i-use-node-js
you can try node js also with Sails Js Framework,its a framework some what like MVC Structure as like in Codeigniter framework.you can create your patter structure (controller,model,views)

How can I properly structure my NodeJS, Express, and MongoDB code?

I am new to all three but I do know javascript well. I understand basics of them all but do not understand what the best way to implement the NodeJS server javascript with the express MVC and MongoDB database querys. I want to break up all this into their own files obviously but I am not sure how everything fits into the pre-created project template created by Express. Does anyone have a good solution or resource to share with me? Thank you
I recently started with node.js, express and mongodb myself and it's true the resources out there are mostly outdated. First of all, express is not an mvc framework. It has no opinion on the structure which you'll find out that it makes it so great. Your question is how to organise the code? It's clearly a personal preference but you can create a model folder where you can put your db queries for specific resources, your lib folder where you can establish a connection to your mongodb instance and call it wherever you need it and use the routes folder for your more specific needs like controllers on a traditional MVC. Another thing is that you have to decide how to interact with mongo. You can either use the native mongodb driver, perhaps with mongoskin as suggested, or mongoose for easier interactions such as defining schemas. Personally i prefer the native but it took me a while to get what it does and how it works. Finally for resources what i can suggest from personal experience and it's still my own opinion, is that the best thing you can do is buy the book Node.js in Action which was what made me realize what node.js is all about and how to use it. Hope it helps...

Open existing Node.js Project in a TypeScript project

I currently have an existing project in Node.js and I would like to migrate it to a TypeScript project.
How can I do this?
Thanks for the help.
The easiest way to do this is to look at the Node sample provided with the TypeScript. It already includes declarations for the built-in NodeJS modules.
After importing the node.js you can start by converting your modules one by one. Since the Typescript will convert into JS, you can convert one file at a time and test it right away!
With ambients it should be easy to do! Good luck with your conversion.

Resources