Introduces GET /users/:id endpoint with validation schema, adds tests for user and register routes, and applies security middlewares (helmet, hpp, cors) to the server. Also adds ESLint configuration and updates logger with linting comments.
19 lines
448 B
JavaScript
19 lines
448 B
JavaScript
const crypto = require("node:crypto")
|
|
const DefaultError = require("../errors/DefaultError")
|
|
|
|
function register({ email, username }) {
|
|
const canRegister = true
|
|
if (canRegister === true) {
|
|
return {
|
|
id: crypto.randomUUID(),
|
|
username: username,
|
|
email: email
|
|
}
|
|
} else {
|
|
throw new DefaultError(418, "I'm a teapot", "", "TeaPotExeception")
|
|
}
|
|
}
|
|
|
|
module.exports = {
|
|
register
|
|
} |