move old to legacy folder

This commit is contained in:
Primakov Alexandr Alexandrovich
2025-01-19 21:09:17 +03:00
parent 8a2afc3f1b
commit 270fe51500
289 changed files with 0 additions and 0 deletions

View File

@@ -0,0 +1,25 @@
const router = require('express').Router()
const { expressjwt } = require('express-jwt')
const ObjectId = require('mongodb').ObjectID
const { BASKET_JWT_TOKEN } = require('./key')
const { getResponse, getCategory, postCategory } = require('./controller')
router.use(expressjwt({ secret: BASKET_JWT_TOKEN, algorithms: ['HS256'] }))
router.get('/', async (req, res) => {
const userId = new ObjectId(req.auth.id)
let error = null
const categoryData = await getCategory({ userId }).catch((e) => error = e.message)
res.send(getResponse(error, categoryData))
})
router.post('/', async (req, res) => {
const userId = new ObjectId(req.auth.id)
let error = null
const categoryData = await postCategory({ userId, ...req.body }).catch((e) => error = e.message)
res.send(getResponse(error, categoryData))
})
module.exports = router