Giter Site home page Giter Site logo

vagnermengali / user-crud Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 125 KB

Este é um CRUD de usuário destinado a facilitar o acesso com funcionalidades básicas de usuário e login.

License: Other

JavaScript 4.29% TypeScript 95.71%
bcryptjs dotenv jsonwebtoken nestjs prisma swagger typescript javascript

user-crud's Introduction

User Crud


Documentação em português

Este é um crud de usuário que visa facilitar o acesso com funcionalidades básicas de um usuário e login.

Instalação       Endpoints       Swagger      

Instalação

A seguir esta o passo-a-passo de instalação e execução em ambiente de desenvolvimento

A url base da api é http://localhost:3000

1. Clone o repositório:

git clone https://github.com/vagnermengali/user-crud

2. Adentre na pasta raiz do projeto:

cd user-crud

3. Instale as dependências do projeto:

yarn ou yarn install

4. Crie seu schema:

yarn prisma generate

7. Aplique suas migrações:

yarn prisma migrate dev

8. Ative o server:

yarn start:dev

Voltar ao início


Endpoints Pt-BR

A API esta divida em /users sendo um CRUD e /login para geraão do token e melhor interação com a api.

Usuário

Nessa rotas o usuário pode acessar sem o token apenas POST/users, as demais usará o token para executar o CRUD de usuário :

GET /users - FORMATO DA REQUISIÇÃO

Não é necessário um corpo da requisição.

GET /users - FORMATO DA RESPOSTA - STATUS 200

[
  {
    "username": "UserCrud UserCrud",
    "email": "[email protected]",
    "created_at": "2023-02-13T14:30:59.868Z",
    "updated_at": "2023-02-13T14:30:59.868Z"
  },
  {
    "username": "CrudUser CrudUser",
    "email": "[email protected]",
    "created_at": "2023-02-13T13:08:00.947Z",
    "updated_at": "2023-02-13T14:33:49.762Z"
  }
]

GET /users/profile - FORMATO DA REQUISIÇÃO

Não é necessário um corpo da requisição.

GET /users/profile - FORMATO DA RESPOSTA - STATUS 201

{
  "id": "fb6f2944-3ddc-4cef-a217-c0de75a1ee04",
  "username": "CrudUser CrudUser",
  "email": "[email protected]",
  "created_at": "2023-02-13T13:08:00.947Z",
  "updated_at": "2023-02-13T14:31:49.390Z"
}

POST /users - FORMATO DA REQUISIÇÃO

{
  "first_name": "UserCrud",
  "last_name": "UserCrud",
  "email": "[email protected]",
  "password": ".Crud123"
}

POST /users- FORMATO DA RESPOSTA - STATUS 201

{
  "id": "6556e127-0518-4407-bd3e-65f5cdf1e869",
  "username": "UserCrud UserCrud",
  "email": "[email protected]",
  "password": "$2a$10$IrAEhGwMky/3ntH.aJA3ZuKgJnbpziUzcXTqlqyV33NGWJQH/EhEe",
  "created_at": "2023-02-13T14:30:59.868Z"
}

PATCH /users/update - FORMATO DA REQUISIÇÃO

Todos os campos são opcionais

{
  "first_name": "CrudUser",
  "last_name": "CrudUser",
  "email": "[email protected]",
  "password": ".User123"
}

PATCH /users/update/ - FORMATO DA RESPOSTA - STATUS 200

{
  "id": "fb6f2944-3ddc-4cef-a217-c0de75a1ee04",
  "username": "CrudUser CrudUser",
  "email": "[email protected]",
  "created_at": "2023-02-13T13:08:00.947Z",
  "updated_at": "2023-02-13T14:31:49.390Z"
}

DELETE /users/delete/ - FORMATO DA REQUISIÇÃO

Não é necessário um corpo da requisição.

DELETE /users/delete/ - FORMATO DA RESPOSTA - STATUS 204

Não a corpo de retorno.

Login

Nessa rota o usuário pode acessar sem o token para efetuar o login :

POST /login - FORMATO DA REQUISIÇÃO

{
  "email": "[email protected]",
  "password": ".Crud123"
}

POST /login - FORMATO DA RESPOSTA - STATUS 201

