progress on friend route

This commit is contained in:
Mikayla Dobson
2022-11-26 15:32:10 -06:00
parent 03ec2bf38c
commit 9bd1704da9
10 changed files with 187 additions and 11 deletions

View File

@@ -0,0 +1,39 @@
import { Express, Router } from "express"
import { restrictAccess } from "../auth/middlewares";
import { CollectionCtl } from "../controllers";
const CollectionInstance = new CollectionCtl();
const router = Router();
export const subscriptionRoute = (app: Express) => {
app.use('/subscription', router);
router.get('/', async (req, res, next) => {
// @ts-ignore
const { user } = req.user;
if (!user) return;
try {
const result = await CollectionInstance.getSubscriptions(user.id as string);
res.status(200).send(result);
} catch(e) {
next(e);
}
})
router.post('/', restrictAccess, async (req, res, next) => {
// @ts-ignore
const { user } = req.user;
const { collection } = req.query;
try {
const result = await CollectionInstance.postSubscription(collection as string, user.id as string);
res.status(201).send(result);
} catch(e) {
next(e);
}
})
router.put('/', async (req, res, next) => {
})
}