0.0.114 • Published 4 months ago

aloux-iam v0.0.114

Weekly downloads
-
License
MIT
Repository
github
Last release
4 months ago

Aloux IAM

Uso de esta librearía para administración de menus, privilegios, funciones, usuarios y envio de notificaciones por medio de correos y mensajes de texto

Installation

$ npm install aloux-iam --save

Usage

En archivo init.js

// Require
const { IAMRouter, IAMSwagger } = require('aloux-iam')


app.use(IAMRouter)

// swagger
app.use(
    "/aloux-iam",
    swaggerUI.serveFiles(IAMswagger, {}), 
    swaggerUI.setup(IAMswagger)
    )

// URL Swagger
// [BASE_URL]/docs-iam/#/default/

En archivo router.js

// Require
const { IAMAuth } = require('aloux-iam')

// Example
router.post('/customer', IAMAuth, customer.create)

Variables de entorno

Requiere las siguientes variables de entorno (.env)

VariableDescription
AUTH_SECRETRequired, para cifrar la contraseña
AWS_SECRET_ACCESS_KEYRequired, para acceso a S3 y SES AWS.
AWS_ACCESS_KEY_IDRequired, para acceso a S3 y SES AWS.
AWS_REGIONRequired, para acceso a S3 y SES AWS.
AWS_BUCKETRequired, para guardar la foto de perfil en AWS.
AWS_EMAIL_SENDERRequired, para mandar el correo de recuperación de contraseña
DEBUGRequired, para validar si el ambiente es dev o PROD
SWAGGER_SERVERRequired, para acceder al swagger de IAM
MASTER_PWDOptional, para utilizar contraseña maestra de usuarios en desarrollo
BASE_URLOptional, para swagger

Endpoints disponibles

Endpoints user self (no auth)

MethodEndpointDescription
POSTiam/auth/emailValidar correo
POSTiam/auth/loginIniciar sesión
POSTiam/auth/forgot/passwordEnviar código a correo
POSTiam/auth/validate/codeVerificar código
POSTiam/auth/verify/mailVerificar correo
GETiam/auth/verify/mail/token/:tokenValida correo (Manda correo de bienvenida)
POSTiam/auth/reset/passwordReestablecer contraseña
POSTiam/auth/signupRegistrarse

Endpoints user self

MethodEndpointDescription
GETiam/auth/meObtener información de usuario autenticado
PUTiam/auth/profileActualizar perfil
PUTiam/auth/profile/picturaActualizar solo la foto de perfil
PUTiam/auth/reset/passwordActualizar contraseña
POSTiam/auth/send/verify/phoneEnviar código al teléfono de la cuenta para verificarla
POSTiam/auth/verify/phoneValida teléfono del usuario de la cuenta
POSTiam/auth/logoutCerrar sesión

Endpoints user

MethodEndpointDescription
POSTiam/userCrear usuario
GETiam/userObtener todos los usuario
GETiam/user/:USER_IDObtener detalle de usuario
PUTiam/user/:USER_IDActualizar usuario
PUTiam/user/:USER_ID/statusActivar o desactivar usuario
PUTiam/user/password/:USER_IDActualizar la constraseña de un usuario
DELETEiam/user/:USER_IDEliminar usuario
GETiam/user/count/allObtiene el número de usuarios

Endpoints funtions

MethodEndpointDescription
POSTiam/functionsCrear función
PUTiam/functions/:FUNCTION_IDActualizar función
PUTiam/functions/:FUNCTION_ID/statusActivar o desactivar función
GETiam/functionsObtener todas las funciones
GETiam/functions/:FUNCTION_IDObtener detalle de la función
DELETEiam/functions/:FUNCTION_IDEliminar función
GETiam/functions/count/allObtiene el número de funciones

Endpoints permission

MethodEndpointDescription
POSTiam/permissionCrear permiso
PUTiam/permission/:PERMISSION_IDActualizar permiso
PUTiam/permission/:PERMISSION_ID/statusActivar o desactivar permiso
GETiam/permissionObtener todas los permisos
GETiam/permission/:PERMISSION_IDObtener detalle de la permiso
DELETEiam/permission/:PERMISSION_IDEliminar permiso
GETiam/permission/count/allObtiene el número de permisos

Endpoints menu

MethodEndpointDescription
POST/iam/menuCrea un elemento de menú
PUT/iam/menu/:MENU_IDActualiza un elemento de menú
PUT/iam/menu/:MENU_ID/statusActiva o desactiva un menú
GET/iam/menuObtiene todos los elementos de menú
GET/iam/menu/:MENU_IDObtiene el detalle de un elemento de menú
DELETE/iam/menu/:MENU_IDElimina un elemento de menú
POST/iam/menu/orderOrdena los elementos de menú
GETiam/menu/countObtiene el número de menús

Aloux-AWS

Aggregate file

// Require
const { AlouxAWS } = require('aloux-iam')


// variables
/*
* AWS_REGION
* AWS_BUCKET
*/

/**
 * pathFile = folder/file_name-file_id
 * file     = req.files.property
 */
// a constant is created to save the new element
const result = await AlouxAWS.upload('folder/file_name', req.files.data)

Eliminate many files

