$ npm install
# development
$ npm run start
# watch mode
$ npm run start:dev
# production mode
$ npm run start:prod
# unit tests
$ npm run test
# e2e tests
$ npm run test:e2e
# test coverage
$ npm run test:cov
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
docker exec -it mysqldb bash
root@16d0d1803a49:/# mysql -u root -psecret
CREATE USER 'admin' IDENTIFIED BY 'root';
SELECT user FROM mysql.user;
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';
- After creating your MySQL user and granting them privileges, you can exit the MySQL client:
mysql> exit
- to log in as your new MySQL user, you’d use a command like the following:
root@16d0d1803a49:/# mysql -u admin -p
CREATE DATABASE IF NOT EXISTS freelancer_db;
show databases;
DATABASE_USERNAME=admin
DATABASE_PASSWORD=root
DATABASE_NAME=freelancer_db
After setup database and NestJS connected to database, you would run migration.
npm run migration:run
npm run start:dev
URL: http://localhost:3000/docs/
Method: GET
Endpoint :/auth/allUsers
Method: POST
Endpoint :/auth/createUser
Body:
{
"user": {
"username": "",
"email": "",
"password": ""
}
}