TestingFrenzy

index.js routes

May 28th, 2024
21
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 26.05 KB | None | 0 0
  1. const express = require('express');
  2. const router = express.Router();
  3. const axios = require('axios');
  4. const app = express();
  5.  
  6. // Starting the Express server
  7. const PORT = 3030;
  8. app.listen(PORT, () => {
  9. console.log(`Express server listening on port ${PORT}`);
  10. });
  11.  
  12. /**
  13. * Handles POST request for player search.
  14. *
  15. * @param {Object} req - The request object.
  16. * @param {Object} req.body - The request body.
  17. * @param {string} req.body.barName - The player's name.
  18. * @param {Object} res - The response object.
  19. * @returns {Object} - JSON response with the players data.
  20. */
  21. router.post('/playerbar', async (req, res) => {
  22. try {
  23. const playerName = req.body.barName; // Extract the player's name from the request
  24.  
  25. // Forward the request to the Spring server using axios
  26. const response = await axios.post('http://localhost:8080/player', playerName);
  27. const players = response.data;
  28.  
  29. // Forward the response from the Spring server to the client
  30. res.json(players);
  31. } catch (error) {
  32. res.status(500).send('Error during player search');
  33. }
  34. });
  35.  
  36. /**
  37. * Handles POST request for club search.
  38. *
  39. * @param {Object} req - The request object.
  40. * @param {Object} req.body - The request body.
  41. * @param {string} req.body.barName - The club's name.
  42. * @param {Object} res - The response object.
  43. * @returns {Object} - JSON response with the clubs data.
  44. */
  45. router.post('/clubbar', async (req, res) => {
  46. try {
  47. const clubName = req.body.barName; // Extract the club's name from the request
  48.  
  49. // Forward the request to the Spring server using axios
  50. const response = await axios.post('http://localhost:8080/club', clubName);
  51. const clubs = response.data;
  52.  
  53. // Forward the response from the Spring server to the client
  54. res.json(clubs);
  55. } catch (error) {
  56. res.status(500).send('Error during club search');
  57. }
  58. });
  59.  
  60. /**
  61. * Handles POST request for player details.
  62. *
  63. * @param {Object} req - The request object.
  64. * @param {Object} req.body - The request body.
  65. * @param {string} req.body.barName - The player's name.
  66. * @param {Object} res - The response object.
  67. */
  68. router.post('/player', async (req, res) => {
  69. try {
  70. const playerName = req.body.barName.toLowerCase(); // Extract the player's name from the request
  71.  
  72. // Forward the request to the Spring server using axios
  73. const response = await axios.post('http://localhost:8080/player', playerName);
  74. const players = response.data;
  75.  
  76. // Extract data from the first player in the list (presumably there is only one)
  77. const playerData = players[0];
  78.  
  79. // Pass the player's name as the page title
  80. res.render('player', {
  81. title: playerData.name,
  82. playerId: playerData.playerId,
  83. firstName: playerData.firstName,
  84. lastName: playerData.lastName,
  85. name: playerData.name,
  86. lastSeason: playerData.lastSeason,
  87. currentClubId: playerData.currentClubId,
  88. playerCode: playerData.playerCode,
  89. countryOfBirth: playerData.countryOfBirth,
  90. cityOfBirth: playerData.cityOfBirth,
  91. countryOfCitizenship: playerData.countryOfCitizenship,
  92. dateOfBirth: playerData.dateOfBirth,
  93. subPosition: playerData.subPosition,
  94. position: playerData.position,
  95. foot: playerData.foot,
  96. heightInCm: playerData.heightInCm,
  97. marketValueInEur: playerData.marketValueInEur,
  98. highestMarketValueInEur: playerData.highestMarketValueInEur,
  99. contractExpirationDate: playerData.contractExpirationDate,
  100. agentName: playerData.agentName,
  101. imageUrl: playerData.imageUrl,
  102. url: playerData.url,
  103. currentClubDomesticCompetitionId: playerData.currentClubDomesticCompetitionId,
  104. currentClubName: playerData.currentClubName
  105. });
  106. } catch (error) {
  107. console.error('Error during player search:', error);
  108. res.status(500).send('Error during player search');
  109. }
  110. });
  111.  
  112. /**
  113. * Handles POST request for club details.
  114. *
  115. * @param {Object} req - The request object.
  116. * @param {Object} req.body - The request body.
  117. * @param {string} req.body.barName - The club's name.
  118. * @param {Object} res - The response object.
  119. */
  120. router.post('/club', async (req, res) => {
  121. try {
  122. const clubName = req.body.barName.toLowerCase(); // Extract the club's name from the request
  123.  
  124. // Forward the request to the Spring server using axios
  125. const response = await axios.post('http://localhost:8080/club', clubName);
  126. const clubs = response.data;
  127.  
  128. // Extract data from the first club in the list (presumably there is only one)
  129. const clubData = clubs[0];
  130.  
  131. // Pass the club's name as the page title
  132. res.render('club', {
  133. title: clubData.name,
  134. clubId: clubData.clubId,
  135. clubCode: clubData.clubCode,
  136. name: clubData.name,
  137. domesticCompetitionId: clubData.domesticCompetitionId,
  138. totalMarketValue: clubData.totalMarketValue,
  139. squadSize: clubData.squadSize,
  140. averageAge: clubData.averageAge,
  141. foreignersNumber: clubData.foreignersNumber,
  142. foreignersPercentage: clubData.foreignersPercentage,
  143. nationalTeamPlayers: clubData.nationalTeamPlayers,
  144. stadiumName: clubData.stadiumName,
  145. stadiumSeats: clubData.stadiumSeats,
  146. netTransferRecord: clubData.netTransferRecord,
  147. coachName: clubData.coachName,
  148. lastSeason: clubData.lastSeason,
  149. url: clubData.url
  150. });
  151. } catch (error) {
  152. console.error('Error during club search:', error);
  153. res.status(500).send('Error during club search');
  154. }
  155. });
  156.  
  157. /**
  158. * Handles GET request for player information by player ID.
  159. *
  160. * @param {Object} req - The request object.
  161. * @param {Object} req.params - The request parameters.
  162. * @param {string} req.params.playerId - The player's ID.
  163. * @param {Object} res - The response object.
  164. */
  165. router.get('/player/:playerId', async (req, res) => {
  166. try {
  167. const playerId = req.params.playerId; // Extract the player's ID from the request
  168.  
  169. // Forward the request to the Spring server using axios
  170. const response = await axios.get(`http://localhost:8080/player/${playerId}`);
  171. const players = response.data;
  172.  
  173. const playerData = players[0];
  174.  
  175. // Retrieve the player's team standings
  176. const responseClub = await axios.get(`http://localhost:8080/club/${playerData.currentClubId}`);
  177. const club = responseClub.data;
  178.  
  179. const response3 = await axios.get(`http://localhost:3001/game/${club[0].domesticCompetitionId}/2023`);
  180. const gameMongo = response3.data; // gameMongo is for games informations coming from Mongodb, like standings, goals, subs, cards etc
  181.  
  182. // Fetch player's appearance stats for the specified year
  183. const totalCountStats = await axios.get(`http://localhost:3001/appearancesCount/${playerId}`);
  184. const app = totalCountStats.data; // App is for appearances stats (adding goal assist and cards)
  185. const lastYear = await axios.get(`http://localhost:3001/appearancesCount/${playerId}/2023`);
  186. const lastYearData = lastYear.data;
  187.  
  188. const ris4 = await axios.get(`http://localhost:3001/clubPlayed/${playerId}`);
  189. const clubPlayed = ris4.data;
  190. const clubDetails = [];
  191.  
  192. for (let i = 0; i < clubPlayed.length; i++) {
  193. const club_id = clubPlayed[i].player_club_id;
  194.  
  195. if (isNaN(club_id) || club_id === '\\N') {
  196. clubDetails.push({
  197. date: clubPlayed[i].date,
  198. id: club_id,
  199. club_name: "Unknown"
  200. });
  201. } else {
  202. try {
  203. const springResponse = await axios.get(`http://localhost:8080/club/${club_id}`);
  204. const club = springResponse.data;
  205. const name = club[0].name;
  206.  
  207. clubDetails.push({
  208. date: clubPlayed[i].date,
  209. id: club_id,
  210. club_name: name
  211. });
  212. } catch (error) {
  213. console.error("Error fetching club details:", error);
  214.  
  215. clubDetails.push({
  216. date: clubPlayed[i].date,
  217. id: club_id,
  218. club_name: "Unknown"
  219. });
  220. }
  221. }
  222. }
  223.  
  224. const market = await axios.get(`http://localhost:3001/playerValue/${playerId}`);
  225. const marketValue = market.data;
  226.  
  227. // Pass the player's name as the page title
  228. res.render('player', {
  229. title: playerData.name,
  230. playerId: playerData.playerId,
  231. firstName: playerData.firstName,
  232. lastName: playerData.lastName,
  233. name: playerData.name,
  234. lastSeason: playerData.lastSeason,
  235. currentClubId: playerData.currentClubId,
  236. playerCode: playerData.playerCode,
  237. countryOfBirth: playerData.countryOfBirth,
  238. cityOfBirth: playerData.cityOfBirth,
  239. countryOfCitizenship: playerData.countryOfCitizenship,
  240. dateOfBirth: playerData.dateOfBirth,
  241. subPosition: playerData.subPosition,
  242. position: playerData.position,
  243. foot: playerData.foot,
  244. heightInCm: playerData.heightInCm,
  245. marketValueInEur: playerData.marketValueInEur,
  246. highestMarketValueInEur: playerData.highestMarketValueInEur,
  247. contractExpirationDate: playerData.contractExpirationDate,
  248. agentName: playerData.agentName,
  249. imageUrl: playerData.imageUrl,
  250. url: playerData.url,
  251. currentClubDomesticCompetitionId: playerData.currentClubDomesticCompetitionId,
  252. currentClubName: playerData.currentClubName,
  253. gameMongo,
  254. app,
  255. clubDetails,
  256. marketValue,
  257. lastYearData
  258. });
  259.  
  260. } catch (error) {
  261. res.render('error');
  262. }
  263. });
  264.  
  265. /**
  266. * Handles GET request for club information by club ID.
  267. *
  268. * @param {Object} req - The request object.
  269. * @param {Object} req.params - The request parameters.
  270. * @param {string} req.params.clubId - The club's ID.
  271. * @param {Object} res - The response object.
  272. */
  273. router.get('/club/:clubId', async (req, res) => {
  274. try {
  275. const clubId = req.params.clubId; // Extract the club's ID from the request
  276.  
  277. // Forward the request to the Spring server using axios
  278. const response = await axios.get(`http://localhost:8080/club/${clubId}`);
  279. const clubs = response.data;
  280. const response2 = await axios.post(`http://localhost:8080/club/${clubId}/player`);
  281. const players = response2.data;
  282.  
  283. const response3 = await axios.get(`http://localhost:3001/game/${clubs[0].domesticCompetitionId}/2023`);
  284. const gameMongo = response3.data; // gameMongo is for games informations coming from Mongodb, like standings, goals, subs, cards etc
  285. console.log("aaaaa ");
  286. const response4 = await axios.get(`http://localhost:3001/coach/${clubId}`);
  287. const coach = response4.data; //get the coach of the club, according to the last game
  288. console.log(response4.data);
  289. // Organize players by position
  290. const goalkeepers = players.filter(player => player.position === 'Goalkeeper');
  291. const defenders = players.filter(player => player.position === 'Defender');
  292. const midfielders = players.filter(player => player.position === 'Midfield');
  293. const forwards = players.filter(player => player.position === 'Attack');
  294.  
  295. // Extract data from the first club in the list (presumably there is only one)
  296. const clubData = clubs[0];
  297.  
  298. // Pass the club's name as the page title
  299. res.render('club', {
  300. title: clubData.name,
  301. clubId: clubData.clubId,
  302. clubCode: clubData.clubCode,
  303. name: clubData.name,
  304. domesticCompetitionId: clubData.domesticCompetitionId,
  305. totalMarketValue: clubData.totalMarketValue,
  306. squadSize: clubData.squadSize,
  307. averageAge: clubData.averageAge,
  308. foreignersNumber: clubData.foreignersNumber,
  309. foreignersPercentage: clubData.foreignersPercentage,
  310. nationalTeamPlayers: clubData.nationalTeamPlayers,
  311. stadiumName: clubData.stadiumName,
  312. stadiumSeats: clubData.stadiumSeats,
  313. netTransferRecord: clubData.netTransferRecord,
  314. coachName: coach,
  315. lastSeason: clubData.lastSeason,
  316. url: clubData.url,
  317. goalkeepers,
  318. defenders,
  319. midfielders,
  320. forwards,
  321. gameMongo
  322. });
  323.  
  324. } catch (error) {
  325. res.render('error');
  326. }
  327. });
  328.  
  329. /**
  330. * Handles GET request to retrieve all competitions.
  331. *
  332. * @param {Object} req - The request object.
  333. * @param {Object} res - The response object.
  334. * @returns {Object} - Renders the competition list page with competitions data.
  335. */
  336. router.get('/competitions', async (req, res) => {
  337. try {
  338. // Make a GET request to the Spring server to retrieve all competitions
  339. const response = await axios.get('http://localhost:8080/competitions');
  340. const competitions = response.data;
  341.  
  342. // Send the competitions as a response
  343. res.render('competitionListPage', { competitions });
  344. } catch (error) {
  345. console.error('Error retrieving competitions:', error);
  346. res.status(500).send('Error retrieving competitions');
  347. }
  348. });
  349.  
  350. /**
  351. * Handles GET request for competition information by competition ID.
  352. *
  353. * @param {Object} req - The request object.
  354. * @param {Object} req.params - The request parameters.
  355. * @param {string} req.params.competitionId - The competition ID.
  356. * @param {Object} res - The response object.
  357. */
  358. router.get('/competitions/:competitionId', async (req, res) => {
  359. try {
  360. const competitionId = req.params.competitionId; // Extract the competition ID from the request
  361.  
  362. // Check if the competitionId matches any of the specified values
  363. const specialCompetitions = ['CIT', 'NLSC', 'GRP', 'POSU', 'RUSS', 'SUC', 'USC', 'EL', 'RUP', 'BESC', 'ELQ',
  364. 'CGB', 'DKP', 'ECLQ', 'FAC', 'NLP', 'CDR', 'CL', 'POCP', 'KLUB', 'CLQ', 'DFL',
  365. 'SFA', 'UKRP', 'DFB', 'FRCH', 'SCI'];
  366.  
  367. if (specialCompetitions.includes(competitionId)) {
  368. const response = await axios.get(`http://localhost:8080/competitions/${competitionId}`);
  369. const competitions = response.data;
  370. const competition = competitions[0];
  371. const response2 = await axios.get(`http://localhost:3001/game/${competitionId}/2023`);
  372. const gameMongo = response2.data; // gameMongo is for games informations coming from Mongodb, like standings, goals, subs, cards etc
  373.  
  374.  
  375. res.render('competitionCup', { competition, gameMongo }); // Pass 'competition' in singular form
  376. } else {
  377. const response = await axios.get(`http://localhost:8080/competitions/${competitionId}`);
  378. const competitions = response.data;
  379. const response2 = await axios.post(`http://localhost:8080/competitions/${competitionId}/clubs`);
  380. const clubs = response2.data;
  381. const response3 = await axios.get(`http://localhost:3001/game/${competitionId}/2023`);
  382. const gameMongo = response3.data;
  383.  
  384. const competition = competitions[0];
  385. res.render('competition', { competition, clubs, gameMongo }); // Pass 'competition' in singular form
  386. }
  387. } catch (error) {
  388. res.render('error');
  389. }
  390. });
  391.  
  392. /**
  393. * Handles GET request for competition information by competition ID and season.
  394. *
  395. * @param {Object} req - The request object.
  396. * @param {Object} req.params - The request parameters.
  397. * @param {string} req.params.competitionId - The competition ID.
  398. * @param {string} req.params.season - The season.
  399. * @param {Object} res - The response object.
  400. */
  401. router.get('/competitions/:competitionId/:season', async (req, res) => {
  402. try {
  403. const competitionId = req.params.competitionId; // Extract the competition ID from the request
  404. const season = req.params.season;
  405. // Check if the competitionId matches any of the specified values
  406. const specialCompetitions = ['CIT', 'NLSC', 'GRP', 'POSU', 'RUSS', 'SUC', 'USC', 'EL', 'RUP', 'BESC', 'ELQ',
  407. 'CGB', 'DKP', 'ECLQ', 'FAC', 'NLP', 'CDR', 'CL', 'POCP', 'KLUB', 'CLQ', 'DFL',
  408. 'SFA', 'UKRP', 'DFB', 'FRCH', 'SCI'];
  409.  
  410. if (specialCompetitions.includes(competitionId)) {
  411. const response = await axios.get(`http://localhost:8080/competitions/${competitionId}`);
  412. const competitions = response.data;
  413. const competition = competitions[0];
  414. const response2 = await axios.get(`http://localhost:3001/game/${competitionId}/${season}`);
  415. const gameMongo = response2.data; // gameMongo is for games informations coming from Mongodb, like standings, goals, subs, cards etc
  416.  
  417.  
  418. res.render('competitionCup', { competition, gameMongo }); // Pass 'competition' in singular form
  419. } else {
  420. const response = await axios.get(`http://localhost:8080/competitions/${competitionId}`);
  421. const competitions = response.data;
  422. const response2 = await axios.post(`http://localhost:8080/competitions/${competitionId}/clubs`);
  423. const clubs = response2.data;
  424. const response3 = await axios.get(`http://localhost:3001/game/${competitionId}/${season}`);
  425. const gameMongo = response3.data;
  426.  
  427. const competition = competitions[0];
  428. res.render('competition', { competition, clubs, gameMongo }); // Pass 'competition' in singular form
  429. }
  430. } catch (error) {
  431. res.render('error');
  432. }
  433. });
  434.  
  435. /**
  436. * Handles GET request for competition information by competition ID, season, and round.
  437. *
  438. * @param {Object} req - The request object.
  439. * @param {Object} req.params - The request parameters.
  440. * @param {string} req.params.competitionId - The competition ID.
  441. * @param {string} req.params.season - The season.
  442. * @param {string} req.params.round - The round.
  443. * @param {Object} res - The response object.
  444. */
  445. router.get('/competitions/:competitionId/:season/:round', async (req, res) => {
  446. try {
  447. const competitionId = req.params.competitionId;
  448. const season = req.params.season;
  449. const round = req.params.round;
  450.  
  451. const response = await axios.get(`http://localhost:3001/game/${competitionId}/${season}/${round}`);
  452. const info = response.data;
  453.  
  454. res.render('dayMatches', { info });
  455. } catch (error) {
  456. res.render('error');
  457. }
  458. });
  459.  
  460. /**
  461. * Handles GET request for competition information by competition ID and round.
  462. *
  463. * @param {Object} req - The request object.
  464. * @param {Object} req.params - The request parameters.
  465. * @param {string} req.params.competitionId - The competition ID.
  466. * @param {string} req.params.round - The round.
  467. * @param {Object} res - The response object.
  468. */
  469. router.get('/competitions/:competitionId/:round', async (req, res) => {
  470. try {
  471. const competitionId = req.params.competitionId;
  472. const round = req.params.round;
  473.  
  474. const response = await axios.get(`http://localhost:3001/game/${competitionId}/2023/${round}`);
  475. const info = response.data;
  476.  
  477. res.render('dayMatches', { info });
  478. } catch (error) {
  479. res.render('error');
  480. res.status(500).send('Error during match search');
  481. }
  482. });
  483.  
  484. /**
  485. * Handles GET request for game information by game ID.
  486. *
  487. * @param {Object} req - The request object.
  488. * @param {Object} req.params - The request parameters.
  489. * @param {string} req.params.gameId - The game ID.
  490. * @param {Object} res - The response object.
  491. */
  492. router.get('/gameinfo/:gameId', async (req, res) => {
  493. try {
  494. const gameId = req.params.gameId;
  495. const response = await axios.get(`http://localhost:3001/gameinfo/${gameId}`);
  496. const gameData = response.data;
  497.  
  498. const home_id = gameData[0].home_club_id;
  499. const response2 = await axios.get(`http://localhost:3001/formazioni/${gameId}/${home_id}`);
  500. const formazioni = response2.data;
  501.  
  502. const lunghezza = formazioni.length;
  503.  
  504. // Check if all keys in formazioni contain empty arrays
  505. const isFormazioniEmpty = Object.values(formazioni).every(array => array.length === 0);
  506.  
  507. if (isFormazioniEmpty) { // If there is no formation
  508. const response3 = await axios.get(`http://localhost:3001/events/${gameId}`);
  509. const events = response3.data;
  510.  
  511. for (const event of events) {
  512. if (event.player_id) {
  513. event.player_name = await getPlayerName(event.player_id);
  514. }
  515. if (event.player_in_id) {
  516. const playerInId = event.player_in_id.split('.')[0]; // Remove the ".0" from player_in_id
  517. event.player_in_name = await getPlayerName(playerInId);
  518. }
  519. if (event.player_assist_id && event.player_assist_id !== '\\N') {
  520. event.player_assist_name = await getPlayerName(event.player_assist_id);
  521. }
  522. }
  523.  
  524. res.render('gameNoLineup', { gameData, events });
  525. return;
  526. } else {
  527. const playerDetails = [];
  528.  
  529. for (let i = 0; i < 22; i++) {
  530. const player_id = formazioni[i].player_id;
  531.  
  532. if (isNaN(player_id) || player_id === '\\N') {
  533. playerDetails.push({
  534. id: player_id,
  535. imageUrl: "https://cdn.icon-icons.com/icons2/1729/PNG/512/footballjersey12_113031.png"
  536. });
  537. } else {
  538. try {
  539. const springResponse = await axios.get(`http://localhost:8080/player/${player_id}`);
  540. const player = springResponse.data;
  541. const url = player[0].imageUrl;
  542.  
  543. playerDetails.push({
  544. id: player_id,
  545. imageUrl: url
  546. });
  547.  
  548. } catch (error) {
  549. console.error("Error fetching player details:", error);
  550.  
  551. playerDetails.push({
  552. id: player_id,
  553. imageUrl: "https://cdn.icon-icons.com/icons2/1729/PNG/512/footballjersey12_113031.png"
  554. });
  555. }
  556. }
  557. }
  558.  
  559. const response4 = await axios.get(`http://localhost:3001/events/${gameId}`);
  560. const events = response4.data;
  561.  
  562. for (const event of events) {
  563. if (event.player_id) {
  564. event.player_name = await getPlayerName(event.player_id);
  565. }
  566. if (event.player_in_id) {
  567. const playerInId = event.player_in_id.split('.')[0];
  568. event.player_in_name = await getPlayerName(playerInId);
  569. }
  570. if (event.player_assist_id && event.player_assist_id !== '\\N') {
  571. event.player_assist_name = await getPlayerName(event.player_assist_id);
  572. }
  573. }
  574.  
  575. // Render the formations data
  576. res.render('game', { gameData, formazioni, playerDetails, events, lunghezza });
  577. }
  578. } catch (error) {
  579. res.render('error');
  580. }
  581. });
  582.  
  583. /**
  584. * Function to get player name.
  585. *
  586. * @param {string} playerId - The player's ID.
  587. * @returns {string} - The player's name.
  588. */
  589. async function getPlayerName(playerId) {
  590. try {
  591. const playerResponse = await axios.get(`http://localhost:8080/player/${playerId}`);
  592. const nome = playerResponse.data;
  593. return nome[0].name;
  594. } catch (error) {
  595. console.error(`Error fetching player name with ID ${playerId}:`, error.message);
  596. return "Unknown"; // Returns an empty string if an error occurs
  597. }
  598. }
  599.  
  600. /**
  601. * GET home page.
  602. *
  603. * @param {Object} req - The request object.
  604. * @param {Object} res - The response object.
  605. * @param {Function} next - The next middleware function.
  606. */
  607. router.get('/home', function(req, res, next) {
  608. res.render('index', { title: 'Soccer Site' });
  609. });
  610.  
  611. /**
  612. * GET home page.
  613. *
  614. * @param {Object} req - The request object.
  615. * @param {Object} res - The response object.
  616. * @param {Function} next - The next middleware function.
  617. */
  618. router.get('/', function(req, res, next) {
  619. if (req.session.user) {
  620. // If the user is logged in, show the preferred team
  621. const teamId = req.session.user.teamId;
  622. res.send(`Welcome to the home page! Your favorite team is ${teamId}`);
  623. } else {
  624. // If the user is not logged in, show a generic version of the home page
  625. res.send('Welcome to the home page!');
  626. }
  627.  
  628. res.render('index', { title: 'Soccer Site' });
  629. });
  630.  
  631. /**
  632. * GET home page.
  633. *
  634. * @param {Object} req - The request object.
  635. * @param {Object} res - The response object.
  636. * @param {Function} next - The next middleware function.
  637. */
  638. router.get('/index', function(req, res, next) {
  639. res.render('index', { title: 'Soccer Site' });
  640. });
  641.  
  642. /**
  643. * GET player list page.
  644. *
  645. * @param {Object} req - The request object.
  646. * @param {Object} res - The response object.
  647. * @param {Function} next - The next middleware function.
  648. */
  649. router.get('/player', function(req, res, next) {
  650. res.render('playerListPage.ejs');
  651. });
  652.  
  653. module.exports = router;
Tags: js
Advertisement
Add Comment
Please, Sign In to add comment