How to integrate Sails.js with Drywall - javascript

I'm evaluating Sails.js for my next project. I think it is a very well laid out project and the framework for Node that mostly resembles Django, that I'm used to.
One thing that every Django developer is gonna miss from any framework not providing it, is the admin page, a very quick and powerful way to administrate the site as you go, test out things, input the initial data and so on.
I've found out Drywall and it looks amazing. Only, it is a framework by its own. I'd just like to use Sails for the site and have a backend administration page provided by Drywall.
How to integrate the two, or: is there any admin plugin for Sails.js?
Thanks

Sails.js Admin Page Scaffolding has been an open issue for a few months now. I think it may come after associations which would make sense - what is User administration if you can't change its Role presented by its label rather than its id.
It shouldn't be too hard since Sails already produce a REST API for each model you set up.
Using Drywall with Sails seems pretty difficult. Sails is DB agnostic while Drywall wants you to use MongoDB.
Drywall seems more like a tool to build website where Sails is more like a framework to build api based webapp.

I am the co-creator of Strapi.
Strapi is a Node.js framework based on Koa. It ships a complete user system management and an auto-generated admin panel.
Feel free to try it and let us know if you have any question.
Pierre

Related

Vue.js: Backend realization

So, I have been learning Vue.js as my first js framework for some time and after I made some simple SPA:s without much interactions with a server I started to wonder: What should a backend be like with Vue? For education purposes I gave it a try and came up with some pattern on my own and now I can't imagine anything else, maybe I got some wrong idea.
What I came up with: I made a simple API with PHP which was receiving requests from the frontend (Vue component methods reacting on UI events) and requesting data from the model or updating data through it.
There are a lot of different Backend Solutions and you should take what fits your websites purpose and also personal preference the best.
If Backend includes Hosting in your case then you basicly have the 2 big options:
a) A Server where you run it ex. via an Reverse Proxy (example: Digital Ocean)
b) A cloud computing Platform (example: AWS, Heroku, App Engine)
But you only need to host it that way if you actually run the app and retrieve dynamic updates on the page, new routes get added when you for example publish a new Post.
If that is not the case then a static hosting provider would be enough, there are 1000´s of them and they are pretty uncomplicated.
If you mean which Database to use, then it also comes down to preference, do you want a SQL Databse or a NoSQL Database like MongoDB? As a personal recommendation I would suggest you to use Firebase as your backend for your experimental app, the free plan is far than enough for testing purposes, you also have a smooth and easy to integrate Authentication System avaliable and you can also take quick advantage of things like Push Messages, Cloud Storage Buckets and more.
Note that Im not related to FB by any means and this is just a personal recommendation, but I feel like your Question is pretty opinion based so maybe be more specific about your goals or just comment down below if you got any more questions.

Reactjs and data on server

