@moreapp/common-nodejs 0.2.0 → 0.3.0

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 CHANGED
@@ -1,11 +1,6 @@
1
- # Notification service
1
+ # MoreApp Common NodeJS
2
2
 
3
- # Direnv
4
-
5
- `direnv` loads the `.envrc` file automatically
6
- This loads Sparkpost secrets via `kubectl`
7
-
8
- **NOTE:** make sure the dev-cluster in `kubectx` is named `dev`!
3
+ .. TODO
9
4
 
10
5
  # Pre-commit hooks
11
6
 
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@moreapp/common-nodejs",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "license": "UNLICENSED",
5
- "main": "build/index.js",
6
- "types": "build/index.d.ts",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
7
  "scripts": {
8
8
  "build": "tsc",
9
9
  "test": "jest",
@@ -14,7 +14,22 @@
14
14
  "lint:fix": "yarn lint:check --fix",
15
15
  "prepare": "husky install"
16
16
  },
17
- "dependencies": {},
17
+ "files": [
18
+ "dist/**/*"
19
+ ],
20
+ "dependencies": {
21
+ "@google-cloud/logging": "10.4.0",
22
+ "@google-cloud/opentelemetry-cloud-trace-exporter": "2.0.0",
23
+ "@opentelemetry/api": "1.4.1",
24
+ "@opentelemetry/instrumentation": "0.36.1",
25
+ "@opentelemetry/instrumentation-dns": "0.31.2",
26
+ "@opentelemetry/instrumentation-express": "0.32.1",
27
+ "@opentelemetry/instrumentation-http": "0.36.1",
28
+ "@opentelemetry/instrumentation-winston": "0.31.1",
29
+ "@opentelemetry/sdk-node": "0.36.1",
30
+ "@opentelemetry/sdk-trace-node": "1.10.1",
31
+ "winston": "3.8.2"
32
+ },
18
33
  "devDependencies": {
19
34
  "@types/jest": "29.2.0",
20
35
  "@types/node": "18.11.8",
package/.eslintignore DELETED
@@ -1,2 +0,0 @@
1
- **/*.js
2
- node_modules
package/.eslintrc.json DELETED
@@ -1,19 +0,0 @@
1
- {
2
- "env": {
3
- "node": true
4
- },
5
- "extends": ["plugin:prettier/recommended"],
6
- "parser": "@typescript-eslint/parser",
7
- "parserOptions": {
8
- "project": ["./tsconfig.json"],
9
- "ecmaVersion": 12,
10
- "sourceType": "module"
11
- },
12
- "plugins": ["prettier", "@typescript-eslint"],
13
- "rules": {
14
- "prettier/prettier": ["error"],
15
- "default-case": "off",
16
- "@typescript-eslint/switch-exhaustiveness-check": "error"
17
- },
18
- "ignorePatterns": ["build"]
19
- }
package/.husky/pre-commit DELETED
@@ -1,5 +0,0 @@
1
- #!/bin/sh
2
- . "$(dirname "$0")/_/husky.sh"
3
-
4
- yarn build
5
- npx lint-staged
package/.nvmrc DELETED
@@ -1 +0,0 @@
1
- 18.12.0
package/.prettierignore DELETED
@@ -1 +0,0 @@
1
- dist
@@ -1,53 +0,0 @@
1
- image: node:18.12.0
2
-
3
- pipelines:
4
- pull-requests:
5
- '**':
6
- - step:
7
- name: Analyse
8
- services:
9
- - docker
10
- caches:
11
- - docker
12
- - node
13
- - sonar
14
- script:
15
- - yarn install --frozen-lockfile
16
- - yarn format:check
17
- - yarn lint:check
18
- - yarn build
19
- - yarn test --coverage --testResultsProcessor=jest-sonar-reporter --detectOpenHandles
20
- - pipe: sonarsource/sonarcloud-scan:1.4.0
21
- variables:
22
- EXTRA_ARGS: '-Dsonar.sources=src -Dsonar.tests=src -Dsonar.test.inclusions="**/*.test.js" -Dsonar.coverage.exclusions="**/node_modules/**,**/*.spec.ts" -Dsonar.javascript.lcov.reportPaths=coverage/lcov.info'
23
- - pipe: sonarsource/sonarcloud-quality-gate:0.1.6
24
- branches:
25
- master:
26
- - step:
27
- name: "Build"
28
- caches:
29
- - node
30
- script:
31
- - yarn --frozen-lockfile
32
- - yarn build
33
- artifacts:
34
- - build/**
35
- - step:
36
- name: "Publish to NPM"
37
- trigger: manual
38
- caches:
39
- - node
40
- script:
41
- - npm version minor -m "Upgrade to %s [skip ci]"
42
- - git push && git push --tags
43
- - pipe: atlassian/npm-publish:0.3.2
44
- variables:
45
- NPM_TOKEN: $NPM_TOKEN
46
- EXTRA_ARGS: "--access public"
47
-
48
- definitions:
49
- caches:
50
- sonar: ~/.sonar/cache
51
- services:
52
- docker:
53
- memory: 2048
@@ -1,3 +0,0 @@
1
- import type { Config } from "@jest/types";
2
- declare const config: Config.InitialOptions;
3
- export default config;
@@ -1,13 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const config = {
4
- verbose: true,
5
- preset: "ts-jest",
6
- testEnvironment: "node",
7
- testPathIgnorePatterns: ["/node_modules/", "/dist/"],
8
- roots: ["<rootDir>/src"],
9
- transform: {
10
- "^.+\\.ts?$": "ts-jest",
11
- },
12
- };
13
- exports.default = config;
@@ -1 +0,0 @@
1
- export * from "./utils";
@@ -1,17 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./utils"), exports);
@@ -1 +0,0 @@
1
- export declare function environmentVariable(key: string, fallback?: string | number): string;
@@ -1,11 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.environmentVariable = void 0;
4
- function environmentVariable(key, fallback) {
5
- const value = process.env[key] || fallback;
6
- if (value) {
7
- return value.toString();
8
- }
9
- throw new Error(`Missing environment variable '${key}'`);
10
- }
11
- exports.environmentVariable = environmentVariable;
@@ -1 +0,0 @@
1
- export {};
@@ -1,15 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const utils_1 = require("./utils");
4
- describe("environmentVariable", () => {
5
- test("Should throw when environment variable does not exist", async () => {
6
- process.env["COMMONS_NODEJS_TEST_EXISTING"] = "SOME_VALUE";
7
- expect((0, utils_1.environmentVariable)("COMMONS_NODEJS_TEST_EXISTING")).toBe("SOME_VALUE");
8
- });
9
- test("Use fallback value when environment variable does not exist", async () => {
10
- expect((0, utils_1.environmentVariable)("COMMONS_NODEJS_TEST_NON_EXISTING", "DEFAULT_VALUE")).toBe("DEFAULT_VALUE");
11
- });
12
- test("Should throw when environment variable does not exist", async () => {
13
- expect(() => (0, utils_1.environmentVariable)("COMMONS_NODEJS_TEST_NON_EXISTING")).toThrow("Missing environment variable 'COMMONS_NODEJS_TEST_NON_EXISTING'");
14
- });
15
- });
package/jest.config.ts DELETED
@@ -1,14 +0,0 @@
1
- import type { Config } from "@jest/types";
2
-
3
- const config: Config.InitialOptions = {
4
- verbose: true,
5
- preset: "ts-jest",
6
- testEnvironment: "node",
7
- testPathIgnorePatterns: ["/node_modules/", "/dist/"],
8
- roots: ["<rootDir>/src"],
9
- transform: {
10
- "^.+\\.ts?$": "ts-jest",
11
- },
12
- };
13
-
14
- export default config;
@@ -1,5 +0,0 @@
1
- sonar.sources=src
2
- sonar.exclusions=src/**/*.test.ts
3
- sonar.tests=src/**/*.test.ts
4
- sonar.testExecutionReportPaths=test-report.xml
5
- sonar.javascript.lcov.reportPaths=coverage/lcov.info
package/src/index.ts DELETED
@@ -1 +0,0 @@
1
- export * from "./utils";
package/src/utils.test.ts DELETED
@@ -1,20 +0,0 @@
1
- import { environmentVariable } from "./utils";
2
-
3
- describe("environmentVariable", () => {
4
- test("Should throw when environment variable does not exist", async () => {
5
- process.env["COMMONS_NODEJS_TEST_EXISTING"] = "SOME_VALUE";
6
- expect(environmentVariable("COMMONS_NODEJS_TEST_EXISTING")).toBe("SOME_VALUE");
7
- });
8
-
9
- test("Use fallback value when environment variable does not exist", async () => {
10
- expect(environmentVariable("COMMONS_NODEJS_TEST_NON_EXISTING", "DEFAULT_VALUE")).toBe(
11
- "DEFAULT_VALUE"
12
- );
13
- });
14
-
15
- test("Should throw when environment variable does not exist", async () => {
16
- expect(() => environmentVariable("COMMONS_NODEJS_TEST_NON_EXISTING")).toThrow(
17
- "Missing environment variable 'COMMONS_NODEJS_TEST_NON_EXISTING'"
18
- );
19
- });
20
- });
package/src/utils.ts DELETED
@@ -1,8 +0,0 @@
1
- export function environmentVariable(key: string, fallback?: string | number): string {
2
- const value = process.env[key] || fallback;
3
- if (value) {
4
- return value.toString();
5
- }
6
-
7
- throw new Error(`Missing environment variable '${key}'`);
8
- }
package/tsconfig.json DELETED
@@ -1,24 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- /* Visit https://aka.ms/tsconfig.json to read more about this file */
4
-
5
- "lib": ["ES2021"],
6
- "module": "commonjs",
7
- "target": "ES2021",
8
- "outDir": "./build",
9
- "strict": true,
10
- "declaration": true,
11
- "noUnusedLocals": true,
12
- "noUnusedParameters": true,
13
- "noImplicitReturns": true,
14
- "noFallthroughCasesInSwitch": true,
15
- "noUncheckedIndexedAccess": true,
16
- "noImplicitOverride": true,
17
- "noPropertyAccessFromIndexSignature": true,
18
- "esModuleInterop": true,
19
- "skipLibCheck": true,
20
- "forceConsistentCasingInFileNames": true,
21
- // Required to load JSON files
22
- "resolveJsonModule": true
23
- }
24
- }