// Require
const { AlouxAWS } = require('aloux-iam')


// variables
/*
* AWS_REGION
* AWS_BUCKET
*/

/**
 * files = [{key: 'folder/file1'},{key: 'folder/file1'}]
 */
// delete selected files
const files = [{key: 'folder/file1.png'},{key: 'folder/file1.png'}]
const deleteFiles = await AlouxAWS.deleteMany(files)

Eliminate file

// Require
const { AlouxAWS } = require('aloux-iam')


// variables
/*
* AWS_REGION
* AWS_BUCKET
*/

/**
 * file = folder/file_name
 */
// delete the file
const file = 'folder/file_name.png'
const deleteFile = await AlouxAWS.delete(file)

Usage for emails

Send email

// Require
const { AlouxAWS } = require('aloux-iam')


// variables
/*
* AWS_REGION
* AWS_EMAIL_SENDER
*/

/**
 * email: Destination email
 * message: Mail body
 * subject: Mail subject
 */
// a constant is created to request the data from the req.body.
const { email, message, subject } = req.body
const sendEmail = await AlouxAWS.sendCustom(email, message, subject)

// example of the messages variable
// this variable must be sent as a string if you want to send modified HTML
/*

message: "<!DOCTYPE html><html lang='en'><head><meta charset='UTF-8'><meta name='viewport' content='width=device-width, initial-scale=1.0'><title>Document</title></head><body><h1>Information</h1></body></html>"

*/

Usage for sns

Send sns

// Require
const { AlouxAWS } = require('aloux-iam')


// variables
/*
* AWS_REGION
*/

/**
 * phoneNumber: Destination number
 * message: Message body
 */
// a constant is created to request the data from the req.body.
const { phoneNumber, message } = req.body
const sendSns = await AlouxAWS.sendMessagePhone(phoneNumber, message)

// example of the phoneNumber variable
// this variable must be sent as a string and taking into account the telephone prefix

/*

phoneNumber: "+52244-------"

*/
0.0.114

4 months ago

0.0.113

4 months ago

0.0.106

4 months ago

0.0.105

4 months ago

0.0.104

4 months ago

0.0.103

4 months ago

0.0.109

4 months ago

0.0.108

4 months ago

0.0.107

4 months ago

0.0.112

4 months ago

0.0.111

4 months ago

0.0.110

4 months ago

0.0.102

5 months ago

0.0.101

6 months ago

0.0.100

6 months ago

0.0.96

6 months ago

0.0.97

6 months ago

0.0.98

6 months ago

0.0.99

6 months ago

0.0.92

7 months ago

0.0.93

7 months ago

0.0.94

7 months ago

0.0.90

7 months ago

0.0.91

7 months ago

0.0.87

7 months ago

0.0.88

7 months ago

0.0.89

7 months ago

0.0.84

8 months ago

0.0.85

8 months ago

0.0.86

7 months ago

0.0.80

8 months ago

0.0.81

8 months ago

0.0.82

8 months ago

0.0.83

8 months ago

0.0.78

8 months ago

0.0.79

8 months ago

0.0.75

8 months ago

0.0.76

8 months ago

0.0.77

8 months ago

0.0.73

8 months ago

0.0.74

8 months ago

0.0.72

9 months ago

0.0.70

10 months ago

0.0.71

10 months ago

0.0.66

10 months ago

0.0.67

10 months ago

0.0.68

10 months ago

0.0.69

10 months ago

0.0.65

11 months ago

0.0.64

11 months ago

0.0.62

1 year ago

0.0.63

1 year ago

0.0.60

1 year ago

0.0.61

1 year ago

0.0.59

1 year ago

0.0.51

1 year ago

0.0.52

1 year ago

0.0.53

1 year ago

0.0.54

1 year ago

0.0.55

1 year ago

0.0.56

1 year ago

0.0.57

1 year ago

0.0.58

1 year ago

0.0.50

1 year ago

0.0.46

1 year ago

0.0.47

1 year ago

0.0.48

1 year ago

0.0.49

1 year ago

0.0.42

1 year ago

0.0.43

1 year ago

0.0.44

1 year ago

0.0.45

1 year ago

0.0.40

1 year ago

0.0.41

1 year ago

0.0.39

1 year ago

0.0.37

1 year ago

0.0.38

1 year ago

0.0.33

1 year ago

0.0.34

1 year ago

0.0.35

1 year ago

0.0.36

1 year ago

0.0.32

1 year ago

0.0.30

1 year ago

0.0.31

1 year ago

0.0.29

1 year ago

0.0.28

1 year ago

0.0.26

1 year ago

0.0.27

1 year ago

0.0.25

1 year ago

0.0.23

1 year ago

0.0.24

1 year ago

0.0.22

1 year ago

0.0.21

1 year ago

0.0.20

1 year ago

0.0.15

1 year ago

0.0.16

1 year ago

0.0.17

1 year ago

0.0.18

1 year ago

0.0.19

1 year ago

0.0.14

1 year ago

0.0.13

1 year ago

0.0.11

1 year ago

0.0.12

1 year ago

0.0.10

2 years ago

0.0.9

2 years ago

0.0.8

2 years ago

0.0.7

2 years ago

0.0.6

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago

0.0.0

2 years ago