Skip to content

Commit

Permalink
feat: finish app
Browse files Browse the repository at this point in the history
  • Loading branch information
GabriellCastro committed Mar 9, 2024
0 parents commit 7fcaa6d
Show file tree
Hide file tree
Showing 84 changed files with 10,166 additions and 0 deletions.
20 changes: 20 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# DB Config
DATABASE_URL="postgresql://postgres:123456@localhost:5432/gestao_db?schema=public"

# JWT Config
JWT_SECRET="secret"

# Port Config
PORT=3001

# Mailer Config
MAIL_HOST="smtp.example.com"
MAIL_USER="user@example.com"
MAIL_PASSWORD="topsecret"
MAIL_FROM="noreply@example.com"

#Email Redirect
EMAIL_CONFIRMATION_URL_REDIRECT="http://localhost:3000/emailVerify"

#Password Recovery Redirect
EMAIL_PASSWORD_RECOVERY_URL_REDIRECT="http://localhost:3000/passwordRecovery"
33 changes: 33 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
module.exports = {
parser: '@typescript-eslint/parser',
parserOptions: {
project: 'tsconfig.json',
tsconfigRootDir: __dirname,
sourceType: 'module',
},
plugins: ['@typescript-eslint/eslint-plugin', 'eslint-plugin-import-helpers'],
extends: [
'plugin:@typescript-eslint/recommended',
'plugin:prettier/recommended',
],
root: true,
env: {
node: true,
jest: true,
},
ignorePatterns: ['.eslintrc.js'],
rules: {
'@typescript-eslint/interface-name-prefix': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'import-helpers/order-imports': [
'warn',
{
newlinesBetween: 'always',
groups: ['module', '/^@shared/', ['parent', 'sibling', 'index']],
alphabetize: { order: 'asc', ignoreCase: true },
},
],
},
};
41 changes: 41 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# compiled output
/dist
/node_modules

# Logs
logs
*.log
npm-debug.log*
pnpm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*

# OS
.DS_Store

# Tests
/coverage
/.nyc_output

# IDEs and editors
/.idea
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace

# IDE - VSCode
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json

# environment
.env

#docker-db
pg-db
4 changes: 4 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"singleQuote": true,
"trailingComma": "all"
}
58 changes: 58 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Gestão (Backoffice)
The Gestão app has been designed to streamline the back office team's work within the company, enabling efficient registration of new clients and users on the main platform, regardless of its nature. The system provides comprehensive functionalities, allowing for the updating, deletion, and addition of records, offering complete and effective management of registered users.

## :white_check_mark: Requirements ##

