mirror of https://github.com/TZGyn/shortener
Added kysely query builder to express backend
parent
89c6abd33b
commit
780fce731a
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…
Reference in New Issue