Build a Twitter Clone With Adonis and Vue

Database Setup

The Tweetr app will use MySQL for storage. So, we need to install Node.js driver for MySQL:

npm install mysql --save

With that installed, let's set up the app to use MySQL. Taking a look at config/database.js, you see config settings for different databases including MySQL. Though you can easily enter the MySQL settings directly in the config file, that will mean you’ll have to change these settings every time you change the application environment (development, staging, production etc.) which is actually a bad practice. Instead, we’ll make use of environment variables and depending on the environment the application is running on, it will pull the settings for that environment. We can easily do that with AdonisJS. All we have to do is enter the appropriate config settings in the .env file.

Open .env and update the DB details as below:

// .env


Replace DB_USER, and DB_PASSWORD accordingly with your own database settings. Then create a MySQL database with the name tweetr.

Like this article? Follow @ammezie on Twitter