squash history
This commit is contained in:
commit
ff8694a9cc
5
.env.example
Normal file
5
.env.example
Normal file
@ -0,0 +1,5 @@
|
||||
DB_USER=
|
||||
DB_DATABASE=
|
||||
DB_PASSWORD=
|
||||
DB_HOSTNAME=
|
||||
DB_PORT=
|
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
*.swp
|
||||
.env
|
9
get.sql
Normal file
9
get.sql
Normal file
@ -0,0 +1,9 @@
|
||||
SELECT
|
||||
"Description" descr
|
||||
,"Amount" amount
|
||||
,id
|
||||
FROM
|
||||
tpsv.dcard_mapped
|
||||
ORDER BY
|
||||
"Trans. Date" Desc
|
||||
,id Desc
|
24
index.js
Normal file
24
index.js
Normal file
@ -0,0 +1,24 @@
|
||||
import { Client } from "https://deno.land/x/postgres/mod.ts";
|
||||
//import { Client } from "https://raw.githubusercontent.com/snsinfu/deno-postgres/feat-scram/mod.ts";
|
||||
import { config } from "https://deno.land/x/dotenv/mod.ts";
|
||||
import CustomServer from "./server.tsx";
|
||||
|
||||
//load the .env file
|
||||
const env = config();
|
||||
|
||||
const client = new Client({
|
||||
user: env.DB_USER,
|
||||
database: env.DB_DATABASE,
|
||||
password: env.DB_PASSWORD,
|
||||
hostname: env.DB_HOSTNAME,
|
||||
port: env.DB_PORT,
|
||||
});
|
||||
await client.connect();
|
||||
|
||||
const sql = await Deno.readTextFile("get.sql");
|
||||
const object_result = await client.queryObject(sql);
|
||||
console.log(object_result.rows); // [{id: 1, name: 'Carlos'}, {id: 2, name: 'John'}, ...]
|
||||
|
||||
await client.end();
|
||||
|
||||
CustomServer(object_result.rows, 8085);
|
10
readme.md
Normal file
10
readme.md
Normal file
@ -0,0 +1,10 @@
|
||||
sometimes you need to run `deno cache -r index.js` due to stale code sitting in the cache.
|
||||
The database uses a cert to encrypt traffic. if the cert is expired it will need dealt with.
|
||||
|
||||
otherwise...
|
||||
* install deno
|
||||
* curl -fsSL https://deno.land/x/install/install.sh | sh
|
||||
* copy the .bashrc stuff per the instructions at the end of the install
|
||||
* exec bash to use the .bashrc changes
|
||||
* copy `.env.example` to `.env` and update the parameters in it
|
||||
* run `deno run --allow-read --allow-net --unstable --allow-env index.js`
|
4
scripts.yaml
Normal file
4
scripts.yaml
Normal file
@ -0,0 +1,4 @@
|
||||
# 1.) "install" velociraptor 'deno install -qA -n vr https://deno.land/x/velociraptor@1.0.0-beta.16/cli.ts'
|
||||
# 2.) run script from this yaml in terminal 'vr dev'
|
||||
scripts:
|
||||
dev: "deno run -A --watch --unstable index.js"
|
91
server.tsx
Normal file
91
server.tsx
Normal file
@ -0,0 +1,91 @@
|
||||
//// "Oak" server
|
||||
import { Application, Router } from "https://deno.land/x/oak/mod.ts";
|
||||
|
||||
//// "React" stuff
|
||||
// @deno-types="https://deno.land/x/servest/types/react/index.d.ts"
|
||||
import React from "https://dev.jspm.io/react/index.js";
|
||||
// @deno-types="https://deno.land/x/servest/types/react-dom/server/index.d.ts"
|
||||
import ReactDOMServer from "https://dev.jspm.io/react-dom/server.js";
|
||||
|
||||
//attemp conversion to a table
|
||||
|
||||
const CustomItemList = (props: any) => {
|
||||
return (
|
||||
<div className="ItemList" key={1}>
|
||||
<h3>Items</h3>
|
||||
<h4>{props.items.length} total</h4>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Descritpion</th>
|
||||
<th>Amount</th>
|
||||
<th>Log ID</th>
|
||||
</tr>
|
||||
</thead>
|
||||
{props.items.map((inItem: any) => {
|
||||
return (
|
||||
<CustomItem
|
||||
description={inItem.descr}
|
||||
amount={inItem.amount}
|
||||
key={inItem.id}
|
||||
id={inItem.id}
|
||||
/>
|
||||
);
|
||||
})}
|
||||
</table>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
const CustomItem = (props: any) => {
|
||||
return (
|
||||
<tr className="Item" key={props.id}>
|
||||
<td>{props.description}</td>
|
||||
<td>{props.amount}</td>
|
||||
<td>{props.id}</td>
|
||||
<td><button>Map</button></td>
|
||||
</tr>
|
||||
);
|
||||
};
|
||||
|
||||
/*
|
||||
const CustomItem = (props: any) => {
|
||||
return (
|
||||
<div className="Item" key={props.id}>
|
||||
<div className="Item_Feature" key={props.id + props.description}>
|
||||
<span>Description:</span> <strong>{props.description}</strong>
|
||||
</div>
|
||||
<div className="Item_Feature" key={props.id + props.amount}>
|
||||
<span>Amount:</span> <strong>{props.amount}</strong>
|
||||
</div>
|
||||
<div className="Item_Feature" key={props.id + "i"}>
|
||||
<span>Key:</span> <strong>{props.id}</strong>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
*/
|
||||
|
||||
export default (inState: any, inPort: number) => {
|
||||
let app, router;
|
||||
let state: any;
|
||||
|
||||
router = new Router();
|
||||
router.get("/api/all", (ctx: any) => {
|
||||
ctx.response.body = JSON.stringify(inState);
|
||||
});
|
||||
router.get("/", (ctx: any) => {
|
||||
ctx.response.body = ReactDOMServer.renderToString(
|
||||
<html>
|
||||
<head></head>
|
||||
<body>
|
||||
<h1>Welcome!</h1>
|
||||
<CustomItemList items={inState} />
|
||||
</body>
|
||||
</html>
|
||||
);
|
||||
});
|
||||
app = new Application();
|
||||
app.use(router.routes());
|
||||
app.listen({ port: inPort });
|
||||
};
|
Loading…
Reference in New Issue
Block a user