Skip to content
This repository has been archived by the owner on Oct 16, 2024. It is now read-only.

Commit

Permalink
feat: strip config
Browse files Browse the repository at this point in the history
  • Loading branch information
dargmuesli committed Nov 24, 2022
1 parent 011fd90 commit 6a16c0d
Show file tree
Hide file tree
Showing 11 changed files with 77 additions and 211 deletions.
34 changes: 1 addition & 33 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,42 +1,10 @@
{
"env": {
"node": true,
"jest": true
},
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:import/recommended",
"plugin:import/typescript",
"plugin:jest/recommended",
"plugin:jest/style",
"plugin:node/recommended",
"plugin:prettier/recommended"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 2022,
"sourceType": "module"
},
"plugins": [
"import",
"jest",
"@typescript-eslint"
],
"rules": {
"node/no-missing-import": "off"
},
"settings": {
"node": {
"tryExtensions": [".js", ".ts"]
},
"import/parsers": {
"@typescript-eslint/parser": [".ts"]
},
"import/resolver": {
"typescript": {
"alwaysTryTypes": true
}
}
}
"parser": "@typescript-eslint/parser"
}
6 changes: 4 additions & 2 deletions jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,9 @@ export default {
// ],

// A map from regular expressions to module names or to arrays of module names that allow to stub out resources with a single module
// moduleNameMapper: {},
moduleNameMapper: {
'(.+)\\.js': '$1',
},

// An array of regexp pattern strings, matched against all module paths before considered 'visible' to the module loader
// modulePathIgnorePatterns: [],
Expand Down Expand Up @@ -137,7 +139,7 @@ export default {
// snapshotSerializers: [],

// The test environment that will be used for testing
testEnvironment: 'node',
// testEnvironment: 'node',

// Options that will be passed to the testEnvironment
// testEnvironmentOptions: {},
Expand Down
7 changes: 3 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,12 @@
"dev": "sh parallel_commands 'nodemon ./src/stomper.ts' 'find ./src/email-templates/ -maxdepth 1 -type f -name ''*.mjml'' -print0 | xargs -0 mjml -o ./src/email-templates/ -w'",
"lint": "eslint .",
"prepare": "if [ -d '.git' ] && [ -d '.husky' ] && [ \"$NODE_ENV\" != 'production' ]; then husky install && shx rm -rf .git/hooks && shx ln -s ../.husky .git/hooks; fi",
"start": "pnpm run build && node ./dist/stomper.js",
"start": "node ./dist/stomper.js",
"test": "NODE_OPTIONS=--experimental-vm-modules jest"
},
"dependencies": {
"@stomp/stompjs": "6.1.2",
"camelcase-keys": "8.0.2",
"consola": "2.15.3",
"express": "4.18.2",
"handlebars": "4.7.7",
"html-to-text": "8.2.1",
Expand All @@ -34,7 +33,7 @@
"nodemailer": "6.8.0",
"pg": "8.8.0",
"serve-static": "1.15.0",
"websocket": "1.0.34"
"ws": "8.11.0"
},
"devDependencies": {
"@babel/core": "7.20.2",
Expand All @@ -50,7 +49,7 @@
"@types/nodemailer": "6.4.6",
"@types/pg": "8.6.5",
"@types/serve-static": "1.15.0",
"@types/websocket": "1.0.5",
"@types/ws": "8.5.3",
"@typescript-eslint/eslint-plugin": "5.44.0",
"@typescript-eslint/parser": "5.44.0",
"babel-jest": "29.3.1",
Expand Down
131 changes: 19 additions & 112 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 7 additions & 8 deletions src/database.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
import consola from 'consola'
import { existsSync, readFileSync } from 'fs'

import fs from 'fs'
import pg from 'pg'

const secretPostgresDbPath = '/run/secrets/postgres_db'
const secretPostgresRoleMaevsiTusdPasswordPath =
'/run/secrets/postgres_role_maevsi-stomper_password'

const pool = new pg.Pool({
database: fs.existsSync(secretPostgresDbPath)
? fs.readFileSync(secretPostgresDbPath, 'utf-8')
database: existsSync(secretPostgresDbPath)
? readFileSync(secretPostgresDbPath, 'utf-8')
: undefined,
host: 'postgres',
password: fs.existsSync(secretPostgresRoleMaevsiTusdPasswordPath)
? fs.readFileSync(secretPostgresRoleMaevsiTusdPasswordPath, 'utf-8')
password: existsSync(secretPostgresRoleMaevsiTusdPasswordPath)
? readFileSync(secretPostgresRoleMaevsiTusdPasswordPath, 'utf-8')
: undefined,
user: 'maevsi_stomper', // lgtm [js/hardcoded-credentials]
})
Expand All @@ -23,9 +22,9 @@ export function ack(id: number, isAcknowledged = true): Promise<unknown> {
pool.query(
'SELECT maevsi.notification_acknowledge($1, $2)',
[id, isAcknowledged],
(err) => {
(err: unknown) => {
if (err) {
consola.error(err)
console.error(err)
reject(err)
return
}
Expand Down
Loading

0 comments on commit 6a16c0d

Please sign in to comment.