diff --git a/backend/handlers/createPerson.go b/backend/handlers/createPerson.go index a6cb139..579564f 100644 --- a/backend/handlers/createPerson.go +++ b/backend/handlers/createPerson.go @@ -35,6 +35,7 @@ func CreatePerson(driver neo4j.DriverWithContext) gin.HandlerFunc { return } + person.ID = c.GetString("id") rec, err := person.CreatePerson(driver) if err != nil { log.Printf("ip: %s error: %s", c.ClientIP(), err.Error()) diff --git a/backend/main.go b/backend/main.go index e1ec1de..bec874e 100644 --- a/backend/main.go +++ b/backend/main.go @@ -71,8 +71,8 @@ func main() { // Initialize the HTTP middleware by providing the authorization mw := middleware.New(authZ) - router.GET("/health", hc.HealthCheckHandler()) router.Use(auth(mw)) + router.GET("/health", hc.HealthCheckHandler()) router.GET("/person", handlers.ViewPerson(memgraphDriver)) router.POST("/person", handlers.CreatePerson(memgraphDriver)) router.DELETE("/person", handlers.DeletePerson(memgraphDriver)) diff --git a/backend/memgraph/create_person.go b/backend/memgraph/create_person.go index d800efb..2e6b7b1 100644 --- a/backend/memgraph/create_person.go +++ b/backend/memgraph/create_person.go @@ -11,7 +11,7 @@ import ( ) func (p *Person) CreatePerson(driver neo4j.DriverWithContext) (*neo4j.Record, error) { - ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) + ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second) defer cancel() session := driver.NewSession(ctx, neo4j.SessionConfig{AccessMode: neo4j.AccessModeWrite}) diff --git a/backend/memgraph/create_schema.go b/backend/memgraph/create_schema.go index 4075615..ba76245 100644 --- a/backend/memgraph/create_schema.go +++ b/backend/memgraph/create_schema.go @@ -21,7 +21,7 @@ func createIndexes(driver neo4j.DriverWithContext) error { `CREATE INDEX ON :Person(last_name);`, `CREATE INDEX ON :Person(first_name);`, `CREATE INDEX ON :Person(born);`, - `CREATE INDEX ON :Person(mothers_firstname);`, + `CREATE INDEX ON :Person(mothers_first_name);`, `CREATE INDEX ON :Person(mothers_last_name);`, } @@ -48,8 +48,8 @@ func createConstraints(driver neo4j.DriverWithContext) error { `CREATE CONSTRAINT ON (n:Person) ASSERT EXISTS (n.last_name);`, `CREATE CONSTRAINT ON (n:Person) ASSERT EXISTS (n.first_name);`, `CREATE CONSTRAINT ON (n:Person) ASSERT EXISTS (n.born);`, - `CREATE CONSTRAINT ON (n:Person) ASSERT EXISTS (n.mothers_firstname);`, - `CREATE CONSTRAINT ON (n:Person) ASSERT EXISTS (n.mothers_lastname);`, + `CREATE CONSTRAINT ON (n:Person) ASSERT EXISTS (n.mothers_first_name);`, + `CREATE CONSTRAINT ON (n:Person) ASSERT EXISTS (n.mothers_last_name);`, `CREATE CONSTRAINT ON (n:Person) ASSERT n.id IS UNIQUE;`, `CREATE CONSTRAINT ON (n:Person) ASSERT n.last_name, n.first_name, n.born, n.mothers_first_name, n.mothers_last_name IS UNIQUE;`, } diff --git a/frontend/src/lib/family_tree/CreateProfile.svelte b/frontend/src/lib/family_tree/CreateProfile.svelte index efd5580..6ee446d 100644 --- a/frontend/src/lib/family_tree/CreateProfile.svelte +++ b/frontend/src/lib/family_tree/CreateProfile.svelte @@ -40,6 +40,7 @@ payload.mothers_first_name && payload.mothers_last_name ) { + payload.born = new Date(payload.born).toISOString(); fetch(PUBLIC_API_URL + '/person', { method: 'POST', headers: {