Tutorials for a blogging application in node.js - javascript

I am learning node.js, and would like to try building a blog on the platform. Do you know of any good tutorials that show you, step-by-step, how to build a blogging app on node? I have seen one by Nettuts, but it doesn't explain a full solution, with databases an the like. So are there any good tutorials? I do not mind if it is text or video, as long as it is descriptive and helpful.
Thanks for any recommendations!

My blog is written in node.js and express.js. I uses just a simple git repo on the filesystem for the post content. It is open source at github.com/focusaurus/peterlyons.com. Feel free to look around if you find it helpful and shoot me follow-up questions. It is no-frills but does have a basic post editor with preview and allows me to add custom markup processing logic.
There is a fully automated deployment solution in there coded in Ansible and bash that I use to deploy it to both a Vagrant-based staging VM and a production digital ocean droplet.

You can try ExpressJS
As an ExpressJS intermediate, I can understand the question coz even I coudnt find an expressjs tutorial that "just" works and is minimal.
You can try this http://cwbuecheler.com/web/tutorials/2013/node-express-mongo/ tutorial or the hack sparrow express tut mentioned by Wyatt
If you are completely new to MVC web frameworks, its gonna take a lot of patience. Since I worked on Django befor, I was able to stand up n run pretty quickly with ExpressJS
So even if the tutorial doesnt make sense there's plenty of other resources likes docs, google and StackOverFlow :D

Node is all about using what is available in the ecosystem. npm is great and sets node apart from other environments. You could use, for example, Wheat.
That said, you could check out this article which is pretty old, but good.
Alternatively, I think the Hack Sparrow Express Tutorial would have a lot of valuable concepts for you, especially when coupled with his posts on Mongo.

Related

Stripe integration in an Expo managed project

I’m very new to programming, I know I’m not supposed to ask here, but I really got lost, I’m building a food ordering app with Expo and the only thing left for me is to add Stripe and building the iOS and android projects. I’m really confused on what are the next steps, some people talk about ejecting and then developing Stripe. The expo documentation just provides examples in TypeScript, and my project is in JavaScript. And the Stripe documentation talks about a “server-side” which I still can’t understand how it works, for example, when I launch then my app in the stores, do I have to run the server in my computer separately at all times when the app launches? Also I should add that I’m using Firebase for Authentication and Databases. If someone could provide me good tutorials or have some suggestions I’d be glad, thanks
Usually StackOverflow is for very specific question, not "global" how-tos, I won't then write code for you, but will try to explain as much as I can.
First of all welcome to the amazing world of programming ! One of my mentor oftenly says "Developer can change the world with a text editor".
Concerning your Expo App : No you don not need to eject to use Stripe, the great expo team is providing a brigde between #stripe/stripe-react-native and expo. You can read more here.
For the demo, just remove the typescript params, it should work like a charm (thus, as you're new to programming, I strongly recommend you to check typescript, as it's (almost) now a standard for JS programming, both front and backend).
For the backend part, yes, you'll have to create your own, raw - using the JS runtime Node.js (Express, Nest, Koa...), PHP, Python or any language you're familiar with, or a "serverless" one, you've mentionned Firebase, it's one of it, bit there're many solutions out there (AWS Lambdas...)
Of course, you won't have a backend on your computer, but on a dedicated server which will handle every call from your app serving from 'https://myapi.mydomain.com/what/to/do'. Imagine your app as a shop, a visitor can see shoes, try them, and if he/she wants it, he has to pay.
And here, usually the shop needs some customer informations (for retargeting) and stock management (Hey ! 4 customers has bought Shoes #42 in Size #4 and Color #17, we should reorder some), that requires a bit a security and business logic (confirm payments, send orders, ...).
Concerning Stripe, you'll need a backend to create a Customer cus_XXX, create a Payment Intent, send it back to your app and confirm it then (for Europe 3D Secure, or SCA stuff), it's slightly more complicated, i took the quickest path.
For the tutorials, there's PLENTY, if you can afford $10 to $50 check the insanely good ones from Udemy or Pluralsight otherwise, check Medium or just ... Google it with "Node.js getting started".
As you're new in programming, and as SO is slightly for more "advanced" peeps, I'd recommend you to find some dev community on Slack / Discord, you'll probably more "welcomed". At some point we're all the junior of someone, but this place is - once more - for very specific questions ;)
Happy programming !

