1.0.138 • Published 5 years ago

sn-utilities v1.0.138

Weekly downloads
4
License
ISC
Repository
-
Last release
5 years ago

Utilities

function getParams(req, func)

Parameters:

 Parameter          | Type        | Description            
--------------------+-------------+------------------------------------------
 req                | JSON        | HTTP request object containing HTTP parameters
 func               | function    | JavaScript function (example below)

Example of func parameter:

function getParams(source, target) {
    if (source) {
        if (source.id && !target.id) {
            target.id = source.id;
        }
        if (source.name && !target.name) {
            target.name = source.name;
        }
    }
    return target;
}

function handleError(error, res)

Parameters:

 Parameter          | Type        | Description            
--------------------+-------------+------------------------------------------
 error              | JSON        | JSON error object (format below)
 res                | JSON        | HTTP response object

Format of JSON error parameter:

{
  "error": [{}],
  "status": [123]
}
Above JSON explained:
 Parameter          | Type        | Description            
--------------------+-------------+------------------------------------------
 error              | JSON        | The JSON object of the error thrown
 status             | INT         | (Optional) HTTP status code to be used if the status in error is not specified
Example of above JSON error:
{
  "error": {
    "errors": [
      {
        "error": "invalid input syntax for uuid: \"3334c105-f842-98e7-603a\""
      }
    ],
    "name": "error",
    "length": 118,
    "severity": "ERROR",
    "code": "22P02",
    "detail": "undefined",
    "hint": "undefined",
    "position": "undefined",
    "internalPosition": "undefined",
    "internalQuery": "undefined",
    "where": "undefined",
    "schema": "undefined",
    "table": "undefined",
    "column": "undefined",
    "dataType": "undefined",
    "constraint": "undefined",
    "file": "uuid.c",
    "line": "129",
    "routine": "string_to_uuid"
  }
}

function handleSuccess(success, res)

Parameters:

 Parameter          | Type        | Description            
--------------------+-------------+------------------------------------------
 success            | JSON        | JSON success object (format below)
 res                | JSON        | HTTP response object

Format of JSON success parameter:

{
  "success": {
  	"status": [123],
  	"message": ["abc"],
    "data": {}
  },
  "status": [123]
}
Above JSON explained:
 Parameter          | Type        | Description            
--------------------+-------------+-----------------------------------------------------------------------------------
 success->status    | INT         | (Optional) HTTP status code
 success->message   | TEXT        | Description of status
 success->data      | JSON        | (Optional) Metadata
 status             | INT         | (Optional) HTTP status code to be used if the status in success is not specified

function handleContentTypeJSON(param, res)

Parameters:

 Parameter          | Type        | Description            
--------------------+-------------+------------------------------------------
 param              | JSON        | JSON param object (format below)
 res                | JSON        | HTTP response object

Format of JSON param parameter:

{
  "contentType": ["abc"]
}
Above JSON explained:
 Parameter           | Type        | Description            
---------------------+-------------+-------------------------------------------------
 contentType         | TEXT        | The content type of the request to be validated

function createUUID(data)

Parameters:

 Parameter          | Type        | Description            
--------------------+-------------+------------------------------------------
 data               | ANYTHING    | (Optional)

function getLocalTimestampString()

1.0.138

5 years ago

1.0.137

5 years ago

1.0.136

5 years ago

1.0.135

5 years ago

1.0.134

5 years ago

1.0.133

5 years ago

1.0.132

6 years ago

1.0.131

6 years ago

1.0.130

6 years ago

1.0.129

6 years ago

1.0.128

6 years ago

1.0.127

6 years ago

1.0.126

6 years ago

1.0.125

6 years ago

1.0.124

6 years ago

1.0.123

6 years ago

1.0.122

6 years ago

1.0.121

6 years ago

1.0.120

6 years ago

1.0.119

6 years ago

1.0.118

6 years ago

1.0.117

6 years ago

1.0.116

6 years ago

1.0.115

6 years ago

1.0.114

6 years ago

1.0.113

6 years ago

1.0.112

6 years ago

1.0.111

6 years ago

1.0.110

6 years ago

1.0.109

6 years ago

1.0.108

6 years ago

1.0.107

6 years ago

1.0.106

6 years ago

1.0.105

6 years ago

1.0.104

6 years ago

1.0.103

7 years ago

1.0.102

7 years ago

1.0.101

7 years ago

1.0.100

7 years ago

1.0.99

7 years ago

1.0.98

7 years ago

1.0.97

7 years ago

1.0.96

7 years ago

1.0.95

7 years ago

1.0.94

7 years ago

1.0.93

7 years ago

1.0.92

7 years ago

1.0.91

7 years ago

1.0.90

7 years ago

1.0.89

8 years ago

1.0.88

8 years ago

1.0.87

8 years ago

1.0.86

8 years ago

1.0.85

8 years ago

1.0.84

8 years ago

1.0.83

8 years ago

1.0.82

8 years ago

1.0.81

8 years ago

1.0.80

8 years ago

1.0.79

8 years ago

1.0.78

8 years ago

1.0.77

8 years ago

1.0.76

8 years ago

1.0.75

8 years ago

1.0.73

8 years ago

1.0.72

8 years ago

1.0.71

8 years ago

1.0.70

8 years ago

1.0.69

8 years ago

1.0.68

8 years ago

1.0.67

8 years ago

1.0.66

8 years ago

1.0.65

8 years ago

1.0.64

8 years ago

1.0.63

8 years ago

1.0.62

8 years ago

1.0.61

8 years ago

1.0.60

8 years ago

1.0.59

8 years ago

1.0.58

8 years ago

1.0.57

8 years ago

1.0.56

8 years ago

1.0.55

8 years ago

1.0.54

8 years ago

1.0.53

8 years ago

1.0.52

8 years ago

1.0.51

8 years ago

1.0.50

8 years ago

1.0.49

8 years ago

1.0.48

8 years ago

1.0.47

8 years ago

1.0.46

8 years ago

1.0.45

8 years ago

1.0.44

8 years ago

1.0.43

8 years ago

1.0.42

8 years ago

1.0.41

8 years ago

1.0.40

8 years ago

1.0.39

8 years ago

1.0.38

8 years ago

1.0.37

8 years ago

1.0.36

8 years ago

1.0.35

8 years ago

1.0.34

8 years ago

1.0.33

8 years ago

1.0.32

8 years ago

1.0.31

8 years ago

1.0.30

8 years ago

1.0.29

8 years ago

1.0.28

8 years ago

1.0.27

8 years ago

1.0.26

8 years ago

1.0.25

8 years ago

1.0.24

8 years ago

1.0.23

8 years ago

1.0.22

8 years ago

1.0.21

8 years ago

1.0.20

8 years ago

1.0.19

8 years ago

1.0.18

8 years ago

1.0.17

8 years ago

1.0.16

8 years ago

1.0.15

8 years ago

1.0.14

8 years ago

1.0.13

8 years ago

1.0.12

8 years ago

1.0.11

8 years ago

1.0.10

8 years ago

1.0.9

8 years ago

1.0.8

8 years ago

1.0.7

8 years ago

1.0.6

8 years ago

1.0.5

8 years ago

1.0.4

8 years ago

1.0.3

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago