Este é um crud de usuário que visa facilitar o acesso com funcionalidades básicas de um usuário e login.
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
A API esta divida em /users sendo um CRUD e /login para geraão do token e melhor interação com a api.
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": "user@gmail.com",
"created_at": "2023-02-13T14:30:59.868Z",
"updated_at": "2023-02-13T14:30:59.868Z"
},
{
"username": "CrudUser CrudUser",
"email": "crud@gmail.com",
"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": "crud@gmail.com",
"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": "user@gmail.com",
"password": ".Crud123"
}
POST /users- FORMATO DA RESPOSTA - STATUS 201
{
"id": "6556e127-0518-4407-bd3e-65f5cdf1e869",
"username": "UserCrud UserCrud",
"email": "user@gmail.com",
"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": "crud@gmail.com",
"password": ".User123"
}
PATCH /users/update/ - FORMATO DA RESPOSTA - STATUS 200
{
"id": "fb6f2944-3ddc-4cef-a217-c0de75a1ee04",
"username": "CrudUser CrudUser",
"email": "crud@gmail.com",
"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.
Nessa rota o usuário pode acessar sem o token para efetuar o login :
POST /login - FORMATO DA REQUISIÇÃO
{
"email": "user@gmail.com",
"password": ".Crud123"
}
POST /login - FORMATO DA RESPOSTA - STATUS 201
{
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJlbWFpbCI6InVzZXJAZ21haWwuY29tIiwiaWF0IjoxNjc2Mjk4NjQ2LCJleHAiOjE2NzYzODUwNDYsInN1YiI6IjdmY2M3MzY4LWZhZWEtNGIzZi1hYjhiLWRlODZjNTQ3ZTA5NyJ9.5IVEZ9popPzx3a7T0vPDI2ZlnnNISxBtPJREd7Zi2HE"
}
Api também conta a rota de interação, manipulação e documentação mais detalhada.
api/
This is a user CRUD aiming to facilitate access with basic user and login functionalities.
Installation Endpoints Swagger
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
The API is divided into /users, which is a CRUD, and /login for token generation and better interaction with the API.
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": "user@gmail.com",
"created_at": "2023-02-13T14:30:59.868Z",
"updated_at": "2023-02-13T14:30:59.868Z"
},
{
"username": "CrudUser CrudUser",
"email": "crud@gmail.com",
"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": "crud@gmail.com",
"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": "user@gmail.com",
"password": ".Crud123"
}
POST /users - RESPONSE FORMAT - STATUS 201
{
"id": "6556e127-0518-4407-bd3e-65f5cdf1e869",
"username": "UserCrud UserCrud",
"email": "user@gmail.com",
"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": "crud@gmail.com",
"password": ".User123"
}
PATCH /users/update/ - RESPONSE FORMAT - STATUS 200
{
"id": "fb6f2944-3ddc-4cef-a217-c0de75a1ee04",
"username": "CrudUser CrudUser",
"email": "crud@gmail.com",
"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.
In this route, the user can access without the token to perform the login :
POST /login - REQUEST FORMAT
{
"email": "user@gmail.com",
"password": ".Crud123"
}
POST /login - RESPONSE FORMAT - STATUS 201
{
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJlbWFpbCI6InVzZXJAZ21haWwuY29tIiwiaWF0IjoxNjc2Mjk4NjQ2LCJleHAiOjE2NzYzODUwNDYsInN1YiI6IjdmY2M3MzY4LWZhZWEtNGIzZi1hYjhiLWRlODZjNTQ3ZTA5NyJ9.5IVEZ9popPzx3a7T0vPDI2ZlnnNISxBtPJREd7Zi2HE"
}
API also includes routes for interaction, manipulation, and more detailed documentation.
api/