Look at the following picture for more details: Then create the file " Database.js" in the folder " config", create the file " Users.js" and " RefreshToken.js" in the folder " controllers", create the file " VerifyToken.js" in the folder " middleware", create " UserModel.js" file in the " models" folder, create the " index.js" file in the " routes" folder, and create the " index.js" file in the " backend" folder. To make the application more structured neatly, we will apply the MVC pattern (Model-View-Controllers).Ĭreate “ config”, “ controllers”, “ middleware”, “ models”, and “ routes” folders in the “ backend” folder. The SQL command above will create a database with the name " auth_db". To create a database in MySQL, it can be done by executing the following query: If you create a database with the same name, that's even better. ![]() Here I create a database with the name " auth_db". Then create a new database in MySQL, you can use tools such as SQLyog, PHPMyAdmin or similar tools. To be able to use MySQL, you need to install XAMPP, WAMP, MAMP, or similar software. This is so that we can use ES6 Module Syntax to export and import modules. "test": "echo "Error: no test specified" & exit 1" So that the “package.json” file looks like the following: Next, add the following code to the “package.json” file: Next, install nodemon globally by typing the following command in the terminal: Npm install express mysql2 sequelize jsonwebtoken bcrypt cookie-parser dotenv cors Next, install express, mysql2, sequelize, jsonwebtoken, bcrypt, cookie-parser, dotenv and cors by typing the following command in the terminal: Next, open a terminal in Visual Studio Code on the menu bar terminal => new terminal.Īfter that, type the following command in the terminal to create a “package.json” file: You can download Visual Studio Code at the following link, then install it on your computer:Īfter the " jwt-auth" folder is opened using Visual Studio Code, create a sub folder named " backend" in the " jwt-auth" folder. I also suggest you to use Visual Studio Code. Then open the " jwt-auth" folder using the code editor, here I use Visual Studio Code. You are free to make it anywhere, either in C, D, or on the Desktop. Install DependencyĬreate a folder on your computer, here I name it " jwt-auth". I will also share with you how to create refresh token and save refresh token into httpOnly cookie so that our application will be safe from XSS (Cross-site Scripting) and CSRF (Cross-site Request Forgery) attacks. Open your MySQL management utility (for example MySQL Workbench), select the database that you specified during the setup in step 3, and execute the "northwind.sql" dump file into it.In this tutorial you will learn how to create login and registration using JWT (JSON Web Token) with node js, express, mysql on backend and react js on frontend. You should see setup instructions in your browser and you should follow the steps mentioned. In your web browser, go to (change "demo_folder" to the name of the folder you extracted the files into in step 1) If you don't know where is your document root, please refer to If you don't have the above software installed, we recommend installing Xampp latest version from and MySQL Workbench latest version from Įxtract the contents of the zip file into a folder inside your document root. ![]() ![]() Before installing the demo, you should have the following software on your local PC: webserver with PHP 4.3 or higher, MySQL 3.2.25 or higher, a MySQL management utility This demo can be installed on Windows, Linux and MacOS. How to install the Northwind demo to your local PC? ![]() A sample AppGini app for development and testing purposes.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |