DEV Community

A road to the easiest user authentication system for Node.js

Shiono Yoshihide on December 15, 2018

JavaScript is easy to read and write, but sometimes we are facing difficulties like user authentication. Before talking about user authentication ...
Collapse
 
simonas88 profile image
simonas88

While this is nice and all, isn't it now no different than any other OOP-language code? Now I'm not saying javascript is good for the sake of being different, but why go all this length with the setup of tens of different libraries, when you could've arguably done it faster with the same result in .NET?

Collapse
 
maheshkale profile image
Mahesh K

Because not everyone wants to use .Net.

Collapse
 
academicrevolt profile image
Academic Revolt

.NET doesn't handle JSON as efficiently as Node.js. However, this tutorial uses postgres instead of mongo, so good point.

Collapse
 
guardadodev profile image
Guardadodev

Awesome project, I was just about to start an auth project just like this with the same stack!

Collapse
 
saltyshiomix profile image
Shiono Yoshihide

Thank you sooo much!
I hope you enjoy it :)

NestjS and NEXT.js are so awesome, I believe.

Collapse
 
yourleader profile image
yourleader

do you have any problema by running on dev?

Collapse
 
geshan profile image
Geshan Manandhar

Good post, great work!

Collapse
 
saltyshiomix profile image
Shiono Yoshihide

Thank you very much!
I'll implement social login like GitHub, soon :)

Collapse
 
chaostheory profile image
Brian Lee • Edited

Question: why did you use NestJS with NextJS? Isn't this all possible leaving out NestJS since NextJS has routing? I know NestJS, but I'm very new to NextJS.

Collapse
 
saltyshiomix profile image
Shiono Yoshihide

Next.js is a react framework that provides SSR(Server Side Rendering) easily.
So if you want to use react with better SEO, Next.js is one of the best choices.

Nest is just a server framework, so it doesn't care about client side.

Generally way, web services have two repositories: server repo and client one.
But I think it's complex enough to learn or test simple web stack :)

Collapse
 
igcp profile image
Igor Conde

Cool post,exactly what I was looking for, for studies.

Collapse
 
saltyshiomix profile image
Shiono Yoshihide

Thanks Igor!

Feel free to open issues if you have any troubles :)

By the way, I'm currently working on react-ssr, which is an alternative to NEXT.js. (I think)

This renders React as a view template engine of Express like this:

// server.js
const posts = [
  { id: 1, body: 'This is a first post.' },
  { id: 2, body: 'This is a second post.' },
  { id: 3, body: 'This is a last post.' },
];

app.get('/', (req, res) => {
  res.render('index', { posts });
});
// views/index.jsx
import React from 'react';

const IndexPage = ({ posts }) => {
  return (
    <React.Fragment>
      {posts.map((post, index) => {
        return (
          <p key={index}>
            <a href={'/posts/' + post.id}>{post.body}</a>
          </p>
        );
      })}
    </React.Fragment>
  );
};

export default IndexPage;

If you like, please try it :)

Thank you in advance!

Yoshihide

Collapse
 
yourleader profile image
yourleader

thanx , this is a very good work. I dont know if you have the time to help me, I can't run your code on dev. I thing the problem is in next.config.js file