upgrade to node 16, add search by full product id (#84)
This commit is contained in:
+1
-1
@@ -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
@@ -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
|
||||
|
||||
Generated
+229
-2885
File diff suppressed because it is too large
Load Diff
@@ -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",
|
||||
|
||||
@@ -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
@@ -5,6 +5,7 @@
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "db_generator",
|
||||
"version": "1.0.0",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
|
||||
@@ -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');
|
||||
}
|
||||
|
||||
@@ -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
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "es2020",
|
||||
"target": "es2021",
|
||||
"module": "commonjs",
|
||||
"esModuleInterop": true,
|
||||
"experimentalDecorators": true,
|
||||
|
||||
Reference in New Issue
Block a user