I'm new to Javascript frameworks and looking for framework for my new projects. Until now i created simple apps using MVC framework Django with Bootstrap frontend. Thanks framework i got everything in one package with best-practice well know. For Javascript i used some jQuery libraries without understanding, just configured with doc help.
When i tried to write some Javascript on my own and found there are big changes in JS world (like ES6, TypeScript) i found it very usefull. When i found JS frameworks, i felt in love.
I have read about frameworks, watched some tutorials. As many other, i found React nice. But what i'm completely missing, is the server part. Especially React tutorials creates components or functions, nice UI, but don't cover what happens with data next. I know that React is ment as "V" in MVC. But what is the best-practice or wide-used extension for server part? Are there tutorials or book to take me further than just creating actions and UI?
Thanks for any links, i just need to point best direction. Or is React ment for just specific project parts and better to look elsewhere?
As you said, yes there are quite a number of tutorials and most of them don't cover how do you deploy node apps on the servers. I'll assume you have some server admin knowledge so I'll skip straight to the meat of the setup.
The Server Setup
Regardless of it being a simple static page, a single page API or a react app, you will need to have Node.js installed on any server you will want it to run. Second you will need a production process manager for Node.js. My personal favourite is PM2. The process manages makes sure your app is always on and restarts it if it goes down for whatever reason. You will also need a reverse proxy server (you need this for security and SEO purposes). Again, a go-to for it is Nginx (it's a competitor of Apache)
Two very good tutorials for setting up your server are
Tut #1
Tut #2
The App Setup
Apart from all the server setup you need to handle routing for your app (what happens when you to go to /blog or /login). A stable standard right now is Express.js. You can do without but then you will need to write a lot of the manual routing by hand in Node.js You will set up Express to server back your Index file and any others you may need.
A good tutorial for configuring your Express for a React app is Video Tut.
He does show a bit more but that is on later videos. You can stop once you get the gist of it.
Advanced Stuff
There's also the matter if you want the JavaScript to be rendered on the server or on the client side. For that you will need to make some more configuration for you app. The video tutorial I linked above should show you how to set that up as well if you are interested.

Suggestion for the best way to store persistent data for a light-weight, portable JS-based web app

I'm still new to web development. To learn more about JavaScript(JS) and web development, I am thinking of writing a simple web app which pulls and records time-series data (say, the price of a stock) periodically and draws a live chart showing the historical data. In addition to price data, I would like the app to record/maintain some user-related info such as the ticker of the stock(s) associated to each user.
Ideally, I would like to keep the app light-weight and portable/standalone (meaning, reduce the dependency as much as possible, and the end user hopefully doesn't have to do a lot of configuration/install of dependencies). The issue that I cannot figure out is where to store the historical data. I looked around for database solutions which will allow the app to write data directly from the browser (that is, using JS) to the client's machine. LocalStorage and IndexDB are non-persistent as far as I understand. Some suggested using PouchDB, but upon looking at it closer, it seems like the user need to install CouchDB or some compatible DB (say, SQLite). But that means I cannot share my app with users who aren't technical enough to install and configure CouchDB or SQLite on their machine before using my app.
If anyone could share some insights as to which DB might allow a JS-based app to write persistent data to the client's machine (if such thing even exist), that would be greatly helpful. If there is no such DB solution, please feel free to let me know alternative solutions that would allow the goal of building a simple, portable, JS-based web app. Thank you!
I think the best solution is to use Electron.js. The whole idea of this framework is to create web apps that can reside on client machines. You could package up any DB option you want, or even better, just include an API to your backend through the web app and it will work on your client machine like I think you want it to.
As for DB options, there is a great thread on S.O. that talks about what is possible. It looks like knex.js is your best bet (full disclosure - I haven't used knex).

Simple realtime web app to be used as a 'voting terminal'

I am asked to project a web solution to allow vote casting in public assemblies.
The solution shall be written with node.js on the server, and javascript, possibly using angular.js on the client (since javascript is the language I know best, today :-).
The app shall run on mobile devices, and will be quite simple: it shall handle some sort of authentication, to identify the owner of the device (the 'user'), and shall show a form with two buttons (Yes and No).
The button press shall be sent to a central server (on the LAN).
The server shall collect and store the votes from the users, and shall choose when to enable the buttons (voting session opened), and when to disable them (voting session closed).
Trying to be clearer, the app shall replace current devices, which look like this one:
It's not so clear from the picture, but the device has two buttons, one for "Yes" vote, and one for "No" (there are more buttons, but their use is irrilevant, here).
Initially the app will handle only the vote casting (not the audio).
I'm totally new to web realtime programming, so I'm in doubt about which software stack of libraries to adopt for the project.
Googling around, I see socket.io could be a good solution, but I prefer asking the community, to try to find the most suited solution for the job.
So the final question: do you know of any open-source project, tutorial, bolg post, anything I could study to start designing the app I tried to describe?
Any solution, observation, opinion, real-life experience would be welcome, too...
I would also look at PubNub, which is a realtime global data stream network--here's a good voting app tutorial to get started: https://www.pubnub.com/blog/2014-11-18-power-a-realtime-voting-app-with-live-results-using-d3js/
There's great developer resources to get your started, for help, and lots of add-ons, like presence, history, and realtime charts, like EON: https://www.pubnub.com/developers/eon/
Socket.io is used essentially when you need something in realtime. The tradition RESTful APIs are a better/proven method.
To get started I would suggest reading up on the MEAN stack (also allows you to use the MongoDB database), A couple of tutorials should be a good starting point :
https://scotch.io/tutorials/setting-up-a-mean-stack-single-page-application
https://thinkster.io/mean-stack-tutorial
https://www.npmjs.com/package/slush-meanjs is a good resource to scaffold out your project. Slush is a generator that uses GULP as compared to yeoman generators which are only just beginning to implement gulp as its task-runner (currently uses grunt as the default task runner). Yeoman still doesnt have a great generator for the MEAN stack. If however you plan to exclude the database a good starting point would be to just use express on the backend and angularjs as the front end. To do this you can scaffold out a express project using generator-express (https://github.com/petecoop/generator-express) and once express is setup you can add angular to it using https://github.com/yeoman/generator-angular.
The directory would look something like this :
-app
---*client side libs*
-bin
--- www /* npm start to start the server */
-routes/ /* for all your express routing */
-test/
...
-app.js
...
For authentication you could use the scaffolded out CRUD model. If using socket.io for all the client server communication this is a good resource -
https://auth0.com/blog/2014/01/15/auth-with-socket-io/

Node.js Rest Framework

I plan to write a rather large-scale web application using JavaScript. I believe I will be developing the webapp using CanJS to organize my client-side pieces.
I am strongly considering using Node.js for my server-side component, but I was wondering what the best way to set up Node to accept and handle REST requests. I did some Googling and came across something called Express. Any comments on this?
Any help/suggestions would be greatly appreciated.
restify is a node.js module built specifically to enable you to build correct REST web services.
http://mcavage.github.com/node-restify/
Express is more directed towards full web application (rendering HTML, etc). Restify is just for web services.
Besides, the guy who created Restify works at Joyent, the company where Ryan Dahl developped Node.js (which is kind of guarantee quality).
For REST request handling, express-resource is a more focused solution than railwayjs that's also built on top of expressjs.
You can try http://railwayjs.com/ it is build on top of http://expressjs.com/
Express is nice and fast :) railway has similar stack to ruby on rails.
http://expressjs.com is the de factor standard, does Sinatra-like routing. If you want real easy automatic generation of resources (sort of Rails-style), try one of those libraries above.
If you want it real simple on top of express, try http://github.com/deitch/booster
Disclosure: I just released Booster this week.

Categories