Giter VIP home page Giter VIP logo

react-node-next-multi-user-blogging-platform's Introduction

Generat NodeJs MongoDB API with Full Authentication in seconds ๐Ÿธ

  • Ready to use API with login and register system
  • Includes forgot password and reset password feature
  • Folder structure includig routes and controllers

Install Globally

sudo npm i -g kaloraat

Create project

mkdir server
cd server
kaloraat-make-auth
Running project
  • Update config.js with real mongodb connection uri and sendgrid api keys (for sending email)
  • Get inside your project and run npm install
  • Then run npm start to start your node server/API with full authentication
  • Visit http://localhost:8000/api to check your server/API running
Generate route and controller file

kaloraat-make-route

Generate model

kaloraat-make-model

react-node-next-multi-user-blogging-platform's People

Contributors

kaloraat avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

react-node-next-multi-user-blogging-platform's Issues

Unhandled Rejection

ร—
Unhandled Rejection (TypeError): Cannot read property 'error' of undefined
(anonymous function)
./components/auth/SignupComponent.js:24
21 | const user = { name, email, password };
22 |
23 | signup(user).then(data => {

24 | if (data.error) {
| ^ 25 | setValues({ ...values, error: data.error, loading: false });
26 | } else {
27 | setValues({

Great work! I'm your student from Udemy.

Will you expand this or make into a real blogging creation platform site in future?

Maybe you can fork a version for the opensource community to contribute etc.

Please do that. Thanks.

License?

Could you tell me what license your code is using? Thanks

Cheers
Elliott

50 create blog with categories and tags: backend code is not working

your example (solution ) code is not working ใ…ก.ใ…ก I used promise and async/await but still not working... I don't know what problem is
`
const Blog = require('../models/blog');
const Category = require('../models/category');
const Tag = require('../models/tag');
const formidable = require('formidable');
const slugify = require('slugify');
const stripHtml = require('string-strip-html');
const _ = require('lodash');
const { errorHandler } = require('../helpers/dbErrorHandler');
const fs = require('fs');

exports.create = (req, res) => {
let form = new formidable.IncomingForm();
form.keepExtensions = true;
form.parse(req, (err, fields, files) => {
if (err) {
return res.status(400).json({
error: 'Image could not upload'
});
}

  const { title, body, categories, tags } = fields;

  if (!title || !title.length) {
      return res.status(400).json({
          error: 'title is required'
      });
  }

  if (!body || body.length < 200) {
      return res.status(400).json({
          error: 'Content is too short'
      });
  }

  if (!categories || categories.length === 0) {
      return res.status(400).json({
          error: 'At least one category is required'
      });
  }

  if (!tags || tags.length === 0) {
      return res.status(400).json({
          error: 'At least one tag is required'
      });
  }

  let blog = new Blog();
  blog.title = title;
  blog.body = body;
  blog.slug = slugify(title).toLowerCase();
  blog.mtitle = `${title} | ${process.env.APP_NAME}`;
  blog.mdesc = stripHtml(body.substring(0, 160));
  blog.postedBy = req.user._id;
  // categories and tags
  let arrayOfCategories = categories && categories.split(',');
  let arrayOfTags = tags && tags.split(',');

  if (files.photo) {
      if (files.photo.size > 10000000) {
          return res.status(400).json({
              error: 'Image should be less then 1mb in size'
          });
      }
      blog.photo.data = fs.readFileSync(files.photo.path);
      blog.photo.contentType = files.photo.type;
  }

  blog.save((err, result) => {
      if (err) {
          return res.status(400).json({
              error: errorHandler(err)
          });
      }
      // res.json(result);
      Blog.findByIdAndUpdate(result._id, { $push: { categories: arrayOfCategories } }, { new: true }).exec(
          (err, result) => {
              if (err) {
                  return res.status(400).json({
                      error: errorHandler(err)
                  });
              } else {
                  Blog.findByIdAndUpdate(result._id, { $push: { tags: arrayOfTags } }, { new: true }).exec(
                      (err, result) => {
                          if (err) {
                              return res.status(400).json({
                                  error: errorHandler(err)
                              });
                          } else {
                              res.json(result);
                          }
                      }
                  );
              }
          }
      );
  });

});
};
`

Unable to get username from isAuth()

To list all blogs created by the specific user, isAuth() from actions returns undefined value if it is used as const username = isAuth() && isAuth().username .
The backend controller method is working perfectly fine, tried passing the user Id by manually typing it into the code and it works.
Repo Code
So it is not getting the value from LocalStorage

login problem

When you open the window to login with facebook, but you close the window, it shows an error evety time you visit any part of the page

Unhandled Rejection (TypeError): Cannot read property 'error' of undefined

Unable to return the related blogs in the component.
Also tried { JSON.strigify(related) } to debug the error which gives
{"related":[]}

The ERROR :

(anonymous function)
./pages/blogs/[slug].js:19 is returning error

17 |    const loadRelated = () => {
  18 |        listRelated({blog}).then(data => {
> 19 |            if (data.error) {
^  20 |                console.log(data.error);
  21 |            } else {
  22 |                setRelated(data);

Security by Obscurity

Correct me if I'm wrong but if a hacker guesses an admin _id in the pubic db, he could gain access to all admin apis such as adding or deleting categories or tags. I believe a token should be used to access those restricted apis.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.