/** * @swagger * tags: * name: Countries * description: Access country data. */ const router = require("express").Router(); // Models const getCountries = require("../models/getCountries.js"); const getCountryById = require("../models/getCountryById.js"); // Utils const sqlSanitzer = require("../util/sqlstring_sanitizer.js") module.exports = dbConn => { /** * @swagger * /countries: * get: * summary: Get all countries * tags: [Countries] * responses: * "200": * description: Returns aviable data for all countries */ router.get("/api/v1/countries", async (req, res) => { res.json(await getCountries(dbConn)); }); /** * @swagger * /countries/{id}: * get: * summary: Get a specific country by id * tags: [Countries] * parameters: * - name: "id" * in: "path" * required: true * type: int * example: 23 * responses: * "200": * description: Returns aviable data for the country * example: test */ router.get("/api/v1/countries/:id", async (req, res) => { const id = sqlSanitzer(req.params.id); res.json(await getCountryById(dbConn, id)) }); return router; };