Added kysely query builder to express backend

pull/3/head
TZGyn 2 years ago
parent 89c6abd33b
commit 780fce731a
Signed by: TZGyn
GPG Key ID: 122EAF77AE81FD4A

Binary file not shown.

@ -1 +1,9 @@
{ "dependencies": { "@types/express": "^4.17.17", "express": "^4.18.2" } }
{
"dependencies": {
"@types/express": "^4.17.17",
"@types/pg": "^8.10.2",
"express": "^4.18.2",
"kysely": "^0.26.3",
"pg": "^8.11.3"
}
}

@ -0,0 +1,18 @@
import { Database } from './types'
import { Pool } from 'pg'
import { Kysely, PostgresDialect } from 'kysely'
const dialect = new PostgresDialect({
pool: new Pool({
database: 'link-shortener',
host: '0.0.0.0',
user: 'postgres',
password: 'password',
port: 5432,
max: 10,
}),
})
export const db = new Kysely<Database>({
dialect,
})

@ -0,0 +1,15 @@
import { Generated, Insertable, Selectable, Updateable } from 'kysely'
export interface Database {
shortener: ShortenerTable
}
export interface ShortenerTable {
id: Generated<number>
link: string
code: string
}
export type Shortener = Selectable<ShortenerTable>
export type NewShortener = Insertable<ShortenerTable>
export type ShortenerUpdate = Updateable<ShortenerTable>
Loading…
Cancel
Save