Feature/api paramyxrx (#24)
* Update .gitignore * Finalize server and add endpoints for paramyx app
This commit is contained in:
parent
eb5d1a63a3
commit
8cebefe5a6
12 changed files with 1882 additions and 1541 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -12,6 +12,8 @@ dist
|
||||||
dist-ssr
|
dist-ssr
|
||||||
*.local
|
*.local
|
||||||
|
|
||||||
|
.env
|
||||||
|
|
||||||
# Editor directories and files
|
# Editor directories and files
|
||||||
.vscode/*
|
.vscode/*
|
||||||
!.vscode/extensions.json
|
!.vscode/extensions.json
|
||||||
|
|
|
||||||
156
api/package-lock.json
generated
156
api/package-lock.json
generated
|
|
@ -10,7 +10,8 @@
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"cors": "^2.8.5",
|
"cors": "^2.8.5",
|
||||||
"dotenv": "^16.5.0",
|
"dotenv": "^16.5.0",
|
||||||
"express": "^5.2.0"
|
"express": "^5.2.0",
|
||||||
|
"pg": "^8.17.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"nodemon": "^3.1.10"
|
"nodemon": "^3.1.10"
|
||||||
|
|
@ -844,6 +845,96 @@
|
||||||
"node": ">=16"
|
"node": ">=16"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/pg": {
|
||||||
|
"version": "8.17.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/pg/-/pg-8.17.1.tgz",
|
||||||
|
"integrity": "sha512-EIR+jXdYNSMOrpRp7g6WgQr7SaZNZfS7IzZIO0oTNEeibq956JxeD15t3Jk3zZH0KH8DmOIx38qJfQenoE8bXQ==",
|
||||||
|
"license": "MIT",
|
||||||
|
"peer": true,
|
||||||
|
"dependencies": {
|
||||||
|
"pg-connection-string": "^2.10.0",
|
||||||
|
"pg-pool": "^3.11.0",
|
||||||
|
"pg-protocol": "^1.11.0",
|
||||||
|
"pg-types": "2.2.0",
|
||||||
|
"pgpass": "1.0.5"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 16.0.0"
|
||||||
|
},
|
||||||
|
"optionalDependencies": {
|
||||||
|
"pg-cloudflare": "^1.3.0"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"pg-native": ">=3.0.1"
|
||||||
|
},
|
||||||
|
"peerDependenciesMeta": {
|
||||||
|
"pg-native": {
|
||||||
|
"optional": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/pg-cloudflare": {
|
||||||
|
"version": "1.3.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/pg-cloudflare/-/pg-cloudflare-1.3.0.tgz",
|
||||||
|
"integrity": "sha512-6lswVVSztmHiRtD6I8hw4qP/nDm1EJbKMRhf3HCYaqud7frGysPv7FYJ5noZQdhQtN2xJnimfMtvQq21pdbzyQ==",
|
||||||
|
"license": "MIT",
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"node_modules/pg-connection-string": {
|
||||||
|
"version": "2.10.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/pg-connection-string/-/pg-connection-string-2.10.0.tgz",
|
||||||
|
"integrity": "sha512-ur/eoPKzDx2IjPaYyXS6Y8NSblxM7X64deV2ObV57vhjsWiwLvUD6meukAzogiOsu60GO8m/3Cb6FdJsWNjwXg==",
|
||||||
|
"license": "MIT"
|
||||||
|
},
|
||||||
|
"node_modules/pg-int8": {
|
||||||
|
"version": "1.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/pg-int8/-/pg-int8-1.0.1.tgz",
|
||||||
|
"integrity": "sha512-WCtabS6t3c8SkpDBUlb1kjOs7l66xsGdKpIPZsg4wR+B3+u9UAum2odSsF9tnvxg80h4ZxLWMy4pRjOsFIqQpw==",
|
||||||
|
"license": "ISC",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=4.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/pg-pool": {
|
||||||
|
"version": "3.11.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/pg-pool/-/pg-pool-3.11.0.tgz",
|
||||||
|
"integrity": "sha512-MJYfvHwtGp870aeusDh+hg9apvOe2zmpZJpyt+BMtzUWlVqbhFmMK6bOBXLBUPd7iRtIF9fZplDc7KrPN3PN7w==",
|
||||||
|
"license": "MIT",
|
||||||
|
"peerDependencies": {
|
||||||
|
"pg": ">=8.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/pg-protocol": {
|
||||||
|
"version": "1.11.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/pg-protocol/-/pg-protocol-1.11.0.tgz",
|
||||||
|
"integrity": "sha512-pfsxk2M9M3BuGgDOfuy37VNRRX3jmKgMjcvAcWqNDpZSf4cUmv8HSOl5ViRQFsfARFn0KuUQTgLxVMbNq5NW3g==",
|
||||||
|
"license": "MIT"
|
||||||
|
},
|
||||||
|
"node_modules/pg-types": {
|
||||||
|
"version": "2.2.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/pg-types/-/pg-types-2.2.0.tgz",
|
||||||
|
"integrity": "sha512-qTAAlrEsl8s4OiEQY69wDvcMIdQN6wdz5ojQiOy6YRMuynxenON0O5oCpJI6lshc6scgAY8qvJ2On/p+CXY0GA==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"pg-int8": "1.0.1",
|
||||||
|
"postgres-array": "~2.0.0",
|
||||||
|
"postgres-bytea": "~1.0.0",
|
||||||
|
"postgres-date": "~1.0.4",
|
||||||
|
"postgres-interval": "^1.1.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=4"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/pgpass": {
|
||||||
|
"version": "1.0.5",
|
||||||
|
"resolved": "https://registry.npmjs.org/pgpass/-/pgpass-1.0.5.tgz",
|
||||||
|
"integrity": "sha512-FdW9r/jQZhSeohs1Z3sI1yxFQNFvMcnmfuj4WBMUTxOrAyLMaTcE1aAMBiTlbMNaXvBCQuVi0R7hd8udDSP7ug==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"split2": "^4.1.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/picomatch": {
|
"node_modules/picomatch": {
|
||||||
"version": "2.3.1",
|
"version": "2.3.1",
|
||||||
"resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz",
|
"resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz",
|
||||||
|
|
@ -857,6 +948,45 @@
|
||||||
"url": "https://github.com/sponsors/jonschlinkert"
|
"url": "https://github.com/sponsors/jonschlinkert"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/postgres-array": {
|
||||||
|
"version": "2.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/postgres-array/-/postgres-array-2.0.0.tgz",
|
||||||
|
"integrity": "sha512-VpZrUqU5A69eQyW2c5CA1jtLecCsN2U/bD6VilrFDWq5+5UIEVO7nazS3TEcHf1zuPYO/sqGvUvW62g86RXZuA==",
|
||||||
|
"license": "MIT",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=4"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/postgres-bytea": {
|
||||||
|
"version": "1.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/postgres-bytea/-/postgres-bytea-1.0.1.tgz",
|
||||||
|
"integrity": "sha512-5+5HqXnsZPE65IJZSMkZtURARZelel2oXUEO8rH83VS/hxH5vv1uHquPg5wZs8yMAfdv971IU+kcPUczi7NVBQ==",
|
||||||
|
"license": "MIT",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=0.10.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/postgres-date": {
|
||||||
|
"version": "1.0.7",
|
||||||
|
"resolved": "https://registry.npmjs.org/postgres-date/-/postgres-date-1.0.7.tgz",
|
||||||
|
"integrity": "sha512-suDmjLVQg78nMK2UZ454hAG+OAW+HQPZ6n++TNDUX+L0+uUlLywnoxJKDou51Zm+zTCjrCl0Nq6J9C5hP9vK/Q==",
|
||||||
|
"license": "MIT",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=0.10.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/postgres-interval": {
|
||||||
|
"version": "1.2.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/postgres-interval/-/postgres-interval-1.2.0.tgz",
|
||||||
|
"integrity": "sha512-9ZhXKM/rw350N1ovuWHbGxnGh/SNJ4cnxHiM0rxE4VN41wsg8P8zWn9hv/buK00RP4WvlOyr/RBDiptyxVbkZQ==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"xtend": "^4.0.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=0.10.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/proxy-addr": {
|
"node_modules/proxy-addr": {
|
||||||
"version": "2.0.7",
|
"version": "2.0.7",
|
||||||
"resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz",
|
"resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz",
|
||||||
|
|
@ -878,9 +1008,9 @@
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"node_modules/qs": {
|
"node_modules/qs": {
|
||||||
"version": "6.14.0",
|
"version": "6.14.1",
|
||||||
"resolved": "https://registry.npmjs.org/qs/-/qs-6.14.0.tgz",
|
"resolved": "https://registry.npmjs.org/qs/-/qs-6.14.1.tgz",
|
||||||
"integrity": "sha512-YWWTjgABSKcvs/nWBi9PycY/JiPJqOD4JA6o9Sej2AtvSGarXxKC3OQSk4pAarbdQlKAh5D4FCQkJNkW+GAn3w==",
|
"integrity": "sha512-4EK3+xJl8Ts67nLYNwqw/dsFVnCf+qR7RgXSK9jEEm9unao3njwMDdmsdvoKBKHzxd7tCYz5e5M+SnMjdtXGQQ==",
|
||||||
"license": "BSD-3-Clause",
|
"license": "BSD-3-Clause",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"side-channel": "^1.1.0"
|
"side-channel": "^1.1.0"
|
||||||
|
|
@ -1112,6 +1242,15 @@
|
||||||
"node": ">=10"
|
"node": ">=10"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/split2": {
|
||||||
|
"version": "4.2.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/split2/-/split2-4.2.0.tgz",
|
||||||
|
"integrity": "sha512-UcjcJOWknrNkF6PLX83qcHM6KHgVKNkV62Y8a5uYDVv9ydGQVwAHMKqHdJje1VTWpljG0WYpCDhrCdAOYH4TWg==",
|
||||||
|
"license": "ISC",
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 10.x"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/statuses": {
|
"node_modules/statuses": {
|
||||||
"version": "2.0.2",
|
"version": "2.0.2",
|
||||||
"resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.2.tgz",
|
||||||
|
|
@ -1210,6 +1349,15 @@
|
||||||
"resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
|
||||||
"integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==",
|
"integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==",
|
||||||
"license": "ISC"
|
"license": "ISC"
|
||||||
|
},
|
||||||
|
"node_modules/xtend": {
|
||||||
|
"version": "4.0.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz",
|
||||||
|
"integrity": "sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==",
|
||||||
|
"license": "MIT",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=0.4"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,8 @@
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"cors": "^2.8.5",
|
"cors": "^2.8.5",
|
||||||
"dotenv": "^16.5.0",
|
"dotenv": "^16.5.0",
|
||||||
"express": "^5.2.0"
|
"express": "^5.2.0",
|
||||||
|
"pg": "^8.17.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"nodemon": "^3.1.10"
|
"nodemon": "^3.1.10"
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,9 @@
|
||||||
import express from 'express';
|
import express from 'express';
|
||||||
import cors from 'cors';
|
import cors from 'cors';
|
||||||
import dotenv from 'dotenv';
|
import dotenv from 'dotenv';
|
||||||
|
import { medicationRouter } from './services/medications/index.js';
|
||||||
|
import { shiftRunQuery } from './services/shiftConnection.js';
|
||||||
dotenv.config();
|
dotenv.config();
|
||||||
import { postgresServices } from './services/postgres/postgresServices.js';
|
|
||||||
|
|
||||||
const app = express();
|
const app = express();
|
||||||
|
|
||||||
|
|
@ -15,9 +16,28 @@ const corsOptions = {
|
||||||
};
|
};
|
||||||
|
|
||||||
app.use(cors(corsOptions));
|
app.use(cors(corsOptions));
|
||||||
|
app.use(express.json({ limit: '10mb' }));
|
||||||
|
|
||||||
|
app.use(express.json());
|
||||||
|
|
||||||
|
const apiRouter = express.Router();
|
||||||
|
|
||||||
|
apiRouter.use('/medication', medicationRouter);
|
||||||
|
|
||||||
app.get("/api", (req, res) => {
|
app.get("/api", (req, res) => {
|
||||||
res.json({ fruits: ["apple", "orange", "banana"] });
|
res.json('Welcome to Shift Sync API');
|
||||||
|
});
|
||||||
|
|
||||||
|
app.use('/api', apiRouter);
|
||||||
|
|
||||||
|
app.get('/db-health', async (req, res) => {
|
||||||
|
try {
|
||||||
|
const result = await shiftRunQuery('SELECT NOW()');
|
||||||
|
res.json({ connected: true, time: result.rows[0].now });
|
||||||
|
} catch (err) {
|
||||||
|
console.error(err);
|
||||||
|
res.status(500).json({ connected: false, error: err.message });
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
app.listen(5172, () => {
|
app.listen(5172, () => {
|
||||||
|
|
|
||||||
7
api/services/index.js
Normal file
7
api/services/index.js
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
import {
|
||||||
|
medicationOperations
|
||||||
|
} from './operations/medications.js';
|
||||||
|
|
||||||
|
export const databaseServices = {
|
||||||
|
...medicationOperations
|
||||||
|
}
|
||||||
30
api/services/medications/index.js
Normal file
30
api/services/medications/index.js
Normal file
|
|
@ -0,0 +1,30 @@
|
||||||
|
import express from 'express';
|
||||||
|
import { databaseServices } from '../index.js';
|
||||||
|
|
||||||
|
export const medicationRouter = express.Router();
|
||||||
|
|
||||||
|
medicationRouter.get('/', async (req, res) => {
|
||||||
|
let data;
|
||||||
|
try {
|
||||||
|
data = await databaseServices.getMedications();
|
||||||
|
res.status(200);
|
||||||
|
} catch (err) {
|
||||||
|
data = { Error: err?.message };
|
||||||
|
res.status(500);
|
||||||
|
} finally {
|
||||||
|
res.send(data);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
medicationRouter.get('/base/', async (req, res) => {
|
||||||
|
let data;
|
||||||
|
try {
|
||||||
|
data = await databaseServices.getBaseMedications();
|
||||||
|
res.status(200);
|
||||||
|
} catch (err) {
|
||||||
|
data = { Error: err?.message };
|
||||||
|
res.status(500);
|
||||||
|
} finally {
|
||||||
|
res.send(data);
|
||||||
|
}
|
||||||
|
});
|
||||||
68
api/services/operations/helpers/medications.js
Normal file
68
api/services/operations/helpers/medications.js
Normal file
|
|
@ -0,0 +1,68 @@
|
||||||
|
import { paramyxRunQuery } from '../../paramyxConnection.js';
|
||||||
|
|
||||||
|
export const medicationHelpers = {
|
||||||
|
getBaseMedications: async () => {
|
||||||
|
const [medList, medRoutes] = await Promise.all([
|
||||||
|
paramyxRunQuery('SELECT * FROM medications'),
|
||||||
|
paramyxRunQuery('SELECT * FROM medication_routes')
|
||||||
|
]);
|
||||||
|
|
||||||
|
const medMap = {};
|
||||||
|
|
||||||
|
medList.forEach((med) => {
|
||||||
|
medMap[med.id] = {
|
||||||
|
id: med.id,
|
||||||
|
generic: med.generic,
|
||||||
|
trade: med.trade,
|
||||||
|
system: med.system,
|
||||||
|
adult: {
|
||||||
|
hasIV: false,
|
||||||
|
hasIO: false,
|
||||||
|
hasIM: false,
|
||||||
|
hasIN: false,
|
||||||
|
hasPO: false,
|
||||||
|
hasSL: false,
|
||||||
|
hasPR: false,
|
||||||
|
hasNEB: false,
|
||||||
|
hasET: false,
|
||||||
|
hasSGA: false
|
||||||
|
},
|
||||||
|
pediatric: {
|
||||||
|
hasIV: false,
|
||||||
|
hasIO: false,
|
||||||
|
hasIM: false,
|
||||||
|
hasIN: false,
|
||||||
|
hasPO: false,
|
||||||
|
hasSL: false,
|
||||||
|
hasPR: false,
|
||||||
|
hasNEB: false,
|
||||||
|
hasET: false,
|
||||||
|
hasSGA: false
|
||||||
|
}
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
medRoutes.forEach((route) => {
|
||||||
|
const medId = route.medication_id;
|
||||||
|
|
||||||
|
if (medMap[medId]) {
|
||||||
|
const target = route.is_adult ? medMap[medId].adult : medMap[medId].pediatric;
|
||||||
|
|
||||||
|
target.hasIV = !!route.intravenous;
|
||||||
|
target.hasIO = !!route.intraosseous;
|
||||||
|
target.hasIM = !!route.intramuscular;
|
||||||
|
target.hasIN = !!route.intranasal;
|
||||||
|
target.hasPO = !!route.oral;
|
||||||
|
target.hasSL = !!route.sublingual;
|
||||||
|
target.hasPR = !!route.rectal;
|
||||||
|
target.hasNEB = !!route.nebulizer;
|
||||||
|
target.hasET = !!route.endotracheal;
|
||||||
|
target.hasSGA = !!route.supraglottic;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const fullMedList = Object.values(medMap);
|
||||||
|
|
||||||
|
return fullMedList;
|
||||||
|
}
|
||||||
|
};
|
||||||
27
api/services/operations/medications.js
Normal file
27
api/services/operations/medications.js
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
import { paramyxRunQuery } from '../paramyxConnection.js';
|
||||||
|
import { medicationHelpers } from './helpers/medications.js'
|
||||||
|
|
||||||
|
const getMedications = async () => {
|
||||||
|
try {
|
||||||
|
const dataResp = await paramyxRunQuery('SELECT * FROM medications');
|
||||||
|
return dataResp;
|
||||||
|
} catch (err) {
|
||||||
|
console.log('GET MEDICATIONS ERROR: ', err);
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const getBaseMedications = async () => {
|
||||||
|
try {
|
||||||
|
const dataResp = medicationHelpers.getBaseMedications();
|
||||||
|
return dataResp;
|
||||||
|
} catch (err) {
|
||||||
|
console.log('GET MEDICATIONS ERROR: ', err);
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const medicationOperations = {
|
||||||
|
getMedications,
|
||||||
|
getBaseMedications
|
||||||
|
}
|
||||||
23
api/services/paramyxConnection.js
Normal file
23
api/services/paramyxConnection.js
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
import { Pool } from 'pg';
|
||||||
|
import 'dotenv/config';
|
||||||
|
|
||||||
|
const poolCreds = {
|
||||||
|
host: process.env.POSTGRES_HOST,
|
||||||
|
database: process.env.POSTGRES_DB_PARAMYXRX,
|
||||||
|
port: process.env.POSTGRES_PORT,
|
||||||
|
user: process.env.POSTGRES_USER,
|
||||||
|
password: process.env.POSTGRES_PASSWORD
|
||||||
|
};
|
||||||
|
|
||||||
|
const pool = new Pool(poolCreds);
|
||||||
|
|
||||||
|
export const paramyxRunQuery = async (query, params = []) => {
|
||||||
|
const client = await pool.connect();
|
||||||
|
|
||||||
|
try {
|
||||||
|
const pgQueryResponse = await client.query(query, params);
|
||||||
|
return pgQueryResponse?.rows || [];
|
||||||
|
} finally {
|
||||||
|
client.release();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,8 +0,0 @@
|
||||||
export const postgresServices = {
|
|
||||||
getUsers: async (args) => {
|
|
||||||
|
|
||||||
},
|
|
||||||
getDepartments: async (args) => {
|
|
||||||
|
|
||||||
}
|
|
||||||
};
|
|
||||||
23
api/services/shiftConnection.js
Normal file
23
api/services/shiftConnection.js
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
import { Pool } from 'pg';
|
||||||
|
import 'dotenv/config';
|
||||||
|
|
||||||
|
const poolCreds = {
|
||||||
|
host: process.env.POSTGRES_HOST,
|
||||||
|
database: process.env.POSTGRES_DB_SHIFT,
|
||||||
|
port: process.env.POSTGRES_PORT,
|
||||||
|
user: process.env.POSTGRES_USER,
|
||||||
|
password: process.env.POSTGRES_PASSWORD
|
||||||
|
};
|
||||||
|
|
||||||
|
const pool = new Pool(poolCreds);
|
||||||
|
|
||||||
|
export const shiftRunQuery = async (query, params = []) => {
|
||||||
|
const client = await pool.connect();
|
||||||
|
|
||||||
|
try {
|
||||||
|
const pgQueryResponse = await client.query(query, params);
|
||||||
|
return pgQueryResponse?.rows || [];
|
||||||
|
} finally {
|
||||||
|
client.release();
|
||||||
|
}
|
||||||
|
}
|
||||||
6
package-lock.json
generated
6
package-lock.json
generated
|
|
@ -1050,9 +1050,9 @@
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"node_modules/qs": {
|
"node_modules/qs": {
|
||||||
"version": "6.14.0",
|
"version": "6.14.1",
|
||||||
"resolved": "https://registry.npmjs.org/qs/-/qs-6.14.0.tgz",
|
"resolved": "https://registry.npmjs.org/qs/-/qs-6.14.1.tgz",
|
||||||
"integrity": "sha512-YWWTjgABSKcvs/nWBi9PycY/JiPJqOD4JA6o9Sej2AtvSGarXxKC3OQSk4pAarbdQlKAh5D4FCQkJNkW+GAn3w==",
|
"integrity": "sha512-4EK3+xJl8Ts67nLYNwqw/dsFVnCf+qR7RgXSK9jEEm9unao3njwMDdmsdvoKBKHzxd7tCYz5e5M+SnMjdtXGQQ==",
|
||||||
"license": "BSD-3-Clause",
|
"license": "BSD-3-Clause",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"side-channel": "^1.1.0"
|
"side-channel": "^1.1.0"
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue