<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Chris Wang</title>
    <description>The latest articles on DEV Community by Chris Wang (@itwebtiger).</description>
    <link>https://dev.to/itwebtiger</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1096753%2F9b662ff5-f93b-4d3e-a9fc-c0fd20ccfca6.png</url>
      <title>DEV Community: Chris Wang</title>
      <link>https://dev.to/itwebtiger</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/itwebtiger"/>
    <language>en</language>
    <item>
      <title>Free React Dashboard - Tailwind CSS &amp; TypeScript</title>
      <dc:creator>Chris Wang</dc:creator>
      <pubDate>Fri, 30 Jun 2023 02:51:51 +0000</pubDate>
      <link>https://dev.to/itwebtiger/free-react-dashboard-tailwind-css-typescript-17i6</link>
      <guid>https://dev.to/itwebtiger/free-react-dashboard-tailwind-css-typescript-17i6</guid>
      <description>&lt;p&gt;Get started and build your dream web app with WorkDaily UI, the trendiest &amp;amp; innovative Open Source Admin Template for Tailwind CSS &amp;amp; React!&lt;/p&gt;

&lt;p&gt;I used React v18.2.0, so you can use the benefits of &lt;a href="https://react.dev/reference/react" rel="noopener noreferrer"&gt;React v18&lt;/a&gt; in the project. &lt;/p&gt;

&lt;p&gt;You can download the full codebase &lt;a href="https://github.com/itwebtiger/workdaily-tailwind-react-ts" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;




&lt;h3&gt;
  
  
  Introduction
&lt;/h3&gt;

&lt;p&gt;Designed for those who like modern UI elements and beautiful websites. Made of hundred of elements, designed blocks and fully coded pages, WorkDaily UI is ready to help you create stunning websites and webapps.&lt;/p&gt;

&lt;p&gt;Save hundreds of hours trying to create and develop a dashboard from scratch.&lt;br&gt;
The fastest, most responsive &amp;amp; trendiest dashboard for Tailwind CSS is here. Seriously.&lt;/p&gt;

&lt;p&gt;Authentication Pages, Profile and so on. Just choose between a Basic Design or a cover and you are good to go!&lt;/p&gt;

&lt;h3&gt;
  
  
  New WorkDaily UI Components 🎉
&lt;/h3&gt;

&lt;p&gt;All the main components will help you to see and interact with all &amp;amp; the latest added components of WorkDaily (also, new components are on the way, stay tuned)! ⚡️&lt;/p&gt;

&lt;h3&gt;
  
  
  Documentation
&lt;/h3&gt;

&lt;p&gt;Each element is well presented in a very complex documentation. Now I am working on that.&lt;/p&gt;

&lt;h4&gt;
  
  
  Login Pages
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Dark Mode:
&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fchrisw.vercel.app%2F_next%2Fimage%3Furl%3D%252F_next%252Fstatic%252Fmedia%252Flogin-dark.04bf4528.png%26w%3D1920%26q%3D75" alt="Login-Dark-Mode"&gt;

&lt;/li&gt;
&lt;li&gt;Light Mode:
&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fchrisw.vercel.app%2F_next%2Fimage%3Furl%3D%252F_next%252Fstatic%252Fmedia%252Flogin-light.30f0d8e3.png%26w%3D1920%26q%3D75" alt="Login-Dark-Mode"&gt;

&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Dashboard Pages
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Dark Mode:
&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fchrisw.vercel.app%2F_next%2Fimage%3Furl%3D%252F_next%252Fstatic%252Fmedia%252Fdash-dark.48c3d0f4.png%26w%3D1920%26q%3D75" alt="Dashboard-Dark-Mode"&gt;

&lt;/li&gt;
&lt;li&gt;Light Mode:
&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fchrisw.vercel.app%2F_next%2Fimage%3Furl%3D%252F_next%252Fstatic%252Fmedia%252Fdash-light.2ae0b903.png%26w%3D1920%26q%3D75" alt="Dashboard-Dark-Mode"&gt;

&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Quick Start
&lt;/h3&gt;

&lt;p&gt;Install WorkDaily UI by running either of the following:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Install NodeJS LTS from &lt;a href="https://nodejs.org/en" rel="noopener noreferrer"&gt;NodeJs Official Page&lt;/a&gt; (NOTE: Product only works with LTS version).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Clone the repository with the following command:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;

git clone https://github.com/itwebtiger/workdaily-tailwind-react-ts.git


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Run in terminal this command:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;

yarn


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Then run this command to start your local server&lt;/p&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;

&lt;p&gt;yarn start&lt;/p&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h3&gt;
&lt;br&gt;
  &lt;br&gt;
  &lt;br&gt;
  References&lt;br&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/itwebtiger/workdaily-tailwind-react-ts" rel="noopener noreferrer"&gt;https://github.com/itwebtiger/workdaily-tailwind-react-ts&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://chrisw.vercel.app/projects/react/dshboard-template" rel="noopener noreferrer"&gt;https://chrisw.vercel.app/projects/react/dshboard-template&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://tailwindcss.com/" rel="noopener noreferrer"&gt;https://tailwindcss.com/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://react.dev/reference/react" rel="noopener noreferrer"&gt;https://react.dev/reference/react&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>react</category>
      <category>tailwindcss</category>
      <category>typescript</category>
      <category>dashboard</category>
    </item>
    <item>
      <title>AWS Cognito Sign In with Node.js</title>
      <dc:creator>Chris Wang</dc:creator>
      <pubDate>Fri, 09 Jun 2023 19:06:45 +0000</pubDate>
      <link>https://dev.to/itwebtiger/aws-cognito-sign-in-with-nodejs-2pkd</link>
      <guid>https://dev.to/itwebtiger/aws-cognito-sign-in-with-nodejs-2pkd</guid>
      <description>&lt;p&gt;Let's add AWS Cognito Sign In function to the Node project today.&lt;br&gt;
I suppose your project already add AWS Cognito Sign Up to your project.&lt;/p&gt;