- [Node](https://nodejs.org/en/)
- [Yarn](https://yarnpkg.com/lang/en/)
- [Docker](https://docs.docker.com/compose/)

## 💻 How to run the application

```bash
# Run the git clone command to clone the repository
$ git clone git@github.com:GabriellCastro/Backoffice_backend.git

# Enter the cloned repository folder
$ cd Backoffice_backend

# Run yarn to install dependencies
$ yarn

# At the root of the project (Backoffice_backend)
# Change the name from .env.example to .env

# Run docker in the root of the project (Backoffice_backend)
$ sudo docker compose up -d

# Run prism migrate on the root of the project (Backoffice_backend)
$ yarn prisma migrate dev

# run the seed and generate an ADM accoun (see the log in the terminal)
$ yarn seed

# To start the application
$ yarn dev

```

Okay, now you can access the application from the route: <a href="https://localhost:3001/docs">https://localhost:3001/docs</a>

## :rocket: Technologies ##

The following technologies were used in the project:

- [NestJs](https://docs.nestjs.com/)
- [JWT](https://jwt.io)
- [Postgres](https://www.postgresql.org/)
- [PrismaORM](https://www.prisma.io/)
- [Swagger](https://swagger.io)


## Autor

Made by Gabriel Castro 👋🏽 Get in touch!

[![Linkedin Badge](https://img.shields.io/badge/-Gabriel-blue?style=flat-square&logo=Linkedin&logoColor=white&link=https://www.linkedin.com/in/eugabrielcastro/)](https://www.linkedin.com/in/eugabrielcastro/)
[![Gmail Badge](https://img.shields.io/badge/-contatodevgabriel@gmail.com-red?style=flat-square&link=mailto:contatodevgabriel@gmail.com)](mailto:contatodevgabriel@gmail.com)

15 changes: 15 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
version: '3.8'
services:
db:
image: 'postgres:latest'
environment:
POSTGRES_PASSWORD: 123456
POSTGRES_USER: postgres
POSTGRES_DB: infinity_db
volumes:
- pg-db:/var/lib/postgresql/data
ports:
- '5432:5432'

volumes:
pg-db:
8 changes: 8 additions & 0 deletions nest-cli.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"$schema": "https://json.schemastore.org/nest-cli",
"collection": "@nestjs/schematics",
"sourceRoot": "src",
"compilerOptions": {
"deleteOutDir": true
}
}
93 changes: 93 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
{
"name": "gestao_backend",
"version": "0.0.1",
"description": "",
"author": "",
"private": true,
"license": "UNLICENSED",
"type": "commonjs",
"scripts": {
"seed": "ts-node src/services/seed.ts",
"build": "nest build && prisma migrate deploy",
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
"start": "nest start",
"dev": "nest start --watch --debug --runInBand",
"start:debug": "nest start --debug --watch",
"start:prod": "node dist/main",
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
"test": "jest",
"test:watch": "jest --watch",
"test:cov": "jest --coverage",
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
"test:e2e": "jest --config ./test/jest-e2e.json"
},
"dependencies": {
"@nestjs-modules/mailer": "^1.9.1",
"@nestjs/common": "^10.0.0",
"@nestjs/config": "^3.1.1",
"@nestjs/core": "^10.0.0",
"@nestjs/platform-express": "^10.0.0",
"@nestjs/swagger": "^7.1.16",
"@prisma/client": "^5.6.0",
"@types/graphlib": "^2.1.12",
"bcrypt": "^5.1.1",
"class-transformer": "^0.5.1",
"class-validator": "^0.14.0",
"cpf-cnpj-validator": "^1.0.3",
"google-distance-matrix": "^1.1.1",
"graphlib": "^2.1.8",
"handlebars": "^4.7.8",
"jsonwebtoken": "^9.0.2",
"nodemailer": "^6.9.7",
"prisma": "^5.6.0",
"reflect-metadata": "^0.1.13",
"rxjs": "^7.8.1"
},
"devDependencies": {
"@nestjs/cli": "^10.0.0",
"@nestjs/schematics": "^10.0.0",
"@nestjs/testing": "^10.0.0",
"@types/bcrypt": "^5.0.2",
"@types/express": "^4.17.17",
"@types/jest": "^29.5.2",
"@types/jsonwebtoken": "^9.0.5",
"@types/node": "^20.3.1",
"@types/nodemailer": "^6.4.14",
"@types/supertest": "^2.0.12",
"@typescript-eslint/eslint-plugin": "^6.0.0",
"@typescript-eslint/parser": "^6.0.0",
"eslint": "^8.42.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-import-helpers": "^1.3.1",
"eslint-plugin-prettier": "^5.0.0",
"jest": "^29.5.0",
"prettier": "^3.0.0",
"source-map-support": "^0.5.21",
"supertest": "^6.3.3",
"ts-jest": "^29.1.0",
"ts-loader": "^9.4.3",
"ts-node": "^10.9.1",
"tsconfig-paths": "^4.2.0",
"typescript": "^5.1.3"
},
"jest": {
"moduleFileExtensions": [
"js",
"json",
"ts"
],
"rootDir": "src",
"testRegex": ".*\\.spec\\.ts$",
"transform": {
"^.+\\.(t|j)s$": "ts-jest"
},
"collectCoverageFrom": [
"**/*.(t|j)s"
],
"coverageDirectory": "../coverage",
"testEnvironment": "node"
},
"resolutions": {
"string-width": "^4.2.0"
}
}
60 changes: 60 additions & 0 deletions prisma/migrations/20240124203946_schema_init/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
-- CreateEnum
CREATE TYPE "Role" AS ENUM ('ADMINISTRATOR', 'MANAGER', 'OPERATOR', 'CLIENT');

-- CreateEnum
CREATE TYPE "OperatorProfile" AS ENUM ('OP_RETRO', 'OP_EXCAVATOR', 'OP_ROLO', 'OP_MOTORLEVELER', 'DUMP_TRUCK_DRIVER', 'LARGE_DUMP_TRUCK_DRIVER', 'PLATFORM_TRUCK_DRIVER');

-- CreateEnum
CREATE TYPE "LocationTypes" AS ENUM ('LINDEIRO', 'HOTEL', 'GUESTHOUSE', 'CRUSHING', 'QUARRY', 'MUNICIPAL_DEPOSIT', 'HORTO_DEPOSIT');

-- CreateTable
CREATE TABLE "User" (
"id" TEXT NOT NULL,
"name" TEXT NOT NULL,
"cpf" TEXT NOT NULL,
"email" TEXT NOT NULL,
"password" TEXT NOT NULL,
"whatsApp" TEXT NOT NULL,
"role" "Role" NOT NULL DEFAULT 'OPERATOR',
"profile" "OperatorProfile",
"activated" BOOLEAN NOT NULL DEFAULT false,
"emailVerify" TEXT,
"passwordReset" TEXT,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL,

CONSTRAINT "User_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "Address" (
"id" TEXT NOT NULL,
"userId" TEXT,
"cep" TEXT NOT NULL,
"address" TEXT NOT NULL,
"complement" TEXT,
"street" TEXT NOT NULL,
"number" TEXT NOT NULL,
"city" TEXT NOT NULL,
"state" TEXT NOT NULL,

CONSTRAINT "Address_pkey" PRIMARY KEY ("id")
);

-- CreateIndex
CREATE UNIQUE INDEX "User_cpf_key" ON "User"("cpf");

-- CreateIndex
CREATE UNIQUE INDEX "User_email_key" ON "User"("email");

-- CreateIndex
CREATE UNIQUE INDEX "User_emailVerify_key" ON "User"("emailVerify");

-- CreateIndex
CREATE UNIQUE INDEX "Address_id_key" ON "Address"("id");

-- CreateIndex
CREATE UNIQUE INDEX "Address_userId_key" ON "Address"("userId");

-- AddForeignKey
ALTER TABLE "Address" ADD CONSTRAINT "Address_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE;
18 changes: 18 additions & 0 deletions prisma/migrations/20240125175651_schema_coordinates/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
-- CreateTable
CREATE TABLE "Coordinates" (
"id" TEXT NOT NULL,
"userId" TEXT,
"latitude" DOUBLE PRECISION NOT NULL,
"longitude" DOUBLE PRECISION NOT NULL,

CONSTRAINT "Coordinates_pkey" PRIMARY KEY ("id")
);

-- CreateIndex
CREATE UNIQUE INDEX "Coordinates_id_key" ON "Coordinates"("id");

-- CreateIndex
CREATE UNIQUE INDEX "Coordinates_userId_key" ON "Coordinates"("userId");

-- AddForeignKey
ALTER TABLE "Coordinates" ADD CONSTRAINT "Coordinates_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE;
3 changes: 3 additions & 0 deletions prisma/migrations/migration_lock.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Please do not edit this file manually
# It should be added in your version-control system (i.e. Git)
provider = "postgresql"
Loading

0 comments on commit 7fcaa6d

Please sign in to comment.