Skip to content

Commit

Permalink
add jest
Browse files Browse the repository at this point in the history
  • Loading branch information
gladwindos committed Feb 10, 2024
1 parent 1691633 commit 601fc15
Show file tree
Hide file tree
Showing 7 changed files with 4,487 additions and 1,246 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
jest.config.js
5 changes: 5 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/** @type {import('ts-jest').JestConfigWithTsJest} */
module.exports = {
preset: "ts-jest",
testEnvironment: "node",
};
5,710 changes: 4,471 additions & 1,239 deletions package-lock.json

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"main": "index.ts",
"scripts": {
"dev": "nodemon ./src/index.ts",
"test": "echo \"Error: no test specified\" && exit 1",
"test": "jest",
"lint": "eslint ."
},
"author": "",
Expand All @@ -18,13 +18,16 @@
},
"devDependencies": {
"@types/express": "^4.17.21",
"@types/jest": "^29.5.12",
"@types/node": "^20.11.17",
"@typescript-eslint/eslint-plugin": "^6.21.0",
"@typescript-eslint/parser": "^6.21.0",
"eslint": "^8.56.0",
"eslint-config-prettier": "^9.1.0",
"jest": "^29.7.0",
"nodemon": "^3.0.3",
"prettier": "3.2.5",
"ts-jest": "^29.1.2",
"ts-node": "^10.9.2",
"typescript": "^5.3.3"
}
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import "dotenv/config";
import express from "express";
import { parseConfig } from "./utils/config/parse-config";
import { parseConfig } from "./utils/parse-config";

const app = express();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import fs from "fs";
import YAML from "yaml";
import { Config } from "../../types/config";
import { Config } from "../types/config";
import { validateConfig } from "./validate-config";

export const parseConfig = (filePath: string): Config => {
const fileContents = fs
const file = fs
.readFileSync(filePath, "utf8")
.replace(/\$\{(.+?)\}/g, (match, name) => process.env[name] || match);

const config = YAML.parse(fileContents);
const config = YAML.parse(file);

const valid = validateConfig(config);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Ajv, { JSONSchemaType } from "ajv";
import { Destination, Endpoint } from "../../types/endpoints";
import { Config } from "../../types/config";
import { Destination, Endpoint } from "../types/endpoints";
import { Config } from "../types/config";

const ajv = new Ajv();

Expand Down

0 comments on commit 601fc15

Please sign in to comment.