Yggdrasil/routes/register.js
azures04 0b1662d8ca Initial project structure and core modules
Add environment example, update .gitignore, and switch license to AGPL v3. Introduce error handling classes, ESLint config, and main modules for database, logging, certificate management, and utility functions. Add authentication routes, schemas, and service layer for a modular REST API. Update README and set up repository structure for further development.
2025-12-23 15:59:43 +01:00

25 lines
822 B
JavaScript

const path = require("node:path")
const express = require("express")
const router = express.Router()
const Logger = require("../modules/logger")
const logger = Logger.createLogger(path.join(__dirname, ".."))
const authService = require("../services/authService")
router.post("/", async (req, res) => {
const { username, password, email, registrationCountry, preferredLanguage } = req.body
const clientIp = req.headers["x-forwarded-for"] || req.connection.remoteAddress
const result = await authService.registerUser({
username,
password,
email,
registrationCountry,
preferredLanguage,
clientIp
})
logger.log(`New user registered: ${username}`, ["Web", "yellow", "AUTH", "green"])
return res.status(200).json(result)
})
module.exports = router