mern-social | MERN stack based social media application [ Full-Stack | Runtime Evironment library
kandi X-RAY | mern-social Summary
kandi X-RAY | mern-social Summary
A simple social media application with users, posts, likes and comments - developed using React, Node, Express and MongoDB.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of mern-social
mern-social Key Features
mern-social Examples and Code Snippets
Community Discussions
Trending Discussions on mern-social
QUESTION
I came by a code that was using req.profile for reading data.How is this possible?
...ANSWER
Answered 2021-Mar-05 at 04:15The key is middleware. In Express, before a request hits a route handler (what you're referencing), it can go through a series of middlewares that can add or modify the request or response objects.
Here is where it sets req.profile
:
QUESTION
I am looking at some code from someone else for learning purposes. The way they're mounting routes is vague to me.
...ANSWER
Answered 2019-Aug-26 at 09:51Writing routes directly can be confusing and difficult to manage if there are large number of routes. So according to MVC pattern, the application is divided into modules/logical blocks based on functionalities they perform. For example, a simple hospital management system can have authentication, billing, payroll , medical-stock , patients etc modules (imaginary). If you are building application using MVC pattern, the common practice is to write controller for each of the module. Express provides something called middleware also called as Router to attach these controllers to respective API routes (Imagine it as a sort of map that connects each route to respective controller).
Once you define routes for each of these modules through middleware, you use those routes with your application. These routes handle requests and send parameters to controller to process. You can learn how to use Middleware and Routers here : https://www.tutorialspoint.com/expressjs/expressjs_routing.htm
Regarding quality of code, dividing the code into modules and using routers to connect them is less tedious for others to understand. It also provides a good view of the application and it becomes easier to add new modules / functionality.
You can read more about building production-ready express app here : https://www.freecodecamp.org/news/how-to-write-a-production-ready-node-and-express-app-f214f0b17d8c/
QUESTION
im trying to install MERN-Social-Network from git hub node js code by Faiyaz Shaikh yTakkar
and face this error :
...ANSWER
Answered 2018-Aug-07 at 08:03Ad you said in the comments your Node.JS version is v6.10.0
unfortunately this version doesn't support async/await
functions.
You can check Here: https://node.green/#ES2017-features-async-functions
Async/await
support starts from version 7.0.0
where you need to add the --harmony
flag to enable ES6/ES7 features. From 7.6.0
it is supported.
So, there are multiple ways you can achieve the same result.
1) Use Promise
instead of async/await
2) Use babel
to transpile the code into ES5. You can do this by running the code through babel-load
if you are using webpack(mostly used for frontend products)
3) You can update your node to >7.6.x
Note: If you see in the package.json
of that repository you can see that it is recommended to use node>8 for this project (accorind to the author)
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install mern-social
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page