DEV Community

Miracle Anyanwu
Miracle Anyanwu

Posted on

Building a file sharing app with Node.js, Vue.js, Cloudinary, and MySQL - Part 3

In this part, we will create our database and write some of the API that will power our application. Now, let's get started!

Requirements

  1. To follow along with this series, you need the following parts: Part 1, Part 2

  2. You will also need to create an account on Cloudinary

Building our app

In our connection.js file, populate it with the following code:

connection.js

The code above handles our database connection parameters.

Next, we create our application entry file index.js and our environment variable file .env in our application project root directory. We then populate our index.js with the following code:

db connection params

In our entry index.js file, we imported the express, cors, dotenv, and the cloudinary packages. We also defined our cloudinary configuration parameters (which we will insert later in our .env variable file). Also, we defined our 404 and 500 HTTP response fallback routes, and then, we started our local server on port 3000.

In our .env file, populate the following with your database configuration information and your cloudinary secrete that can be found on your cloudinary dashboard.

alt text

Replace all the value positions with your correct database and cloudinary configuration information.

Creating our database

Our MySQL database schema will look like this. If you do not have a suitable MySQL database workbench, you can download MAMP

database structure

Conclusion

In this part of the series, we have created our database, populated our index.js and added our database and cloudinary configuration information.

In the next part, we will be implementing the core API that will power our application.

The source code is also available on GitHub

See you in the next part!

Top comments (0)