How to Connect ExpressJS with MySQL professional

Ernesto Jara Olveda
1 min readFeb 24, 2020

--

nodejs

Today I’ll show you the way I kind of connect to a mysql database and typescript. First let’s create the project and install dependencies:

$  mkdir my-sql && cd my-sql && npm init -y && npm i express cors body-parser mysql && npm i -D @types/node @types/express @types/body-parser @types/cors @types/mysql typescript tslib nodemon && mkdir ./src && mkdir ./src/{controllers,config} && touch ./src/controllers/controller.ts ./src/controllers/base-controller.ts ./src/index.ts ./nodemon.json ./src/config/mysql.ts && ./node_modules/typescript/bin/tsc --init

Let’s first open

./src/config/mysql.ts

Now Open

./src/controllers/base-controller.ts

Last Open a son controller

./src/controllers/base-controller.ts

From here the sky is the limit. If you want to see the whole project or part of it you is always welcome.

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

No responses yet

Write a response