&lt;p&gt;If not, please take a look at my provious articles:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Article&lt;/th&gt;
&lt;th&gt;Codebase&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href="https://dev.to/itwebtiger/express-es6-boilerplate-2pd5"&gt;ES6 Node-Express Boilerplate&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;&lt;a href="https://github.com/itwebtiger/express-amazon-cognito/tree/init-expressjs" rel="noopener noreferrer"&gt;https://github.com/itwebtiger/express-amazon-cognito/tree/init-expressjs&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href="https://dev.to/itwebtiger/aws-cognito-setup-for-user-authentication-2c2"&gt;AWS Cognito Setup&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;----&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href="https://dev.to/itwebtiger/aws-cognito-sign-up-with-nodejs-4202"&gt;AWS Cognito Sign Up with Node.js&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;&lt;a href="https://github.com/itwebtiger/express-amazon-cognito/tree/cognito-signup" rel="noopener noreferrer"&gt;https://github.com/itwebtiger/express-amazon-cognito/tree/cognito-signup&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href="https://dev.to/itwebtiger/aws-cognito-sign-up-confirm-with-nodejs-1501"&gt;AWS Cognito Sign Up Email Confirm with Node.js&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;&lt;a href="https://github.com/itwebtiger/express-amazon-cognito/tree/cognito-signupconfirm" rel="noopener noreferrer"&gt;https://github.com/itwebtiger/express-amazon-cognito/tree/cognito-signupconfirm&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Also, you can download the &lt;a href="https://github.com/itwebtiger/express-amazon-cognito/tree/congnito-signin" rel="noopener noreferrer"&gt;full codebase&lt;/a&gt; here for AWS Cognito Signin if you are interested in this &lt;em&gt;AWS Cognito Sign In&lt;/em&gt;.&lt;/p&gt;



&lt;h3&gt;
  
  
  Add a AWS Cognito Sign In route
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Add &lt;a href="https://github.com/itwebtiger/express-amazon-cognito/blob/d4ce8b6f277033c2504e51c941740425905ee1c1/routes/auth.routes.js#L15" rel="noopener noreferrer"&gt;/api/auth/signin&lt;/a&gt; route in existing your node.js project, if don't use &lt;a href="https://github.com/itwebtiger/express-amazon-cognito/blob/congnito-signin/middleware/validateSigninRequest.js" rel="noopener noreferrer"&gt;validateSigninRequest&lt;/a&gt; middleware, then you can remove the &lt;code&gt;validateSigninRequest&lt;/code&gt; middleware.&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

import controller from '../controllers/auth.controller';
import {
  validateSignupRequest,
  validateSignupConfirmRequest,
} from '../middleware';

export default (app) =&amp;gt; {
  app.post('/api/auth/signup', validateSignupRequest, controller.signup);
  app.post(
    '/api/auth/email/verify',
    validateSignupConfirmRequest,
    controller.signupConfirm,
  );
  app.post('/api/auth/signin', validateSigninRequest, controller.signin); // add signin route
};


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Add a Sign In Function in the auth controller.
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Add a &lt;a href="https://github.com/itwebtiger/express-amazon-cognito/blob/d4ce8b6f277033c2504e51c941740425905ee1c1/controllers/auth.controller.js#L72" rel="noopener noreferrer"&gt;Sign In Function&lt;/a&gt; in the controller.&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

// User Signup
import CognitoIdentity from '../services/cognito';

const CognitoIdentityService = CognitoIdentity();

const signin = async (req, res) =&amp;gt; {
  const { email, password } = req.body;
  const cognitoParams = {
    username: email,
    password,
  };

  try {
    const cognitoUser = await new Promise((resolve, reject) =&amp;gt; {
      CognitoIdentityService.signin(cognitoParams, (err, user) =&amp;gt; {
        if (err) {
          reject(err);
        } else {
          resolve(user);
        }
      });
    });

    // DB logic here
    // ...

    res.status(200).send({
      success: true,
      message: 'User logined successfully',
      user: cognitoUser,
    });
  } catch (error) {
    res.status(400).send({ success: false, message: error.message, error });
  }
};

export default {
  signup,
  signupConfirm,
  signin, // add
};


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Add a Sign Up Email Confirm in the services.
&lt;/h3&gt;

&lt;p&gt;And then we need to add the AWS Cognito user authentication service to the services folder. I will use the amazon-cognito-identity-js for the service.&lt;br&gt;
If you don't understand how to work the service, please check the service folder structure on &lt;a href="https://github.com/itwebtiger/express-amazon-cognito/blob/congnito-signin/services/cognito/methods/signin.js" rel="noopener noreferrer"&gt;my git repository&lt;/a&gt;.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

services/
  └──cognito/
        ├── index.js
        └── methods/
              ├── index.js
              ├── signup.js
              ├── signin.js // add
              └── signupConfirm.js



&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;This is a signin file, please add it.&lt;/p&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

&lt;p&gt;import {&lt;br&gt;
  CognitoUserPool,&lt;br&gt;
  CognitoUser,&lt;br&gt;
  AuthenticationDetails,&lt;br&gt;
} from 'amazon-cognito-identity-js';&lt;/p&gt;

&lt;p&gt;/**&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Signin&lt;/li&gt;
&lt;li&gt;@param {*} poolData&lt;/li&gt;
&lt;li&gt;@param {{username, password}} body&lt;/li&gt;
&lt;li&gt;@param {*} callback
*/&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;const signin = (poolData, body, callback) =&amp;gt; {&lt;br&gt;
  const userPool = new CognitoUserPool(poolData);&lt;/p&gt;

&lt;p&gt;const { username, password } = body;&lt;/p&gt;

&lt;p&gt;const authenticationData = {&lt;br&gt;
    Username: username,&lt;br&gt;
    Password: password,&lt;br&gt;
  };&lt;/p&gt;

&lt;p&gt;const authenticationDetails = new AuthenticationDetails(authenticationData);&lt;/p&gt;

&lt;p&gt;const userData = {&lt;br&gt;
    Username: username,&lt;br&gt;
    Pool: userPool,&lt;br&gt;
  };&lt;/p&gt;

&lt;p&gt;const cognitoUser = new CognitoUser(userData);&lt;/p&gt;

&lt;p&gt;cognitoUser.authenticateUser(authenticationDetails, {&lt;br&gt;
    onSuccess: (res) =&amp;gt; {&lt;br&gt;
      const data = {&lt;br&gt;
        refreshToken: res.getRefreshToken().getToken(),&lt;br&gt;
        accessToken: res.getAccessToken().getJwtToken(),&lt;br&gt;
        accessTokenExpiresAt: res.getAccessToken().getExpiration(),&lt;br&gt;
        idToken: res.getIdToken().getJwtToken(),&lt;br&gt;
        idTokenExpiresAt: res.getAccessToken().getExpiration(),&lt;br&gt;
      };&lt;br&gt;
      callback(null, data);&lt;br&gt;
    },&lt;br&gt;
    onFailure: (err) =&amp;gt; {&lt;br&gt;
      callback(err);&lt;br&gt;
    },&lt;br&gt;
    mfaRequired: () =&amp;gt; {&lt;br&gt;
      const data = {&lt;br&gt;
        nextStep: 'MFA_AUTH',&lt;br&gt;
        loginSession: cognitoUser.Session,&lt;br&gt;
      };&lt;br&gt;
      callback(null, data);&lt;br&gt;
    },&lt;br&gt;
    totpRequired: () =&amp;gt; {&lt;br&gt;
      const data = {&lt;br&gt;
        nextStep: 'SOFTWARE_TOKEN_MFA',&lt;br&gt;
        loginSession: cognitoUser.Session,&lt;br&gt;
      };&lt;br&gt;
      callback(null, data);&lt;br&gt;
    },&lt;br&gt;
    newPasswordRequired: () =&amp;gt; {&lt;br&gt;
      const data = {&lt;br&gt;
        nextStep: 'NEW_PASSWORD_REQUIRED',&lt;br&gt;
        loginSession: cognitoUser.Session,&lt;br&gt;
      };&lt;br&gt;
      callback(null, data);&lt;br&gt;
    },&lt;br&gt;
  });&lt;br&gt;
};&lt;/p&gt;

