Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
DB_STRING=<your_string_connection>
SECRET=<your_secret_key>
#NODE_ENV_TEST="test"
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# ignorando .env
.env

# igorando pasta de build
dist/

# ignorando node-modules
node_modules/
.vercel
111 changes: 111 additions & 0 deletions docs/auth.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
paths:
/auth/login:
post:
summary: "Login an user"
description: "Verify user credentials and to make login"
tags:
- "Auth"
requestBody:
required: true
content:
application/json:
schema:
type: object
items:
$ref: "#/components/schemas/Login"
example:
email: "wiredcraft@gmail.com"
password: "!Test12345"
responses:
"200":
description: "User authenticated successfully"
content:
application/json:
schema:
type: object
properties:
message:
type: string
description: "User authenticated successfully"
token:
type: string
description: "JWT token"
"404":
description: "User not found"
"422":
description: "Invalids data"
"500":
description: "Internal Server Error"
/auth/register:
post:
summary: "Register an user"
description: "Register a new user"
tags:
- "Auth"
requestBody:
required: true
content:
application/json:
schema:
type: object
items:
$ref: "#/components/schemas/Register"
example:
name: "User Test"
email: "wiredcraft@gmail.com"
password: "!Test12345"
dateBirth: "2000/05/04"
address:
street: "Avenue Principal"
number: "1204"
city: "Los Angeles"
description: "Software Developer, 25y, Single"
responses:
"201":
description: "User created successfully"
content:
application/json:
schema:
type: object
properties:
message:
type: string
description: "User created successfully"
userCreated:
type: object
properties:
acknowledged:
type: boolean
description: "true"
insertedId:
type: string
description: "675db56f84deb000d9e86187"
"400":
description: "Email is not available"
"422":
description: "Invalids data"
"500":
description: "Internal Server Error"
/auth/logout:
post:
summary: "Logout an user"
description: "Must logout an user and invalid a token"
tags:
- "Auth"
responses:
"200":
description: "User logged out successfully"
content:
application/json:
schema:
type: object
properties:
message:
type: string
description: "User logged out successfully"
"401":
description: "Access denied, unauthorize"
"500":
description: "Internal Server Error"
security:
- bearerAuth: []
21 changes: 21 additions & 0 deletions docs/index.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
definition:
openapi: 3.0.0
info:
title: Wiredcraft API node.js
version: 1.0.0
paths:
/user:
$ref: "./user.yaml"
/auth:
$ref: "./auth.yaml"
/profile:
$ref: "./profile.yaml"
components:
securitySchemes:
bearerAuth:
type: "http"
scheme: "Bearer"
bearerFormat: "JWT"
servers:
- url: "http://localhost:3000"
description: "Development server"
192 changes: 192 additions & 0 deletions docs/profile.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,192 @@
paths:
/profile/{userId}:
get:
summary: "Return user profile"
description: "Must return profile of user logged"
tags:
- "Profile"
parameters:
- name: "userId"
in: "path"
required: true
schema:
type: string
description: "User ID"
responses:
"200":
description: "Profile user"
content:
application/json:
schema:
type: array
items:
$ref: "#/components/schemas/Profile"
"401":
description: "Access denied, unauthorized"
"404":
description: "Profile not found"
"500":
description: "Internal Server Error"
security:
- bearerAuth: []
/profile/nearby/{userId}:
get:
summary: "Return friends nearby of user"
description: "Returns close friends to the user within a radius of up to 10 km"
tags:
- "Profile"
parameters:
- name: "userId"
in: "path"
required: true
schema:
type: string
description: "User ID"
responses:
"200":
description: "A list of users nearby in a radius of 10km"
content:
application/json:
schema:
type: array
items:
$ref: "#/components/schemas/UserWithDistance"
"400":
description: "No followers found"
"401":
description: "Access denied, unauthorized"
"404":
description: "User or address not found"
"500":
description: "Internal Server Error"
security:
- bearerAuth: []
/profile/{receiverId}/{senderId}:
post:
summary: "Send request of friendship"
description: "Must send a request of friendship for an user"
tags:
- "Profile"
parameters:
- name: "receiverId"
in: "path"
required: true
schema:
type: string
description: "User that must receive an invite"
- name: "senderId"
in: "path"
required: true
schema:
type: string
description: "User that sended an invite"
responses:
"200":
description: "Invite sended successfully"
content:
application/json:
schema:
type: object
properties:
message:
type: string
description: "Invite sended successfully"
"400":
description: "Error to send invite, try again later"
"401":
description: "Access denied, unauthorized"
"404":
description: "Profile not found"
"422":
description: "ReceiverID and SenderID is required"
"500":
description: "Internal Server Error"
security:
- bearerAuth: []
/profile/{receiverId}:
post:
summary: "Accepting an invite of friendship"
description: "Must accept an invite of friendship"
tags:
- "Profile"
parameters:
- name: "receiverId"
in: "path"
required: true
schema:
type: string
description: "Receiver ID"
requestBody:
required: true
content:
application/json:
schema:
type: object
properties:
userId:
type: string
description: "User that sended an invite"
example: "675dcd08dc92e3ee2bc87998"
respost:
type: number
example: 1
responses:
"200":
description: "Friend request successfully accepted"
content:
application/json:
schema:
type: object
properties:
message:
type: string
description: "Friend request successfully accepted"
"400":
description: "Users already friends"
"401":
description: "Access denied, unauthorized"
"404":
description: "Profile not found"
"422":
description: "ReceiverID is required"
"500":
description: "Internal Server Error"
security:
- bearerAuth: []
/profile/delete/{userId}:
delete:
summary: "Delete an User profile"
description: "Must delete an User profile from database"
tags:
- "Profile"
parameters:
- name: "userId"
in: "path"
required: true
schema:
type: string
description: "User ID"
responses:
"200":
description: "User Profile deleted successfully"
content:
application/json:
schema:
type: object
properties:
message:
type: string
description: "User deleted successfully"
response:
type: object
description: "Informations of user deleted"
"400":
description: "Failed to delete user"
"401":
description: "Access denied, unauthorized"
"422":
description: "UserId is required"
"500":
description: "Internal Server Error"
security:
- bearerAuth: []
11 changes: 11 additions & 0 deletions docs/schemas/login.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
components:
schemas:
Login:
type: object
properties:
email:
type: string
description: User email
password:
type: string
description: User password
Loading