yemiwebby / nest-planetscale

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Build a user management API with Nest.js and MySQL

Description

Learn how to connect Nest.js to PlanetScale MySQL database. The complete tutorial can be found here

Download the application

Clone this repository with:

git clone https://github.com/yemiwebby/nest-planetscale.git

Install dependencies

npm install

Connecting with PlanetScale Database

Set up a free account on PlanetScale and create a new database. Obtain the username and password for your database branch. Follow the steps in this section of the tutorial.

Environment variable

Create a .env file and populate using this command:

cp .env.example .env

Be sure to replace the following placeholders:

DATABASE_USER=USERNAME
DATABASE_PASSWORD=PASSWORD
DATABASE_NAME=DATABASE_NAME
DATABASE_HOST=DATABASE_HOST

Running the app

Run the application with:

npm run start:dev

The API will start running default port http://localhost:3000

The endpoints are:

POST      '/user/create'
GET       '/user/all'
GET       '/user/:userId'
PATCH     '/user/edit/:userId'
DELETE    '/user/delete/:userId'

About


Languages

Language:TypeScript 89.7%Language:JavaScript 8.9%Language:Shell 1.4%