&lt;p&gt;export default signin;&lt;/p&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h3&gt;
&lt;br&gt;
  &lt;br&gt;
  &lt;br&gt;
  The Result in the Postman&lt;br&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fchrisw.vercel.app%2F_next%2Fimage%3Furl%3D%252F_next%252Fstatic%252Fmedia%252Fauthsignin.982a566e.png%26w%3D1920%26q%3D75" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fchrisw.vercel.app%2F_next%2Fimage%3Furl%3D%252F_next%252Fstatic%252Fmedia%252Fauthsignin.982a566e.png%26w%3D1920%26q%3D75" alt="Cognito email verification"&gt;&lt;/a&gt;&lt;/p&gt;



&lt;h3&gt;
  
  
  References
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://github.com/itwebtiger/express-amazon-cognito/tree/congnito-signin" rel="noopener noreferrer"&gt;https://github.com/itwebtiger/express-amazon-cognito/tree/congnito-signin&lt;/a&gt;&lt;br&gt;
&lt;a href="https://docs.aws.amazon.com/cognito/latest/developerguide/cognito-user-pools-social-idp.html#cognito-user-pools-social-idp-step-1" rel="noopener noreferrer"&gt;https://docs.aws.amazon.com/cognito/latest/developerguide/cognito-user-pools-social-idp.html#cognito-user-pools-social-idp-step-1&lt;/a&gt;&lt;/p&gt;

</description>
      <category>cognito</category>
      <category>signin</category>
      <category>autho</category>
      <category>node</category>
    </item>
    <item>
      <title>AWS Cognito Sign Up Confirm with Node.js</title>
      <dc:creator>Chris Wang</dc:creator>
      <pubDate>Fri, 09 Jun 2023 09:42:53 +0000</pubDate>
      <link>https://dev.to/itwebtiger/aws-cognito-sign-up-confirm-with-nodejs-1501</link>
      <guid>https://dev.to/itwebtiger/aws-cognito-sign-up-confirm-with-nodejs-1501</guid>
      <description>&lt;p&gt;Let's add AWS Cognito Sign Up Confirm function to the Node project today.&lt;br&gt;
I suppose your project already add AWS Cognito Sign Up to your project.&lt;/p&gt;

&lt;p&gt;If not, please take a look at my provious articles:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Article&lt;/th&gt;
&lt;th&gt;Codebase&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href="https://dev.to/itwebtiger/express-es6-boilerplate-2pd5"&gt;ES6 Node-Express Boilerplate&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;&lt;a href="https://github.com/itwebtiger/express-amazon-cognito/tree/init-expressjs" rel="noopener noreferrer"&gt;https://github.com/itwebtiger/express-amazon-cognito/tree/init-expressjs&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href="https://dev.to/itwebtiger/aws-cognito-setup-for-user-authentication-2c2"&gt;AWS Cognito Setup&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;----&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href="https://dev.to/itwebtiger/aws-cognito-sign-up-with-nodejs-4202"&gt;AWS Cognito Sign Up with Node.js&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;&lt;a href="https://github.com/itwebtiger/express-amazon-cognito/tree/cognito-signup" rel="noopener noreferrer"&gt;https://github.com/itwebtiger/express-amazon-cognito/tree/cognito-signup&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Also, you can download the &lt;a href="https://github.com/itwebtiger/express-amazon-cognito/tree/cognito-signupconfirm" rel="noopener noreferrer"&gt;full codebase&lt;/a&gt; here if you are interested in this &lt;em&gt;AWS Cognito Sign Up Email Confirm&lt;/em&gt;.&lt;/p&gt;


&lt;h2&gt;
  
  
  Add a AWS Cognito Sign Up Email Confirm route
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Add &lt;a href="https://github.com/itwebtiger/express-amazon-cognito/blob/3b9d84108bf4eb3c55cc154be0347292e9016f07/routes/auth.routes.js#L9" rel="noopener noreferrer"&gt;/api/auth/email/verify&lt;/a&gt; route in existing your node.js project, if don't use &lt;a href="https://github.com/itwebtiger/express-amazon-cognito/blob/3b9d84108bf4eb3c55cc154be0347292e9016f07/middleware/validateSignupConfirmRequest.js" rel="noopener noreferrer"&gt;validateSignupRequest&lt;/a&gt; middleware, then you can remove the &lt;code&gt;validateSignupRequest&lt;/code&gt; middleware.
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import controller from '../controllers/auth.controller';
import {
  validateSignupRequest,
  validateSignupConfirmRequest,
} from '../middleware';

