33var utils = require ( '../utils/writer.js' ) ;
44var Spot = require ( '../service/SpotService' ) ;
55
6- module . exports . createSpot = function createSpot ( req , res , next , body ) {
6+ //Function to handle creating a new spot
7+ module . exports . createSpot = function createSpot ( _ , res , __ , body ) {
78 Spot . createSpot ( body )
89 . then ( function ( response ) {
10+ // Write the response using the utility function
911 utils . writeJson ( res , response ) ;
1012 } )
1113 . catch ( function ( response ) {
14+ // Write the error response using the utility function
1215 utils . writeJson ( res , response ) ;
1316 } ) ;
1417} ;
1518
16- module . exports . getSpots = function getSpots ( req , res , next ) {
19+ //Function to handle retrieving all spots
20+ module . exports . getSpots = function getSpots ( _ , res , __ ) {
1721 Spot . getSpots ( )
1822 . then ( function ( response ) {
23+ // Write the response using the utility function
1924 utils . writeJson ( res , response ) ;
2025 } )
2126 . catch ( function ( response ) {
27+ // Write the error response using the utility function
2228 utils . writeJson ( res , response ) ;
2329 } ) ;
2430} ;
2531
26- module . exports . modifySpot = function modifySpot ( req , res , next , body , address , type , charger , id ) {
32+ //Function to handle modifying an existing parking spot
33+ module . exports . modifySpot = function modifySpot ( _ , res , __ , body , address , type , charger , id ) {
2734 Spot . modifySpot ( body , address , type , charger , id )
2835 . then ( function ( response ) {
36+ // Write the response using the utility function
2937 utils . writeJson ( res , response ) ;
3038 } )
3139 . catch ( function ( response ) {
40+ // Write the error response using the utility function
3241 utils . writeJson ( res , response ) ;
3342 } ) ;
3443} ;
3544
36- module . exports . removeSpot = function removeSpot ( req , res , next , id ) {
45+ // Function to handle removing a parking spot
46+ module . exports . removeSpot = function removeSpot ( _ , res , __ , id ) {
3747 Spot . removeSpot ( id )
3848 . then ( function ( response ) {
49+ // Write the response using the utility function
3950 utils . writeJson ( res , response ) ;
4051 } )
4152 . catch ( function ( response ) {
53+ // Write the error response using the utility function
4254 utils . writeJson ( res , response ) ;
4355 } ) ;
4456} ;
4557
46- module . exports . searchSpot = function searchSpot ( req , res , next , address , type , charger ) {
58+ //Function to handle searching for a parking spot
59+ module . exports . searchSpot = function searchSpot ( _ , res , __ , address , type , charger ) {
4760 Spot . searchSpot ( address , type , charger )
4861 . then ( function ( response ) {
62+ // Write the response using the utility function
4963 utils . writeJson ( res , response ) ;
5064 } )
5165 . catch ( function ( response ) {
66+ // Write the error response using the utility function
5267 utils . writeJson ( res , response ) ;
5368 } ) ;
54- } ;
69+ } ;
0 commit comments