1.0.138 • Published 6 years ago

sn-utilities v1.0.138

Weekly downloads
4
License
ISC
Repository
-
Last release
6 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

6 years ago

1.0.137

6 years ago

1.0.136

7 years ago

1.0.135

7 years ago

1.0.134

7 years ago

1.0.133

7 years ago

1.0.132

7 years ago

1.0.131

7 years ago

1.0.130

7 years ago

1.0.129

7 years ago

1.0.128

7 years ago

1.0.127

7 years ago

1.0.126

7 years ago

1.0.125

7 years ago

1.0.124

7 years ago

1.0.123

7 years ago

1.0.122

7 years ago

1.0.121

7 years ago

1.0.120

7 years ago

1.0.119

7 years ago

1.0.118

8 years ago

1.0.117

8 years ago

1.0.116

8 years ago

1.0.115

8 years ago

1.0.114

8 years ago

1.0.113

8 years ago

1.0.112

8 years ago

1.0.111

8 years ago

1.0.110

8 years ago

1.0.109

8 years ago

1.0.108

8 years ago

1.0.107

8 years ago

1.0.106

8 years ago

1.0.105

8 years ago

1.0.104

8 years ago

1.0.103

8 years ago

1.0.102

8 years ago

1.0.101

8 years ago

1.0.100

8 years ago

1.0.99

8 years ago

1.0.98

8 years ago

1.0.97

8 years ago

1.0.96

8 years ago

1.0.95

8 years ago

1.0.94

8 years ago

1.0.93

8 years ago

1.0.92

8 years ago

1.0.91

8 years ago

1.0.90

8 years ago

1.0.89

9 years ago

1.0.88

9 years ago

1.0.87

9 years ago

1.0.86

9 years ago

1.0.85

9 years ago

1.0.84

9 years ago

1.0.83

9 years ago

1.0.82

9 years ago

1.0.81

9 years ago

1.0.80

9 years ago

1.0.79

9 years ago

1.0.78

9 years ago

1.0.77

9 years ago

1.0.76

9 years ago

1.0.75

9 years ago

1.0.73

9 years ago

1.0.72

9 years ago

1.0.71

9 years ago

1.0.70

9 years ago

1.0.69

9 years ago

1.0.68

9 years ago

1.0.67

9 years ago

1.0.66

9 years ago

1.0.65

9 years ago

1.0.64

9 years ago

1.0.63

9 years ago

1.0.62

9 years ago

1.0.61

9 years ago

1.0.60

9 years ago

1.0.59

9 years ago

1.0.58

9 years ago

1.0.57

9 years ago

1.0.56

9 years ago

1.0.55

9 years ago

1.0.54

9 years ago

1.0.53

9 years ago

1.0.52

9 years ago

1.0.51

9 years ago

1.0.50

9 years ago

1.0.49

9 years ago

1.0.48

9 years ago

1.0.47

9 years ago

1.0.46

9 years ago

1.0.45

9 years ago

1.0.44

9 years ago

1.0.43

9 years ago

1.0.42

9 years ago

1.0.41

9 years ago

1.0.40

9 years ago

1.0.39

9 years ago

1.0.38

9 years ago

1.0.37

9 years ago

1.0.36

9 years ago

1.0.35

10 years ago

1.0.34

10 years ago

1.0.33

10 years ago

1.0.32

10 years ago

1.0.31

10 years ago

1.0.30

10 years ago

1.0.29

10 years ago

1.0.28

10 years ago

1.0.27

10 years ago

1.0.26

10 years ago

1.0.25

10 years ago

1.0.24

10 years ago

1.0.23

10 years ago

1.0.22

10 years ago

1.0.21

10 years ago

1.0.20

10 years ago

1.0.19

10 years ago

1.0.18

10 years ago

1.0.17

10 years ago

1.0.16

10 years ago

1.0.15

10 years ago

1.0.14

10 years ago

1.0.13

10 years ago

1.0.12

10 years ago

1.0.11

10 years ago

1.0.10

10 years ago

1.0.9

10 years ago

1.0.8

10 years ago

1.0.7

10 years ago

1.0.6

10 years ago

1.0.5

10 years ago

1.0.4

10 years ago

1.0.3

10 years ago

1.0.2

10 years ago

1.0.1

10 years ago

1.0.0

10 years ago