export default (app) =&amp;gt; {
  app.post('/api/auth/signup', validateSignupRequest, controller.signup);
  app.post(
    '/api/auth/email/verify',
    validateSignupConfirmRequest,
    controller.signupConfirm,
  );
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Add a Sign Up Email Confirm Function in the auth controller.
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Add a &lt;a href="https://github.com/itwebtiger/express-amazon-cognito/blob/3b9d84108bf4eb3c55cc154be0347292e9016f07/controllers/auth.controller.js#L39" rel="noopener noreferrer"&gt;Sign Up Email Confirm Function&lt;/a&gt; in the controller.
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// User Signup
import CognitoIdentity from '../services/cognito';

const CognitoIdentityService = CognitoIdentity();

const signup = async (req, res) =&amp;gt; {
  // Signup logic here
  // ...

  const { email, password, givenname, familyname } = req.body;

  const cognitoParams = {
    username: email,
    password,
    givenname,
    familyname,
  };

  try {
    const cognitoUser = await new Promise((resolve, reject) =&amp;gt; {
      CognitoIdentityService.signup(cognitoParams, (err, user) =&amp;gt; {
        if (err) {
          reject(err);
        } else {
          resolve(user);
        }
      });
    });

    res.status(200).send({
      success: true,
      message: 'User registered successfully',
      user: cognitoUser,
    });
  } catch (error) {
    res.status(400).send({ success: false, message: error.message, error });
  }
};

const signupConfirm = async (req, res) =&amp;gt; {
  const { email, code } = req.body;
  const cognitoParams = {
    username: email,
    confirmationCode: code,
  };

  try {
    await new Promise((resolve, reject) =&amp;gt; {
      CognitoIdentityService.signupConfirm(cognitoParams, (err, user) =&amp;gt; {
        if (err) {
          reject(err);
        } else {
          resolve(user);
        }
      });
    });

    // DB logic here
    // ...

    res.status(200).send({
      success: true,
      message: 'User email confirmed successfully',
      user: {
        user_confirmed: true,
      },
    });
  } catch (error) {
    res.status(400).send({ success: false, message: error.message, error });
  }
};

export default {
  signup,
  signupConfirm,
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Add a Sign Up Email Confirm in the services.
&lt;/h2&gt;

&lt;p&gt;And then we need to add the AWS Cognito user authentication service to the services folder. I will use the amazon-cognito-identity-js for the service.&lt;br&gt;
If you don't understand how to work the service, please check the service folder structure on &lt;a href="https://github.com/itwebtiger/express-amazon-cognito/blob/cognito-signupconfirm/services/cognito/methods/signupConfirm.js" rel="noopener noreferrer"&gt;my git repository&lt;/a&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;services/
  └──cognito/
        ├── index.js
        └── methods/
              ├── index.js
              ├── signup.js
              └── signupConfirm.js

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is a signupConfirm file, please add it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { CognitoUserPool, CognitoUser } from 'amazon-cognito-identity-js';

/**
 * Confirm the signup action
 * @param {*} poolData
 * @param {{username, confirmationCode}} body
 * @param {*} callback
 */

const signupConfirm = (poolData, body, callback) =&amp;gt; {
  const userPool = new CognitoUserPool(poolData);

  const { username, confirmationCode } = body;

  const userData = {
    Username: username,
    Pool: userPool,
  };

  const cognitoUser = new CognitoUser(userData);

  cognitoUser.confirmRegistration(confirmationCode, true, (err, res) =&amp;gt;
    callback(err, res),
  );
};

export default signupConfirm;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  The Result in the Postman
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fchrisw.vercel.app%2F_next%2Fimage%3Furl%3D%252F_next%252Fstatic%252Fmedia%252Fauthsignupverify.54bb3cb6.png%26w%3D1920%26q%3D75" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fchrisw.vercel.app%2F_next%2Fimage%3Furl%3D%252F_next%252Fstatic%252Fmedia%252Fauthsignupverify.54bb3cb6.png%26w%3D1920%26q%3D75" alt="Cognito email verification"&gt;&lt;/a&gt;&lt;/p&gt;



&lt;p&gt;We will take a look at AWS Cognito login in the next article.&lt;br&gt;
If you like this type of content you can give me a star on my &lt;a href="https://github.com/itwebtiger/express-amazon-cognito/tree/cognito-signupconfirm" rel="noopener noreferrer"&gt;GitHub repository&lt;/a&gt; for the latest updates.&lt;/p&gt;

&lt;h2&gt;
  
  
  References
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://github.com/itwebtiger/express-amazon-cognito/tree/cognito-signupconfirm" rel="noopener noreferrer"&gt;https://github.com/itwebtiger/express-amazon-cognito/tree/cognito-signupconfirm&lt;/a&gt;&lt;br&gt;
&lt;a href="https://docs.aws.amazon.com/cognito/latest/developerguide/cognito-user-pools-social-idp.html#cognito-user-pools-social-idp-step-1" rel="noopener noreferrer"&gt;https://docs.aws.amazon.com/cognito/latest/developerguide/cognito-user-pools-social-idp.html#cognito-user-pools-social-idp-step-1&lt;/a&gt;&lt;/p&gt;

</description>
      <category>aws</category>
      <category>signup</category>
      <category>cognito</category>
      <category>node</category>
    </item>
    <item>
      <title>AWS Cognito Sign Up with Node.js</title>
      <dc:creator>Chris Wang</dc:creator>
      <pubDate>Wed, 07 Jun 2023 14:07:58 +0000</pubDate>
      <link>https://dev.to/itwebtiger/aws-cognito-sign-up-with-nodejs-4202</link>
      <guid>https://dev.to/itwebtiger/aws-cognito-sign-up-with-nodejs-4202</guid>
      <description>&lt;p&gt;Hope you have already set up the Node.JS environment on your system and exist &lt;a href="https://dev.to/itwebtiger/express-es6-boilerplate-2pd5"&gt;Express.js project&lt;/a&gt; and the AWS Cognito on AWS side, if didn't set up the AWS Cognito, then use the &lt;a href="https://dev.to/itwebtiger/aws-cognito-setup-for-user-authentication-2c2"&gt;following tutorial&lt;/a&gt; for AWS Cognito setup. Also, you can download the full codebase(opens in a new tab) here if you are interested in this AWS Cognito Sign Up.&lt;/p&gt;

&lt;h3&gt;
  
  
  Set Cognito environment variables
&lt;/h3&gt;

&lt;p&gt;Then we will use these environment variables in the Node project.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Add these environment variables to .env and &lt;a href="https://github.com/itwebtiger/express-amazon-cognito/blob/cognito-signup/example.env" rel="noopener noreferrer"&gt;example.env&lt;/a&gt; files&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

  AWS_COGNITO_REGION=
  AWS_COGNITO_USER_POOL_ID=
  AWS_COGNITO_CLIENT_ID=
  AWS_COGNITO_IDENTITY_POOL_ID=


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

  AWS_COGNITO_REGION=ca-central-1
  AWS_COGNITO_USER_POOL_ID=ca-central-1_oOXMEFtX3
  AWS_COGNITO_CLIENT_ID=54ado14mc8n0cmnm5s70vsis63
  AWS_COGNITO_IDENTITY_POOL_ID=ca-central-1:18ec2ec3-9e0a-474c-9d82-eb811b028e83


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h3&gt;
  
  
  Add a Sign Up Route in the Node.js Project
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Add &lt;a href="https://github.com/itwebtiger/express-amazon-cognito/blob/cognito-signup/routes/auth.routes.js" rel="noopener noreferrer"&gt;/api/auth/signup&lt;/a&gt; route in existing your node.js project, if don't use &lt;a href="https://github.com/itwebtiger/express-amazon-cognito/blob/cognito-signup/middleware/validateSignupRequest.js" rel="noopener noreferrer"&gt;validateSignupRequest&lt;/a&gt; middleware, then you can remove the &lt;code&gt;verifySignUp&lt;/code&gt; middleware.&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

import controller from '../controllers/auth.controller';
import validateSignupRequest from '../middleware/validateSignupRequest';

export default (app) =&amp;gt; {
  app.post('/api/auth/signup', validateSignupRequest, controller.signup);
};


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Add a Sign Up Function in the auth controller.
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Add a &lt;a href="https://github.com/itwebtiger/express-amazon-cognito/blob/cognito-signup/controllers/auth.controller.js" rel="noopener noreferrer"&gt;Sign Up Function&lt;/a&gt; in the controller.&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

// User Signup
import CognitoIdentity from '../services/cognito';

const CognitoIdentityService = CognitoIdentity();

const signup = async (req, res) =&amp;gt; {
  // Signup logic here
  // ...

  const { email, password, givenname, familyname } = req.body;

  const cognitoParams = {
    username: email,
    password,
    givenname,
    familyname,
  };

  try {
    const cognitoUser = await new Promise((resolve, reject) =&amp;gt; {
      CognitoIdentityService.signup(cognitoParams, (err, user) =&amp;gt; {
        if (err) {
          reject(err);
        } else {
          resolve(user);
        }
      });
    });

    res.status(200).send({
      success: true,
      message: 'User registered successfully',
      user: cognitoUser,
    });
  } catch (error) {
    res.status(400).send({ success: false, message: error.message, error });
  }
};

export default {
  signup,
};


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Add a Sign Up in the services.
&lt;/h3&gt;

&lt;p&gt;And then we need to add the AWS Cognito user authentication service to the services folder. I will use the amazon-cognito-identity-js for the service.&lt;br&gt;
If you don't understand how to work the service, please check the service folder structure on &lt;a href="https://github.com/itwebtiger/express-amazon-cognito/blob/cognito-signup/services/cognito/methods/signup.js" rel="noopener noreferrer"&gt;my git repository&lt;/a&gt;.&lt;/p&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

&lt;p&gt;import {&lt;br&gt;
  CognitoUserPool,&lt;br&gt;
  CognitoUserAttribute,&lt;br&gt;
} from 'amazon-cognito-identity-js';&lt;/p&gt;

&lt;p&gt;const attributes = (key, value) =&amp;gt; ({&lt;br&gt;
  Name: key,&lt;br&gt;
  Value: value,&lt;br&gt;
});&lt;/p&gt;

&lt;p&gt;/**&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Signup user
*&lt;/li&gt;
&lt;li&gt;@param {poolData} poolData&lt;/li&gt;
&lt;li&gt;@param {{ username: string, password: string, givenname: string, familyname: string, }} body&lt;/li&gt;
&lt;li&gt;@param {*} callback
*/&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;const signup = (poolData, body, callback) =&amp;gt; {&lt;br&gt;
  const userPool = new CognitoUserPool(poolData);&lt;/p&gt;

&lt;p&gt;const { username, password, givenname, familyname } = body;&lt;br&gt;
  const attributesList = [&lt;br&gt;
    attributes('email', username),&lt;br&gt;
    attributes('given_name', givenname),&lt;br&gt;
    attributes('family_name', familyname),&lt;br&gt;
  ];&lt;/p&gt;

&lt;p&gt;const cognitoAttributeList = attributesList.map(&lt;br&gt;
    (element) =&amp;gt; new CognitoUserAttribute(element),&lt;br&gt;
  );&lt;/p&gt;

&lt;p&gt;userPool.signUp(&lt;br&gt;
    username,&lt;br&gt;
    password,&lt;br&gt;
    cognitoAttributeList,&lt;br&gt;
    null,&lt;br&gt;
    (err, res) =&amp;gt; {&lt;br&gt;
      if (err) {&lt;br&gt;
        callback(err);&lt;br&gt;
        return;&lt;br&gt;
      }&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  const data = {
    user_id: res.userSub,
    email: res.username,
    user_confirmed: res.userConfirmed,
  };

  callback(null, data);
},
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;);&lt;br&gt;
};&lt;/p&gt;

&lt;p&gt;export default signup;&lt;/p&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h3&gt;
&lt;br&gt;
  &lt;br&gt;
  &lt;br&gt;
  The Result in the Postman&lt;br&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fchrisw.vercel.app%2F_next%2Fimage%3Furl%3D%252F_next%252Fstatic%252Fmedia%252Fauthsignup.d4911e8e.png%26w%3D1920%26q%3D75" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fchrisw.vercel.app%2F_next%2Fimage%3Furl%3D%252F_next%252Fstatic%252Fmedia%252Fauthsignup.d4911e8e.png%26w%3D1920%26q%3D75" alt="Cognito Test"&gt;&lt;/a&gt;&lt;/p&gt;



&lt;h3&gt;
  
  
  6 Digit OTP For Email Verification.
&lt;/h3&gt;

&lt;p&gt;Then you will receive the 6 Digit OTP for email verification as shown below in the screenshot.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fchrisw.vercel.app%2F_next%2Fimage%3Furl%3D%252F_next%252Fstatic%252Fmedia%252Fverification.0b007530.png%26w%3D1200%26q%3D75" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fchrisw.vercel.app%2F_next%2Fimage%3Furl%3D%252F_next%252Fstatic%252Fmedia%252Fverification.0b007530.png%26w%3D1200%26q%3D75" alt="Cognito email verification"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you want you can customize your email messages. So when a user sign ups he will get an email to confirm his account. You can customize that message.&lt;/p&gt;

&lt;p&gt;This is it for the signup scope now. We will take a look at signup email verification in the &lt;a href="https://dev.to/itwebtiger/aws-cognito-sign-up-confirm-with-nodejs-1501"&gt;next article&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;If you like this type of content you can give me a star on my &lt;a href="https://github.com/itwebtiger/express-amazon-cognito/tree/init-expressjs" rel="noopener noreferrer"&gt;GitHub repository&lt;/a&gt; for the latest updates.&lt;/p&gt;

&lt;h3&gt;
  
  
  References
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://github.com/itwebtiger/express-amazon-cognito/tree/cognito-signup" rel="noopener noreferrer"&gt;https://github.com/itwebtiger/express-amazon-cognito/tree/cognito-signup&lt;/a&gt;&lt;br&gt;
&lt;a href="https://chrisw.vercel.app/projects/node/cognito/signup" rel="noopener noreferrer"&gt;https://chrisw.vercel.app/projects/node/cognito/signup&lt;/a&gt;&lt;br&gt;
&lt;a href="https://docs.aws.amazon.com/cognito/latest/developerguide/cognito-user-pools-social-idp.html#cognito-user-pools-social-idp-step-1" rel="noopener noreferrer"&gt;https://docs.aws.amazon.com/cognito/latest/developerguide/cognito-user-pools-social-idp.html#cognito-user-pools-social-idp-step-1&lt;/a&gt;&lt;/p&gt;

</description>
      <category>aws</category>
      <category>cognito</category>
      <category>node</category>
      <category>express</category>
    </item>
    <item>
      <title>AWS Cognito Setup for User Authentication</title>
      <dc:creator>Chris Wang</dc:creator>
      <pubDate>Wed, 07 Jun 2023 12:55:06 +0000</pubDate>
      <link>https://dev.to/itwebtiger/aws-cognito-setup-for-user-authentication-2c2</link>
      <guid>https://dev.to/itwebtiger/aws-cognito-setup-for-user-authentication-2c2</guid>
      <description>&lt;h2&gt;
  
  
  AWS Cognito Overview
&lt;/h2&gt;

&lt;p&gt;Amazon Cognito lets you add user sign-up, sign-in, and access control to your web and mobile apps quickly and easily. Amazon Cognito scales to millions of users and supports sign-in with social identity providers, such as Facebook, Google, and Amazon, and enterprise identity providers via SAML 2.0.&lt;/p&gt;

&lt;p&gt;Let’s understand what is AWS Cognito User Pool and AWS Cognito Federal Identity&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;AWS Cognito User Pool&lt;/li&gt;
&lt;li&gt;AWS Cognito Federated Identities&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  1. AWS Cognito User Pool
&lt;/h3&gt;

&lt;p&gt;A User Pool is the user directory that you can configure for your web and mobile apps. A User Pool securely stores your users’ profile attributes. You can create and manage a User Pool using the AWS console, AWS CLI, or AWS SDK.&lt;/p&gt;

&lt;h4&gt;
  
  
  Create Cognito User Pool
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Sign in/up to your AWS account from the Services drop-down menu select Cognito then you will see the following screen. Click to the User Pools Button in the left sidebar.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--LD3Msp99--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://chrisw.vercel.app/_next/image%3Furl%3D%252F_next%252Fstatic%252Fmedia%252Fuserpool01.22121787.png%26w%3D1920%26q%3D75" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--LD3Msp99--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://chrisw.vercel.app/_next/image%3Furl%3D%252F_next%252Fstatic%252Fmedia%252Fuserpool01.22121787.png%26w%3D1920%26q%3D75" alt="Cognito User Pool" width="800" height="431"&gt;&lt;/a&gt;&lt;/p&gt;



&lt;ul&gt;
&lt;li&gt;Click on the Create user pool button.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--XAkiUi1P--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://chrisw.vercel.app/_next/image%3Furl%3D%252F_next%252Fstatic%252Fmedia%252Fuserpool02.b164683d.png%26w%3D1920%26q%3D75" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--XAkiUi1P--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://chrisw.vercel.app/_next/image%3Furl%3D%252F_next%252Fstatic%252Fmedia%252Fuserpool02.b164683d.png%26w%3D1920%26q%3D75" alt="Cognito User Pool" width="800" height="388"&gt;&lt;/a&gt;&lt;/p&gt;



&lt;ul&gt;
&lt;li&gt;Select Authentication Providers Type&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--O5CW-y2_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://chrisw.vercel.app/_next/image%3Furl%3D%252F_next%252Fstatic%252Fmedia%252Fuserpool03.9588da63.png%26w%3D1920%26q%3D75" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--O5CW-y2_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://chrisw.vercel.app/_next/image%3Furl%3D%252F_next%252Fstatic%252Fmedia%252Fuserpool03.9588da63.png%26w%3D1920%26q%3D75" alt="Cognito User Pool" width="800" height="376"&gt;&lt;/a&gt;&lt;/p&gt;



&lt;ul&gt;
&lt;li&gt;Select Password policy mode and Multi-factor authentication type&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--0QeogssL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://chrisw.vercel.app/_next/image%3Furl%3D%252F_next%252Fstatic%252Fmedia%252Fuserpool04.561f458c.png%26w%3D1920%26q%3D75" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--0QeogssL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://chrisw.vercel.app/_next/image%3Furl%3D%252F_next%252Fstatic%252Fmedia%252Fuserpool04.561f458c.png%26w%3D1920%26q%3D75" alt="Cognito User Pool" width="800" height="376"&gt;&lt;/a&gt;&lt;/p&gt;



&lt;ul&gt;
&lt;li&gt;Select MFA methods(Authenticator apps or SMS message)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--hPBTwSx5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://chrisw.vercel.app/_next/image%3Furl%3D%252F_next%252Fstatic%252Fmedia%252Fuserpool05.0ccb3013.png%26w%3D1920%26q%3D75" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--hPBTwSx5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://chrisw.vercel.app/_next/image%3Furl%3D%252F_next%252Fstatic%252Fmedia%252Fuserpool05.0ccb3013.png%26w%3D1920%26q%3D75" alt="Cognito User Pool" width="800" height="385"&gt;&lt;/a&gt;&lt;/p&gt;



&lt;ul&gt;
&lt;li&gt;Choose the attributes, and click next button.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--SYapEF62--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://chrisw.vercel.app/_next/image%3Furl%3D%252F_next%252Fstatic%252Fmedia%252Fuserpool06.1a49a4c5.png%26w%3D1920%26q%3D75" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--SYapEF62--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://chrisw.vercel.app/_next/image%3Furl%3D%252F_next%252Fstatic%252Fmedia%252Fuserpool06.1a49a4c5.png%26w%3D1920%26q%3D75" alt="Cognito User Pool" width="800" height="378"&gt;&lt;/a&gt;&lt;/p&gt;



&lt;ul&gt;
&lt;li&gt;Select Email provider, and click next button.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ZKlg2jdT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://chrisw.vercel.app/_next/image%3Furl%3D%252F_next%252Fstatic%252Fmedia%252Fuserpool07.6c26803a.png%26w%3D1920%26q%3D75" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ZKlg2jdT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://chrisw.vercel.app/_next/image%3Furl%3D%252F_next%252Fstatic%252Fmedia%252Fuserpool07.6c26803a.png%26w%3D1920%26q%3D75" alt="Cognito User Pool" width="800" height="375"&gt;&lt;/a&gt;&lt;/p&gt;



&lt;ul&gt;
&lt;li&gt;Enter User pool name.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--eWqGpprW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://chrisw.vercel.app/_next/image%3Furl%3D%252F_next%252Fstatic%252Fmedia%252Fuserpool08.20d8594e.png%26w%3D1920%26q%3D75" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--eWqGpprW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://chrisw.vercel.app/_next/image%3Furl%3D%252F_next%252Fstatic%252Fmedia%252Fuserpool08.20d8594e.png%26w%3D1920%26q%3D75" alt="Cognito User Pool" width="800" height="232"&gt;&lt;/a&gt;&lt;/p&gt;



&lt;ul&gt;
&lt;li&gt;Check Use the Cognito Hosted UI, enter a domain prefix.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ST87azCf--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://chrisw.vercel.app/_next/image%3Furl%3D%252F_next%252Fstatic%252Fmedia%252Fuserpool09.ba3dd2e6.png%26w%3D1920%26q%3D75" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ST87azCf--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://chrisw.vercel.app/_next/image%3Furl%3D%252F_next%252Fstatic%252Fmedia%252Fuserpool09.ba3dd2e6.png%26w%3D1920%26q%3D75" alt="Cognito User Pool" width="800" height="375"&gt;&lt;/a&gt;&lt;/p&gt;



&lt;ul&gt;
&lt;li&gt;Enter a friendly name for yhour app client, and enter a callback URLs.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--EDYuadRd--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://chrisw.vercel.app/_next/image%3Furl%3D%252F_next%252Fstatic%252Fmedia%252Fuserpool10.d6223557.png%26w%3D1920%26q%3D75" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--EDYuadRd--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://chrisw.vercel.app/_next/image%3Furl%3D%252F_next%252Fstatic%252Fmedia%252Fuserpool10.d6223557.png%26w%3D1920%26q%3D75" alt="Cognito User Pool" width="800" height="377"&gt;&lt;/a&gt;&lt;/p&gt;



&lt;ul&gt;
&lt;li&gt;You will see the user pool has been created as shown below in the screenshot.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Zwr28AZT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://chrisw.vercel.app/_next/image%3Furl%3D%252F_next%252Fstatic%252Fmedia%252Fuserpool11.d87dd648.png%26w%3D1920%26q%3D75" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Zwr28AZT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://chrisw.vercel.app/_next/image%3Furl%3D%252F_next%252Fstatic%252Fmedia%252Fuserpool11.d87dd648.png%26w%3D1920%26q%3D75" alt="Cognito User Pool" width="800" height="378"&gt;&lt;/a&gt;&lt;/p&gt;



&lt;ul&gt;
&lt;li&gt;Finally you can check the all of authentication work flow in the Cognito Hosted UI.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--t6yv56Lt--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://chrisw.vercel.app/_next/image%3Furl%3D%252F_next%252Fstatic%252Fmedia%252Fuserpool12.d140dde0.png%26w%3D1920%26q%3D75" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--t6yv56Lt--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://chrisw.vercel.app/_next/image%3Furl%3D%252F_next%252Fstatic%252Fmedia%252Fuserpool12.d140dde0.png%26w%3D1920%26q%3D75" alt="Cognito User Pool" width="800" height="406"&gt;&lt;/a&gt;&lt;/p&gt;



&lt;h3&gt;
  
  
  2. AWS Cognito Federated Identities
&lt;/h3&gt;

&lt;p&gt;Identity pools are the containers that Cognito Identity uses to keep your apps’ federated identities organized. Identity Pool associates federated identities from social identity providers with a unique user-specific identifier. Identity Pools do not store any user profiles. An identity pool can be associated with one or many apps. If you use two different identity pools for two apps then the same end user will have a different unique identifier in each Identity Pool.&lt;/p&gt;

&lt;h4&gt;
  
  
  Create Cognito Federated Identities
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Click a Create new identity pool button as shown in the below screenshot.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--J108j1wO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://chrisw.vercel.app/_next/image%3Furl%3D%252F_next%252Fstatic%252Fmedia%252Ffederated01.9a668383.png%26w%3D1920%26q%3D75" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--J108j1wO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://chrisw.vercel.app/_next/image%3Furl%3D%252F_next%252Fstatic%252Fmedia%252Ffederated01.9a668383.png%26w%3D1920%26q%3D75" alt="Cognito User Pool" width="800" height="354"&gt;&lt;/a&gt;&lt;/p&gt;



&lt;ul&gt;
&lt;li&gt;Enter the User Pool Id and App client id as shown in the below screenshot.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ZXUioGFh--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://chrisw.vercel.app/_next/image%3Furl%3D%252F_next%252Fstatic%252Fmedia%252Ffederated02.16b5e1c5.png%26w%3D1920%26q%3D75" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ZXUioGFh--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://chrisw.vercel.app/_next/image%3Furl%3D%252F_next%252Fstatic%252Fmedia%252Ffederated02.16b5e1c5.png%26w%3D1920%26q%3D75" alt="Cognito User Pool" width="800" height="375"&gt;&lt;/a&gt;&lt;/p&gt;



&lt;ul&gt;
&lt;li&gt;Enter the User Pool Id and App client id as shown in the below screenshot.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ZXUioGFh--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://chrisw.vercel.app/_next/image%3Furl%3D%252F_next%252Fstatic%252Fmedia%252Ffederated02.16b5e1c5.png%26w%3D1920%26q%3D75" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ZXUioGFh--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://chrisw.vercel.app/_next/image%3Furl%3D%252F_next%252Fstatic%252Fmedia%252Ffederated02.16b5e1c5.png%26w%3D1920%26q%3D75" alt="Cognito User Pool" width="800" height="375"&gt;&lt;/a&gt;&lt;/p&gt;



&lt;ul&gt;
&lt;li&gt;Then you can get the Identity pool Id as shown in the below screenshot&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--9NR2M4II--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://chrisw.vercel.app/_next/image%3Furl%3D%252F_next%252Fstatic%252Fmedia%252Ffederated03.bb471d04.png%26w%3D1920%26q%3D75" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--9NR2M4II--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://chrisw.vercel.app/_next/image%3Furl%3D%252F_next%252Fstatic%252Fmedia%252Ffederated03.bb471d04.png%26w%3D1920%26q%3D75" alt="Cognito User Pool" width="800" height="337"&gt;&lt;/a&gt;&lt;/p&gt;



&lt;p&gt;I just done with AWS Cognito User Pool, Cognito Federated Identities setup.&lt;br&gt;
In the &lt;a href="https://dev.to/itwebtiger/aws-cognito-sign-up-with-nodejs-4202"&gt;next post&lt;/a&gt;, we will discuss how you're going to integrate Cognito with a Node.js &amp;amp; Express.js app.&lt;/p&gt;

&lt;h4&gt;
  
  
  References
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://chrisw.vercel.app/projects/node/cognito/started"&gt;https://chrisw.vercel.app/projects/node/cognito/started&lt;/a&gt;&lt;/p&gt;

</description>
      <category>aws</category>
      <category>cognito</category>
      <category>node</category>
      <category>express</category>
    </item>
    <item>
      <title>Express &amp; ES6 Boilerplate</title>
      <dc:creator>Chris Wang</dc:creator>
      <pubDate>Tue, 06 Jun 2023 20:02:50 +0000</pubDate>
      <link>https://dev.to/itwebtiger/express-es6-boilerplate-2pd5</link>
      <guid>https://dev.to/itwebtiger/express-es6-boilerplate-2pd5</guid>
      <description>&lt;p&gt;Let's set up an Express.js app using ES6. I will be using the Babel compiler to compile our ES6 code to ES5. Babel is a JavaScript compiler that enables one use next generation JavaScript, today. This Tutorial assumes that you have installed the Node Package Manager(NPM) and the Node.js Engine in your development environment. If you do not have Node.js installed, you can download and install it from the &lt;a href="https://nodejs.org/en"&gt;Node.js website&lt;/a&gt;. Also, you can download the full codebase &lt;a href="https://github.com/itwebtiger/express-amazon-cognito/tree/init-expressjs"&gt;here&lt;/a&gt; if you are interested in this es6 node-express boilerplate.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 1: Set up the project
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Create a new directory for your project and navigate to it.&lt;/li&gt;
&lt;li&gt;Initialize a new Node.js project by running the following command in your terminal:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm init &lt;span class="nt"&gt;-y&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 2: Install dependencies
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Install Express and other required packages by running the following command:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;install &lt;/span&gt;express
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 3: Configure Babel
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Install Babel and the necessary plugins by running the following command:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;--save-dev&lt;/span&gt; @babel/core @babel/preset-env @babel/register
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Create a file named .babelrc in the root directory of your project and add the following content:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
{
  "presets": ["@babel/preset-env"]
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 4: Create the Express app
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Create a file named app.js in the root directory of your project.&lt;/li&gt;
&lt;li&gt;Add the following code to app.js to set up a basic Express application:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import express from 'express';

const app = express();

// Define routes and middleware here

const port = process.env.PORT || 3000;
app.listen(port, () =&amp;gt; {
  console.log(`Server listening on port ${port}`);
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In your terminal, run the following command to start the server:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;node &lt;span class="nt"&gt;-r&lt;/span&gt; @babel/register app.js
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 5: Install nodemon
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Install nodemon as a development dependency by running the following command in your project's root directory:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;--save-dev&lt;/span&gt; nodemon
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Open your project's package.json file and modify the "scripts" section to include a new script called "start" with the command to run the server using nodemon(&lt;code&gt;"start": "nodemon --exec babel-node app.js"&lt;/code&gt;). Your package.json file should look like &lt;a href="https://github.com/itwebtiger/express-amazon-cognito/blob/init-expressjs/package.json"&gt;this&lt;/a&gt;:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  "name": "express-amazon-cognito",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" &amp;amp;&amp;amp; exit 1",
    "start": "nodemon --exec babel-node app.js",
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "express": "^4.18.2"
  },
  "devDependencies": {
    "@babel/core": "^7.22.1",
    "@babel/node": "^7.22.1",
    "@babel/preset-env": "^7.22.4",
    "@babel/register": "^7.21.0",
    "nodemon": "^2.0.22"
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Save the changes to package.json.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Open your terminal and navigate to your project's root directory.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Start the server using the following command:&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm start or yarn start
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, nodemon will automatically monitor your files for changes and restart the server whenever you save changes to your code.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 6: Set up Prettier and ESLint
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Install the necessary packages as dev dependencies:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;--save-dev&lt;/span&gt; prettier eslint eslint-config-prettier eslint-plugin-prettier
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Create an ESLint configuration file by running the following command and following the prompts:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx eslint &lt;span class="nt"&gt;--init&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This command will guide you through setting up ESLint. Make the following selections when prompted:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;- How would you like to configure ESLint? -&amp;gt; Use a popular style guide
- Which style guide do you want to follow? -&amp;gt; Airbnb
- Do you use TypeScript? -&amp;gt; No
- Where will your code run? -&amp;gt; Node
- How would you like to define a style for your project? -&amp;gt; Use a configuration file
- Which format do you want your config file to be in? -&amp;gt; JavaScript
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;ol&gt;
&lt;li&gt;Install the necessary Babel ESLint plugin:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;--save-dev&lt;/span&gt; babel-eslint
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Open the .eslintrc.js file that was created in your project's root directory.
Modify the configuration file to extend the plugin:prettier/recommended configuration and set the parser option to babel-eslint. It should look something like this(&lt;a href="https://github.com/itwebtiger/express-amazon-cognito/blob/init-expressjs/.eslintrc.js"&gt;source file&lt;/a&gt;):
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;module.exports = {
  env: {
    browser: true,
    es2021: true,
  },
  extends: ['airbnb-base', 'plugin:prettier/recommended'],
  parserOptions: {
    ecmaVersion: 'latest',
    sourceType: 'module',
  },
  rules: {
    'prettier/prettier': 'error',
  },
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Create a &lt;a href="https://github.com/itwebtiger/express-amazon-cognito/blob/init-expressjs/.prettierrc"&gt;.prettierrc file&lt;/a&gt; in your project's root directory and specify your desired Prettier formatting rules.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  "singleQuote": true,
  "trailingComma": "es5"
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Add a Prettier script to your package.json file's "scripts" section:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"scripts": {
  "prettier": "prettier --write '**/*.{js,json}'"
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now you can run ESLint and Prettier on your project. For example, to run ESLint on your entire project, use the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx eslint &lt;span class="nb"&gt;.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To format your code with Prettier, run the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm run prettier
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Feel free to adjust the ESLint and Prettier configurations to meet your specific project requirements.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 7: Set up env
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Install the dotenv package, which allows you to load environment variables from a .env file:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;install &lt;/span&gt;dotenv
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Create a .env file in your project's root directory. Add the following line to the .env file, specifying the desired port number:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;PORT&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;3000
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;In your main entry file (e.g., app.js or index.js), import the dotenv package using ES6 syntax at the top of the file:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;import dotenv from &lt;span class="s1"&gt;'dotenv'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Load the environment variables from the .env file by invoking the config method on the dotenv object:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;dotenv.config&lt;span class="o"&gt;()&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Update the code where you define the port for your Express.js server. Use destructuring to extract the PORT variable from process.env:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;const port &lt;span class="o"&gt;=&lt;/span&gt; process.env.PORT &lt;span class="o"&gt;||&lt;/span&gt; 3000&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example, the PORT variable will hold the value from the .env file. If it is not set, the port variable will default to 3000.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Start your Express.js server using the port variable:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;app.listen&lt;span class="o"&gt;(&lt;/span&gt;port, &lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
  console.log&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="sb"&gt;`&lt;/span&gt;Server is running on port &lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;port&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;&lt;span class="sb"&gt;`&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="o"&gt;})&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now your Express.js server will read the port number from the .env file using ES6 syntax.&lt;/p&gt;

&lt;p&gt;You can adjust the code and syntax to match your specific project structure and requirements.&lt;br&gt;
You can download the full codebase &lt;a href="https://github.com/itwebtiger/express-amazon-cognito/tree/init-expressjs"&gt;here&lt;/a&gt; for this article.&lt;/p&gt;

&lt;p&gt;If you like this type of content you can give me a star on my &lt;a href="https://github.com/itwebtiger/express-amazon-cognito/tree/init-expressjs"&gt;GitHub repository&lt;/a&gt; for the latest updates.&lt;/p&gt;

&lt;h4&gt;
  
  
  References:
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://chrisw.vercel.app/projects/node/express/getstarted"&gt;https://chrisw.vercel.app/projects/node/express/getstarted&lt;/a&gt;&lt;br&gt;
&lt;a href="https://github.com/itwebtiger/express-amazon-cognito/tree/init-expressjs"&gt;https://github.com/itwebtiger/express-amazon-cognito/tree/init-expressjs&lt;/a&gt;&lt;/p&gt;

</description>
      <category>node</category>
      <category>express</category>
      <category>es6</category>
      <category>babel</category>
    </item>
  </channel>
</rss>
