start fastify

This commit is contained in:
2023-06-14 22:09:43 -04:00
parent f7a35a1bde
commit a0e3df17c9
6 changed files with 433 additions and 18 deletions
+10
View File
@@ -0,0 +1,10 @@
import postgres from 'postgres';
import {parse} from 'csv-parse/sync';
export const sql = postgres({
host: '127.0.0.1',
port: 5432,
user: 'postgres',
password: 'buginoo'
});
+19 -2
View File
@@ -1,7 +1,24 @@
import { ingestOptions, ingestStocks, sql } from './ingest';
//import { ingestOptions, ingestStocks, } from './ingest';
import { sql } from './db.js';
/*
const sourceDataDir = '/home/avraham/programming/calendar-optimizer-csv';
//await ingestStocks(sourceDataDir);
await ingestOptions(sourceDataDir);
*/
import fastify from 'fastify'
const server = fastify()
server.get('/ping', async (request, reply) => {
return 'pong\n'
})
server.listen({ port: 8234, host: '127.0.0.1' }, (err, address) => {
if (err) {
console.error(err)
process.exit(1)
}
console.log(`Server listening at ${address}`)
})
await sql.end({timeout:60});
+1 -9
View File
@@ -1,16 +1,8 @@
import { join, dirname } from 'node:path'
import fs from 'node:fs/promises';
import postgres from 'postgres';
import {sql} from './db';
import {parse} from 'csv-parse/sync';
export const sql = postgres({
host: '127.0.0.1',
port: 5432,
user: 'postgres',
password: 'buginoo'
});
try {