my idea about how pintreset collection/boards api router work
i'm using
express-js
// `/username/board/section`
import { Router } from 'express';
const router = Router();
router.get('/:username/:board/:section', (req, res) => {
const { username, board, section } = req.params;
let resualt = [];
if(username){
let user = User.find({ username });
let boards = Board.find({ username });
// if user position on /collection/boards
if(board){
let brd = boards.filter(b => b.name === board);
if(brd !== -1){
if(section){
let pins = Pins.find({ user, board: brd, section });
return res.json({ resualt: pins });
}
let sections = Section.find({ user, board: brd });
return res.json({ resualt: sections });
}
}
return res.json({ resualt: boards })
}
return res.json({ error: 'user-not-found' })
});
// `/username/board/section`
const router = require('express').Router();
router.get('/:username/:board/:section', (req, res) => {
const { username, board, section } = req.params;
let resualt = [];
if(username){
let user = User.find({ username });
let boards = Board.find({ username });
if(board){
let brd = boards.filter(b => b.name === board);
if(brd !== -1){
if(section){
let pins = Pins.find({ user, board: brd, section });
return res.json({ resualt: pins });
}
let sections = Section.find({ user, board: brd });
return res.json({ resualt: sections });
}
}
return res.json({ resualt: boards })
}
return res.json({ error: 'user-not-found' })
});