Fix SQL syntax and add user registration test

Corrected a SQL syntax error in the databaseGlobals.js by removing an extraneous comma. Added a test script (test.js) to initialize the database and test user registration functionality.
This commit is contained in:
Gilles Lazures 2026-01-27 05:56:44 +01:00
parent f8c1340b41
commit 3346dae465
2 changed files with 20 additions and 1 deletions

View File

@ -68,7 +68,7 @@ function initializeDatabase() {
FOREIGN KEY(productId)
REFERENCES products(id)
ON DELETE CASCADE,
ON DELETE CASCADE
)
`)
}

19
test.js
View File

@ -0,0 +1,19 @@
const globals = require("./modules/databaseGlobals")
const userService = require("./services/userService")
async function main() {
globals.initializeDatabase()
try {
const result = await userService.register({
firstName: "User",
lastName: "Root",
username: "admin",
password: "changme"
})
console.log(result)
} catch (error) {
console.error(error)
}
}
main()