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.
20 lines
682 B
JavaScript
20 lines
682 B
JavaScript
const express = require("express")
|
|
const router = express.Router()
|
|
const authService = require("../../services/authService")
|
|
const YggdrasilError = require("../../errors/YggdrasilError")
|
|
const { DefaultError } = require("../../errors/errors")
|
|
|
|
router.post("/", async (req, res) => {
|
|
const { accessToken, clientToken } = req.body
|
|
try {
|
|
await authService.validate({ accessToken, clientToken })
|
|
res.sendStatus(204)
|
|
} catch (err) {
|
|
if (err instanceof DefaultError) {
|
|
throw new YggdrasilError(err.code, err.error || "ForbiddenOperationException", err.message, "Invalid token.")
|
|
}
|
|
throw err
|
|
}
|
|
})
|
|
|
|
module.exports = router |