set application name
This commit is contained in:
parent
86613ab0d6
commit
af05489171
20
api.ts
20
api.ts
@ -1,10 +1,12 @@
|
|||||||
import { Application, Router } from 'https://deno.land/x/oak/mod.ts';
|
import { Application, Router } from 'https://deno.land/x/oak/mod.ts';
|
||||||
import { Client } from "https://deno.land/x/postgres@v0.17.0/mod.ts";
|
import { Client } from "https://deno.land/x/postgres@v0.17.0/mod.ts";
|
||||||
import { load } from "https://deno.land/std/dotenv/mod.ts";
|
|
||||||
|
|
||||||
const app = new Application();
|
const app = new Application();
|
||||||
const router = new Router();
|
const router = new Router();
|
||||||
|
|
||||||
|
//---------dotenv info-------------
|
||||||
|
import { load } from "https://deno.land/std/dotenv/mod.ts";
|
||||||
|
|
||||||
const env = await load();
|
const env = await load();
|
||||||
const hostname = env["HOSTNAME"];
|
const hostname = env["HOSTNAME"];
|
||||||
const port = env["PORT"];
|
const port = env["PORT"];
|
||||||
@ -13,6 +15,7 @@ const password = env["PASSWORD"];
|
|||||||
const database = env["DATABASE"];
|
const database = env["DATABASE"];
|
||||||
const app_port = env["APP_PORT"];
|
const app_port = env["APP_PORT"];
|
||||||
|
|
||||||
|
|
||||||
// Configure database connection
|
// Configure database connection
|
||||||
const client = new Client({
|
const client = new Client({
|
||||||
hostname:hostname
|
hostname:hostname
|
||||||
@ -20,6 +23,7 @@ const client = new Client({
|
|||||||
,user: user
|
,user: user
|
||||||
,password:password
|
,password:password
|
||||||
,database:database
|
,database:database
|
||||||
|
,applicationName: "pricing guidance"
|
||||||
});
|
});
|
||||||
|
|
||||||
await client.connect();
|
await client.connect();
|
||||||
@ -35,22 +39,14 @@ router.get('/price_info/part_cust/:partcode/:customer', async (ctx) => {
|
|||||||
|
|
||||||
//console.log(partcode)
|
//console.log(partcode)
|
||||||
//console.log(customer)
|
//console.log(customer)
|
||||||
|
|
||||||
const result = await client.queryObject({args: [partcode, customer], text: query} );
|
const result = await client.queryObject({args: [partcode, customer], text: query} );
|
||||||
|
ctx.response.body = result.rows;
|
||||||
for (const row of result.rows) {
|
|
||||||
if (typeof row.season === 'object' && row.season !== null) {
|
|
||||||
for (const year in row.season) {
|
|
||||||
console.log(`${year}: ` + row.season[year].price_usd)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
app.use(router.routes());
|
app.use(router.routes());
|
||||||
app.use(router.allowedMethods());
|
app.use(router.allowedMethods());
|
||||||
|
|
||||||
// Start the server
|
// Start the server
|
||||||
console.log('Server is running on http://localhost:8085');
|
console.log('Server is running on http://usmidsap02:8090');
|
||||||
await app.listen({ port: 8085 });
|
await app.listen({ port: 8090 });
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user