Skip to content

lyudad/capslol_backend

Repository files navigation

NestJS

Installation

$ npm install

Running the app

# development
$ npm run start

# watch mode
$ npm run start:dev

# production mode
$ npm run start:prod

Test

# unit tests
$ npm run test

# e2e tests
$ npm run test:e2e

# test coverage
$ npm run test:cov

Database

I used MySQL v8.0 If you haven`t installed database in your machine, you can use docker container.

docker run --name mysqldb \
           --volume "$(pwd)/data:/var/lib/mysql" \
           --env MYSQL_ROOT_PASSWORD=secret \
           --publish 3306:3306 \
           --detach \
           --restart unless-stopped \
           mysql:8.0

Creating a New User

Enter into container

  1. docker exec -it mysqldb bash

Enter into MySQL

  1. root@16d0d1803a49:/# mysql -u root -psecret

Create new User with Password

  1. CREATE USER 'admin' IDENTIFIED BY 'root';

Check new User

  1. SELECT user FROM mysql.user;

Granting a User Permissions

  1. GRANT ALL PRIVILEGES ON * . * TO 'admin'; FLUSH PRIVILEGES; You can review a user’s current permissions by running the SHOW GRANTS command: SHOW GRANTS FOR 'admin';
  2. After creating your MySQL user and granting them privileges, you can exit the MySQL client:
mysql> exit
  1. to log in as your new MySQL user, you’d use a command like the following:
root@16d0d1803a49:/# mysql -u admin -p

Create new database

  1. CREATE DATABASE IF NOT EXISTS freelancer_db; show databases;

Update .env file

DATABASE_USERNAME=admin DATABASE_PASSWORD=root DATABASE_NAME=freelancer_db

Migration

After setup database and NestJS connected to database, you would run migration. npm run migration:run npm run start:dev

Documentaion

URL: http://localhost:3000/docs/

REST API

Get All users

Method: GET Endpoint :/auth/allUsers

Create user

Method: POST Endpoint :/auth/createUser Body:

{
  "user": {
    "username": "",
    "email": "",
    "password": ""
  }
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published