Skip to content

Commit

Permalink
start implementing database package
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinBLT committed Jan 30, 2024
1 parent 8f5dc7d commit 65d9836
Show file tree
Hide file tree
Showing 8 changed files with 89 additions and 8 deletions.
23 changes: 18 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"packages/@hec.js/cli",
"packages/@hec.js/api",
"packages/@hec.js/env",
"packages/@hec.js/ui"
"packages/@hec.js/ui",
"packages/@hec.js/database"
]
}
12 changes: 10 additions & 2 deletions packages/@hec.js/api/lib/src/routing/routing.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ export function integrateRoute(route, parent = null) {
).replaceAll('//', '/'),
});

route.group?.forEach((e) => integrateRoute(e, route));
route.group?.sort(routeCompare);
if (route.group) {

for (const childRoute of route.group){
// @ts-ignore: Child route will be transoformed into Route<T> by the Route class
integrateRoute(childRoute, route);
}

route.group?.sort(routeCompare);
}

}
1 change: 1 addition & 0 deletions packages/@hec.js/database/lib/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './src/driver/postgres.js';
36 changes: 36 additions & 0 deletions packages/@hec.js/database/lib/src/database.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
export class Database {

/** @type { string } */
host;

/** @type { number } */
port;

/** @type { string } */
database;

/** @type { string } */
user;

/** @type { string } */
password;

/** @type { number } */
pool = 4;

/** @param {Partial<Database> } connection */
constructor(connection) {
Object.assign(this, connection);
}

/**
* @param { string } query
* @param { any[] } params
* @returns { Promise<any[]> }
*/
async query(query, params) {
return [];
}


}
8 changes: 8 additions & 0 deletions packages/@hec.js/database/lib/src/driver/postgres.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { Database } from '../database.js';
/*import { Client } from 'pg';
const client = new Client()
await client.connect();*/

class PostgresDB extends Database {

}
Empty file.
14 changes: 14 additions & 0 deletions packages/@hec.js/database/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "@hec.js/database",
"type": "module",
"version": "0.0.1",
"description": "DB lib for the hec.dev environment",
"license": "MIT",
"main": "./lib/index.js",
"dependencies": {
"@hec.js/database": "file:./"
},
"devDependencies": {
"vitest": "^1.1.1"
}
}

0 comments on commit 65d9836

Please sign in to comment.