diff --git a/api.ts b/api.ts index 95d37f3..7f94305 100644 --- a/api.ts +++ b/api.ts @@ -35,29 +35,16 @@ const query_dseg = await Deno.readTextFile("sql/get_dseg.pg.sql"); // exact scenario for existing codes router.get('/code_price/:billcode/:shipcode/:partcode/:qty', async (ctx) => { - - const partcode = ctx.params.partcode; - const billcode = ctx.params.billcode; - const shipcode = ctx.params.shipcode; - const qty = ctx.params.qty; - + const { billcode, shipcode, partcode, qty } = ctx.params; const result = await client.queryObject({args: [billcode, shipcode, partcode, qty], text: query} ); - const procd = apply_guidance(result.rows[0]["doc"]) - ctx.response.body = procd; + ctx.response.body = apply_guidance(result.rows[0]["doc"]); }); // specific customres codes but generic style code and data segment to accomodate custom colors and branding router.get('/dseg_price/:billcode/:shipcode/:stlc/:dseg/:qty', async (ctx) => { - - const stlc = ctx.params.stlc; - const dseg = ctx.params.dseg; - const billcode = ctx.params.billcode; - const shipcode = ctx.params.shipcode; - const qty = ctx.params.qty; - + const { billcode, shipcode, stlc, dseg, qty } = ctx.params; const result = await client.queryObject({args: [billcode, shipcode, stlc, dseg, qty], text: query_dseg} ); - const procd = apply_guidance(result.rows[0]["doc"]) - ctx.response.body = procd; + ctx.response.body = apply_guidance(result.rows[0]["doc"]); }); app.use(router.routes()); app.use(router.allowedMethods());