{
  "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJlbWFpbCI6InVzZXJAZ21haWwuY29tIiwiaWF0IjoxNjc2Mjk4NjQ2LCJleHAiOjE2NzYzODUwNDYsInN1YiI6IjdmY2M3MzY4LWZhZWEtNGIzZi1hYjhiLWRlODZjNTQ3ZTA5NyJ9.5IVEZ9popPzx3a7T0vPDI2ZlnnNISxBtPJREd7Zi2HE"
}

Voltar ao início


Swagger Pt-BR

Api também conta a rota de interação, manipulação e documentação mais detalhada.

api/

Voltar ao início


Documentation in English

This is a user CRUD aiming to facilitate access with basic user and login functionalities.

Installation       Endpoints       Swagger      

Installation

Below is the step-by-step installation and execution guide in a development environment.

The base URL of the API is http://localhost:3000

1. Clone the repository:

git clone https://github.com/vagnermengali/user-crud

2. Navigate to the project root directory:

cd user-crud

3. Install project dependencies:

yarn ou yarn install

4. Create your schema:

yarn prisma generate

7. Apply your migrations:

yarn prisma migrate dev

8. Start the server:

yarn start:dev

Back to Top


Endpoints

The API is divided into /users, which is a CRUD, and /login for token generation and better interaction with the API.

User

In these routes, the user can access without the token only POST/users, the others will use the token to execute the user CRUD :

GET /users - REQUEST FORMAT

No request body is required.

GET /users - RESPONSE FORMAT - STATUS 200

[
  {
    "username": "UserCrud UserCrud",
    "email": "[email protected]",
    "created_at": "2023-02-13T14:30:59.868Z",
    "updated_at": "2023-02-13T14:30:59.868Z"
  },
  {
    "username": "CrudUser CrudUser",
    "email": "[email protected]",
    "created_at": "2023-02-13T13:08:00.947Z",
    "updated_at": "2023-02-13T14:33:49.762Z"
  }
]

GET /users/profile - REQUEST FORMAT

No request body is required.

GET /users/profile - RESPONSE FORMAT - STATUS 201

{
  "id": "fb6f2944-3ddc-4cef-a217-c0de75a1ee04",
  "username": "CrudUser CrudUser",
  "email": "[email protected]",
  "created_at": "2023-02-13T13:08:00.947Z",
  "updated_at": "2023-02-13T14:31:49.390Z"
}

POST /users - REQUEST FORMAT

{
  "first_name": "UserCrud",
  "last_name": "UserCrud",
  "email": "[email protected]",
  "password": ".Crud123"
}

POST /users - RESPONSE FORMAT - STATUS 201

{
  "id": "6556e127-0518-4407-bd3e-65f5cdf1e869",
  "username": "UserCrud UserCrud",
  "email": "[email protected]",
  "password": "$2a$10$IrAEhGwMky/3ntH.aJA3ZuKgJnbpziUzcXTqlqyV33NGWJQH/EhEe",
  "created_at": "2023-02-13T14:30:59.868Z"
}

PATCH /users/update - REQUEST FORMAT

All fields are optional

{
  "first_name": "CrudUser",
  "last_name": "CrudUser",
  "email": "[email protected]",
  "password": ".User123"
}

PATCH /users/update/ - RESPONSE FORMAT - STATUS 200

{
  "id": "fb6f2944-3ddc-4cef-a217-c0de75a1ee04",
  "username": "CrudUser CrudUser",
  "email": "[email protected]",
  "created_at": "2023-02-13T13:08:00.947Z",
  "updated_at": "2023-02-13T14:31:49.390Z"
}

DELETE /users/delete/ - REQUEST FORMAT

No request body is required.

DELETE /users/delete/ - RESPONSE FORMAT - STATUS 204

No return body.

Login

In this route, the user can access without the token to perform the login :

POST /login - REQUEST FORMAT

{
  "email": "[email protected]",
  "password": ".Crud123"
}

POST /login - RESPONSE FORMAT - STATUS 201

{
  "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJlbWFpbCI6InVzZXJAZ21haWwuY29tIiwiaWF0IjoxNjc2Mjk4NjQ2LCJleHAiOjE2NzYzODUwNDYsInN1YiI6IjdmY2M3MzY4LWZhZWEtNGIzZi1hYjhiLWRlODZjNTQ3ZTA5NyJ9.5IVEZ9popPzx3a7T0vPDI2ZlnnNISxBtPJREd7Zi2HE"
}

Back to Top


Swagger

API also includes routes for interaction, manipulation, and more detailed documentation.

api/

Back to Top


Created by Vagner Mengali

user-crud's People

Contributors

vagnermengali avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.