Choosing right node.js server side framework for game development

I have an idea to create a browser-based game and I struggle to find the right tools to use. I'm a Python/Django developer right now, but I also would like to learn something new and try using node.js for backend. The thing is that there are a lot of frameworks around and I have no idea which one can be the most suitable for game development.
I have read a little bit about sails.js, hapi.js, total.js and others. Many of them sound nice and it is very hard to pick one.
A few of the requirements are:
Good performance
Easy use of web sockets
ORM with migration support (sails.js doesn't have migration support production ready)
Large community (a lot of packages for common scenarios etc., many questions already answered)
I hope somebody can help me to pick the right tool to use.

Best practices of building a website using Node.js

This question's answers are a community effort. Edit existing answers to improve this post. It is not currently accepting new answers or interactions.
I was wondering how one would go about developing a website from scratch with Node.js.
I understand how I could possibly do it, but I am interested in the best design practice.
I need this theoretical website to:
Do a lot of AJAX
Be very straightforward
Be relatively small
Connect to... let's say a MySQL server
In PHP, building a pretty small website was very straightforward - I set up PHP on Apache and a MySQL server and then do something like:
includes/db/ which has connect.php for connecting to the db, a file with common db related functions and so on
includes/layout/ which had stuff like footer.php, header.php, and other layout related stuff
includes/users/ to handle user related actions
Then PHP just let you build pages and include these files together to form a website - I could go something like:
<?php
require_once('inclues/users/user_session.php');
require_once('inclues/db/connect.php');
require_once('inclues/design/header.php')
?>
// Other php or html or related content relating to the page
<?php
require_once('inclues/.../footer.php');
?>
I was wondering what might be similar in Node.js - I am looking for a way to accomplish this which is as simple, fast and straightforward as possible.
If the answer is not simple, I would love a book recommendation, I don't mind reading.
I love event based programming, I really love JavaScript's abilities and I'm really excited about Node.js. I want to learn how to develop this sort of stuff with it the right way from the start.
To start with the bad news: As Node.js is a pretty young technique, I think you'll find that the proces of creating a full fledged website and maintaining/operating it will be very different than what you're currently used to.
Josh3736 adds: Once you figure out how Node.js and its various packages (Connect, Express) work, I found that you can develop new sites very quickly.
The rough edges that currently exist in Node.js, combined with the fast pace of its development and all modules involved can complicate things though, and make things less simple, fast and straightforward than you'd like.
Having that out of the way, here's the good news:
The Node Package Manager, NPM has a lot of good tools and frameworks to expand Node.js's bare bones functionality, making it suitable to create a webserver.
Most notably would be the Express Framework which contains almost everything you need to run a webserver (including cookies, sessions and path routing). Additionally Express supports partials, which take care of your header and footer includes.
Express is built on top of Sencha's Connect. Cookies and sessions are actually powered by Connect. Express is what simplifies your routing and handles views/partials. So if you don't need all bells and whistles that come with Express you could just go for Connect instead.
If you like to use templates for these partials, the Jade Template Engine can speed things up for you. Though Josh3736 points out that Jade is slow and whitespace-significant. A more complete overview can be found here, which includes his favourite, doT. (I personally use Node.js for socket.io based applications only, so he's a better source than me when it comes to templating).
You can connect to MySQL from Node.js using the db-mysql module, but if you don't need that because you're accessing data connected to an already present system, I'd advise to use a more... 'modern' approach, which is to use a NoSQL database as most Node.js projects seem to do. MongoDB via Mongoose is the popular way to go.
Or if it's just storing objects you're interested in, just go for Redis instead (which you're probably going to need at some point anyway).
Once your website is complete, you'll have to deploy it and make sure it keeps running. There are many ways to do so, like using built-in cluster support or use the more feature-friendly forever npm module. See this SO question of mine for more information.
Conclusion:
What I'm trying to get at is this:
Asking what the best practice for building a website in Node.js is, is about the same as asking what the best way to build a website in PHP is: 100 developers will give you 100 different answers.
NPM is blessed with a variety of excellent frameworks that greatly simplify a lot of tasks involved, but it's all based on preference which one is the way to go really.
As I've said, Node.js is still a pretty young technique, so none of the frameworks or additional tools have emerged as 'defacto standard' yet; for most things you're trying to do there are probably various alternatives, and expect your code to break when using most of them during updates, because development of Node.js itself and most modules is fast paced. You'll have to keep up.
Putting it all together:
As I've said, my main production use for Node.js is to be able to use socket.io, so I don't have any good production examples present (And as I'm about to leave on a well-deserved vacation I don't have the time to put one together either). There are some good examples though:
Setup and deployment using Express and Jade
A very complete blog example using Express, Jade and MongoDB
Combining Restify (an extension of Express), Backbone.js and Mongoose
Again, the way to go (and subsequently the example to follow) depends greatly on your ultimate goals and the techniques chosen, but luckily there are plenty of resources available for all of the choices available. Most modules use well documented GitHub repositories and include examples in combination with the most popular modules (See the /examples/ dir that seems to be present in most repositories).
(thanks to Josh3736 for rectifying my errors.)

Creating a Web2.0 application with Maven(or other build tools)

Background:
I've been building web apps and web sites for many years, but each time I tend to start from scratch as each project has different requirements. However, this has me building my workflow from scratch as well. At this point, I'm about ready to settle on something a little more standard.
But what exactly is that standard? Being a JAVA developer by nature, I'm drawn to tools like Maven. And I've seen some work in the community for better Javascript support in Maven (javascript-maven-tools, javascript-maven-plugin, and others). But is this the best way to do it? I tried for a while to find a good WEB2.0 client/ajax-app maven-archetype to no avail.
I'm going to want to use tools in my workflow including JSLint [[http://www.jslint.com]], JSUnit [[http://jsunit.net/]] for testing, Documentation with things such as JSDoc Toolkit [[http://code.google.com/p/jsdoc-toolkit/]]. Compression and Framework inclusion would be nice too.
So, at this point, I'm even stumped at the the basic ways to start my app. What should a directory structure look like? For a pure client/frontend app (so no controllers, etc), do i just have a single webapp directory?
I guess I'm at that point where I'm questioning "my religion" with webapps. And after talking to everyone I know, I figured it was time for me to open it up to a hive-mind far smarter than my own.
Note. This is a question I also wrote
about in general on my site at
[[http://blog.jbjonesjr.com/?p=283]]
, but no one every cares about it
there.
Thanks for the help, I look forward to your thoughts.
I've started a couple of plugins (this and this) on Codehaus that facilitate the use of Maven for building JavaScript applications following Maven's goal oriented approach. I want to do more of this including the provision of a Surefire-compatible unit testing plugin and a minification plugin that leverages assembles. Take a look at what I've done so far and feel free to help out!
I'm also considering providing a JavaScript DSL for Maven using Polyglot Maven. A colleague kindly pointed out that JavaScript programmers will probably want to express their poms using JavaScript, not XML. In addition they probably won't want the learning curve of Maven. A JavaScript DSL could facilitate that.

What had happend to Trimpath Junction Javascript Framework?

I've been desperately searching for a Javascript MVC framework to create rich client side applications with a Rails backend and I come across junction framework. It highly appeals to me due to its similarity with rails and offline capabilities. but unfortunately it has not been actively maintained for a long time.
I just wanted to know if the project still alive or I should look where else for a viable solution.
I know about sproutecore and cappuccino and I'm taking a close eye on them and their development process. But I'm really reluctant to learn something like a new language for this manner. In fact cappuccino using objectiveJ which is literally a new language running inside javascript.
IMHO, the killer framework would be something similar to Rails in structure, (as rails has already proved itself as a de facto structure for frameworks and has been ported to a lot of other frameworks) and uses jQuery to work with the dom and perform ajax calls. I still couldn't find it.
I'm not sure if it is still actively being developed.
I've been using Trimpath quite extensively myself lately and I didn't miss any features.
I sure hope it's still being developed but it's a great tool and really reduces development time.
I've searched for junction on the web and as far as I can tell the project is dead.
Try Ejscript: http://ejscript.org/products/ejs/webFramework.html
I'm a dev on Ejscript. The project not dead, just very focussed on embedded.

Categories

Resources