branch-node-core 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,33 @@
1
+ # branch-node-core
2
+
3
+ Branch node core lib.
4
+
5
+ ## Features
6
+
7
+ - ES6 syntax, managed with Prettier + Eslint and Stylelint
8
+ - Unit testing via Jest
9
+
10
+ ## Install
11
+
12
+ ```sh
13
+ yarn add branch-node-core
14
+ // or
15
+ npm i branch-node-core
16
+ ```
17
+
18
+ ### Requirements
19
+
20
+ - Node.js `v14.x` or later
21
+
22
+
23
+ ### Usage
24
+
25
+ ```js
26
+ import { UserError } from 'branch-node-core';
27
+
28
+ function main() {
29
+ if(!user.isLoggedIn()) {
30
+ throw new UserError();
31
+ }
32
+ }
33
+ ```
@@ -0,0 +1,15 @@
1
+ // Note: careful, this code is shared between client and server side.
2
+
3
+ function UserError(message, field, code) {
4
+ this.name = 'UserError';
5
+ if (Error && Error.captureStackTrace) { Error.captureStackTrace(this, UserError); }
6
+
7
+ this.field = field || '';
8
+ this.code = code || 400;
9
+ this.message = message;
10
+ }
11
+
12
+ UserError.prototype = Object.create(Error.prototype);
13
+ UserError.prototype.constructor = UserError;
14
+
15
+ module.exports = UserError;
package/package.json ADDED
@@ -0,0 +1,20 @@
1
+ {
2
+ "name": "branch-node-core",
3
+ "version": "0.0.1",
4
+ "private": false,
5
+ "description": "Branch node core lib",
6
+ "license": "MIT",
7
+ "author": "hbnch",
8
+ "main": "branch/errors/UserError.js",
9
+ "scripts": {
10
+ "test": "exit 0"
11
+ },
12
+ "publishConfig": {
13
+ "access": "public"
14
+ },
15
+ "devDependencies": {
16
+ "@babel/runtime": "^7.18.3",
17
+ "@babel/cli": "^7.18.3",
18
+ "@babel/core": "^7.18.3"
19
+ }
20
+ }