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.
This commit is contained in:
25
routes/register.js
Normal file
25
routes/register.js
Normal file
@@ -0,0 +1,25 @@
|
||||
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
|
||||
Reference in New Issue
Block a user