summaryrefslogtreecommitdiff
path: root/db/db.go
diff options
context:
space:
mode:
authorsanine <sanine.not@pm.me>2023-04-29 01:11:04 -0500
committersanine <sanine.not@pm.me>2023-04-29 01:11:04 -0500
commitaa7c3eb23c31fa6051ee0caaebea47c8225d55a4 (patch)
tree273ab2e65e5f19107fb2773a4602cfa15118844a /db/db.go
parentbfdee97bec65746362fd432136eefbd60598f8bf (diff)
add endpoint.go
Diffstat (limited to 'db/db.go')
-rw-r--r--db/db.go11
1 files changed, 8 insertions, 3 deletions
diff --git a/db/db.go b/db/db.go
index 4824a6d..d9faff3 100644
--- a/db/db.go
+++ b/db/db.go
@@ -2,6 +2,7 @@ package db
import (
"os"
+ "time"
"io/fs"
"errors"
"database/sql"
@@ -19,11 +20,13 @@ type User struct {
type Session struct {
Id string
- UserId string
+ UserId int
+ Created time.Time
+ Modified time.Time
}
type Endpoint struct {
- Id string
+ Id int
Name string
Path string
Address string
@@ -45,6 +48,7 @@ type Model interface {
CreateSession(user User) (Session, error)
DeleteSession(session Session) error
CheckSession(session Session) (bool, error)
+ CleanSessions(maxIdle time.Duration) error
AllSessions() ([]Session, error)
CreateEndpoint(name, path, address string) (Endpoint, error)
@@ -52,6 +56,7 @@ type Model interface {
GetEndpointByName(name string) (Endpoint, error)
GetEndpointByPath(path string) (Endpoint, error)
GetEndpointByAddress(address string) (Endpoint, error)
+ AllEndpoints() ([]Endpoint, error)
}
@@ -100,7 +105,7 @@ func (p *Phlox) Create(filename string) error {
insert into schema values(0);
create table users (userid integer not null primary key, username string, passwordhash string, salt string);
- create table sessions (sessionid string not null primary key, userid integer, foreign key(userid) references users(userid));
+ create table sessions (sessionid string not null primary key, userid integer, created string, modified string, foreign key(userid) references users(userid));
create table endpoints (endpointid integer not null primary key, name string, path string, address string);
`)
if err != nil {