upgrade to node 16, add search by full product id (#84)

This commit is contained in:
Anders Gustafsson
2021-11-02 10:57:11 +01:00
committed by GitHub
parent 043f1455cf
commit 0afe689200
10 changed files with 260 additions and 2892 deletions
+1 -1
View File
@@ -1 +1 @@
v14.17.0
v16.12
+1 -1
View File
@@ -1,5 +1,5 @@
# Uses the node base image with the latest LTS version
FROM node:14.17.0
FROM node:16.12
# Informs Docker that the container listens on the
# specified network ports at runtime
EXPOSE 4000
+1 -1
View File
@@ -1,5 +1,5 @@
# Uses the node base image with the latest LTS version
FROM node:14.17.0
FROM node:16.12.0
# Informs Docker that the container listens on the
# specified network ports at runtime
EXPOSE 4000
+227 -2883
View File
File diff suppressed because it is too large Load Diff
+4
View File
@@ -10,6 +10,9 @@
"unit:dev": "jest --watch src/__test__/unit.test.ts",
"test:manual": "cd manual-tests && ts-node test-scopes.ts"
},
"engines": {
"node": ">=16.12 <17"
},
"author": "",
"license": "ISC",
"dependencies": {
@@ -28,6 +31,7 @@
"graphql-scalars": "^1.10.0",
"jsonwebtoken": "^8.5.1",
"jwk-to-pem": "^2.0.5",
"knex": "^0.95.12",
"knex-stringcase": "^1.4.5",
"nodemon": "^2.0.12",
"pg": "^8.7.1",
+2 -2
View File
@@ -8,7 +8,7 @@ import {
StartedTestContainer,
Wait,
} from 'testcontainers';
import Knex from 'knex';
import { Knex, knex } from 'knex';
// import knexTinyLogger from 'knex-tiny-logger';
export const DbNetworkName = 'postgres_container';
@@ -26,7 +26,7 @@ const runFile = async (db, file) => {
const createKnexDb = (host: string, mappedPort: number, database: string) => {
const connection = `postgresql://testuser:test@${host}:${mappedPort}/${database}`;
// console.log(`connection`, connection);
const db = Knex({
const db = knex({
client: 'pg',
connection: connection,
pool: { min: 0 },
+1
View File
@@ -5,6 +5,7 @@
"requires": true,
"packages": {
"": {
"name": "db_generator",
"version": "1.0.0",
"license": "ISC",
"dependencies": {
+8
View File
@@ -240,6 +240,14 @@ export class ProductAPI extends BaseSQLDataSource {
.then((data) => data.rows.map((row) => this.createProductFromRow(row)));
}
async searchByCompleteProductId(q: string): Promise<Maybe<Product>> {
const queryAsNumber = Number(q.replaceAll('%', ''));
if (!queryAsNumber) {
return;
}
return this.getProduct(queryAsNumber);
}
async searchByBatch(name: string): Promise<Array<Batch>> {
return this.searchByFieldValue<Batch>(name, 36, 'batch');
}
+12 -1
View File
@@ -84,7 +84,18 @@ async function getProductsSearchResult(
const prods = Promise.all([
prodApi.searchByName(q),
prodApi.searchByArtNo(q),
]).then((d) => d.flat());
prodApi.searchByCompleteProductId(q),
]).then((d) => {
// flatten, remove falsy (each searchBy... can return undefined above)
// and finally remove duplicates.
const products = {} as { [key: string]: Product };
d.flat().forEach((product) => {
if (product && !products[product.id]) {
products[product.id] = product;
}
});
return Object.values(products);
});
return {
q: q,
+1 -1
View File
@@ -1,6 +1,6 @@
{
"compilerOptions": {
"target": "es2020",
"target": "es2021",
"module": "commonjs",
"esModuleInterop": true,
"experimentalDecorators": true,