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
|
# 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
|
# Informs Docker that the container listens on the
|
||||||
# specified network ports at runtime
|
# specified network ports at runtime
|
||||||
EXPOSE 4000
|
EXPOSE 4000
|
||||||
|
|||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
# Uses the node base image with the latest LTS version
|
# 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
|
# Informs Docker that the container listens on the
|
||||||
# specified network ports at runtime
|
# specified network ports at runtime
|
||||||
EXPOSE 4000
|
EXPOSE 4000
|
||||||
|
|||||||
Generated
+227
-2883
File diff suppressed because it is too large
Load Diff
@@ -10,6 +10,9 @@
|
|||||||
"unit:dev": "jest --watch src/__test__/unit.test.ts",
|
"unit:dev": "jest --watch src/__test__/unit.test.ts",
|
||||||
"test:manual": "cd manual-tests && ts-node test-scopes.ts"
|
"test:manual": "cd manual-tests && ts-node test-scopes.ts"
|
||||||
},
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=16.12 <17"
|
||||||
|
},
|
||||||
"author": "",
|
"author": "",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@@ -28,6 +31,7 @@
|
|||||||
"graphql-scalars": "^1.10.0",
|
"graphql-scalars": "^1.10.0",
|
||||||
"jsonwebtoken": "^8.5.1",
|
"jsonwebtoken": "^8.5.1",
|
||||||
"jwk-to-pem": "^2.0.5",
|
"jwk-to-pem": "^2.0.5",
|
||||||
|
"knex": "^0.95.12",
|
||||||
"knex-stringcase": "^1.4.5",
|
"knex-stringcase": "^1.4.5",
|
||||||
"nodemon": "^2.0.12",
|
"nodemon": "^2.0.12",
|
||||||
"pg": "^8.7.1",
|
"pg": "^8.7.1",
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import {
|
|||||||
StartedTestContainer,
|
StartedTestContainer,
|
||||||
Wait,
|
Wait,
|
||||||
} from 'testcontainers';
|
} from 'testcontainers';
|
||||||
import Knex from 'knex';
|
import { Knex, knex } from 'knex';
|
||||||
// import knexTinyLogger from 'knex-tiny-logger';
|
// import knexTinyLogger from 'knex-tiny-logger';
|
||||||
|
|
||||||
export const DbNetworkName = 'postgres_container';
|
export const DbNetworkName = 'postgres_container';
|
||||||
@@ -26,7 +26,7 @@ const runFile = async (db, file) => {
|
|||||||
const createKnexDb = (host: string, mappedPort: number, database: string) => {
|
const createKnexDb = (host: string, mappedPort: number, database: string) => {
|
||||||
const connection = `postgresql://testuser:test@${host}:${mappedPort}/${database}`;
|
const connection = `postgresql://testuser:test@${host}:${mappedPort}/${database}`;
|
||||||
// console.log(`connection`, connection);
|
// console.log(`connection`, connection);
|
||||||
const db = Knex({
|
const db = knex({
|
||||||
client: 'pg',
|
client: 'pg',
|
||||||
connection: connection,
|
connection: connection,
|
||||||
pool: { min: 0 },
|
pool: { min: 0 },
|
||||||
|
|||||||
+1
@@ -5,6 +5,7 @@
|
|||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
|
"name": "db_generator",
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|||||||
@@ -240,6 +240,14 @@ export class ProductAPI extends BaseSQLDataSource {
|
|||||||
.then((data) => data.rows.map((row) => this.createProductFromRow(row)));
|
.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>> {
|
async searchByBatch(name: string): Promise<Array<Batch>> {
|
||||||
return this.searchByFieldValue<Batch>(name, 36, 'batch');
|
return this.searchByFieldValue<Batch>(name, 36, 'batch');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -84,7 +84,18 @@ async function getProductsSearchResult(
|
|||||||
const prods = Promise.all([
|
const prods = Promise.all([
|
||||||
prodApi.searchByName(q),
|
prodApi.searchByName(q),
|
||||||
prodApi.searchByArtNo(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 {
|
return {
|
||||||
q: q,
|
q: q,
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"target": "es2020",
|
"target": "es2021",
|
||||||
"module": "commonjs",
|
"module": "commonjs",
|
||||||
"esModuleInterop": true,
|
"esModuleInterop": true,
|
||||||
"experimentalDecorators": true,
|
"experimentalDecorators": true,
|
||||||
|
|||||||
Reference in New Issue
Block a user