@@ -5,7 +5,6 @@ const router = express.Router(),
55 Booking = require ( '../models/booking' ) ,
66 validator = require ( '../helpers/validator' ) ,
77 creator = require ( '../helpers/bookingcreator' ) ,
8- ua = require ( 'universal-analytics' ) ;
98globalLogins = { } ;
109
1110const { v4 : uuidv4 } = require ( 'uuid' ) ;
@@ -27,8 +26,6 @@ if(process.env.SEED === 'true'){
2726 } ) ( )
2827} ;
2928
30- const visitor = ua ( 'UA-118712228-2' , uuidv4 ( ) ) ;
31-
3229/**
3330 * @api {get } ping HealthCheck
3431 * @apiName Ping
@@ -45,9 +42,6 @@ const visitor = ua('UA-118712228-2', uuidv4());
4542 * HTTP/1.1 201 Created
4643 */
4744router . get ( '/ping' , function ( req , res , next ) {
48- visitor . set ( 'uid' , uuidv4 ( ) ) ;
49- visitor . pageview ( '/ping' , 'https://restful-booker.herokuapp.com/' , "GET /Ping" ) . send ( ) ;
50-
5145 res . sendStatus ( 201 ) ;
5246} ) ;
5347
@@ -94,9 +88,6 @@ router.get('/ping', function(req, res, next) {
9488]
9589*/
9690router . get ( '/booking' , function ( req , res , next ) {
97- visitor . set ( 'uid' , uuidv4 ( ) ) ;
98- visitor . pageview ( '/booking' , 'https://restful-booker.herokuapp.com/' , "GET /booking" ) . send ( ) ;
99-
10091 const query = { } ;
10192
10293 if ( typeof ( req . query . firstname ) != 'undefined' ) {
@@ -184,9 +175,6 @@ router.get('/booking', function(req, res, next) {
184175 * firstname=Jim&lastname=Brown&totalprice=111&depositpaid=true&bookingdates%5Bcheckin%5D=2018-01-01&bookingdates%5Bcheckout%5D=2019-01-01
185176 */
186177router . get ( '/booking/:id' , function ( req , res , next ) {
187- visitor . set ( 'uid' , uuidv4 ( ) ) ;
188- visitor . pageview ( '/booking/:id' , 'https://restful-booker.herokuapp.com/' , "GET /booking/:id" ) . send ( ) ;
189-
190178 Booking . get ( req . params . id , function ( err , record ) {
191179 if ( record ) {
192180 const booking = parse . booking ( req . headers . accept , record ) ;
@@ -309,9 +297,6 @@ router.get('/booking/:id',function(req, res, next){
309297 * bookingid=1&booking%5Bfirstname%5D=Jim&booking%5Blastname%5D=Brown&booking%5Btotalprice%5D=111&booking%5Bdepositpaid%5D=true&booking%5Bbookingdates%5D%5Bcheckin%5D=2018-01-01&booking%5Bbookingdates%5D%5Bcheckout%5D=2019-01-01
310298 */
311299router . post ( '/booking' , function ( req , res , next ) {
312- visitor . set ( 'uid' , uuidv4 ( ) ) ;
313- visitor . pageview ( '/booking' , 'https://restful-booker.herokuapp.com/' , "POST /booking" ) . send ( ) ;
314-
315300 newBooking = req . body ;
316301 if ( req . headers [ 'content-type' ] === 'text/xml' ) newBooking = newBooking . booking ;
317302
@@ -446,9 +431,6 @@ router.post('/booking', function(req, res, next) {
446431 * firstname=Jim&lastname=Brown&totalprice=111&depositpaid=true&bookingdates%5Bcheckin%5D=2018-01-01&bookingdates%5Bcheckout%5D=2019-01-01
447432 */
448433router . put ( '/booking/:id' , function ( req , res , next ) {
449- visitor . set ( 'uid' , uuidv4 ( ) ) ;
450- visitor . pageview ( '/booking/:id' , 'https://restful-booker.herokuapp.com/' , "PUT /booking/:id" ) . send ( ) ;
451-
452434 if ( globalLogins [ req . cookies . token ] || req . headers . authorization == 'Basic YWRtaW46cGFzc3dvcmQxMjM=' ) {
453435 updatedBooking = req . body ;
454436 if ( req . headers [ 'content-type' ] === 'text/xml' ) updatedBooking = updatedBooking . booking ;
@@ -575,9 +557,6 @@ router.put('/booking/:id', function(req, res, next) {
575557 * firstname=Jim&lastname=Brown&totalprice=111&depositpaid=true&bookingdates%5Bcheckin%5D=2018-01-01&bookingdates%5Bcheckout%5D=2019-01-01
576558 */
577559router . patch ( '/booking/:id' , function ( req , res ) {
578- visitor . set ( 'uid' , uuidv4 ( ) ) ;
579- visitor . pageview ( '/booking/:id' , 'https://restful-booker.herokuapp.com/' , "DELETE /booking/:id" ) . send ( ) ;
580-
581560 if ( globalLogins [ req . cookies . token ] || req . headers . authorization == 'Basic YWRtaW46cGFzc3dvcmQxMjM=' ) {
582561 updatedBooking = req . body ;
583562
@@ -633,9 +612,6 @@ router.patch('/booking/:id', function(req, res) {
633612 * HTTP/1.1 201 Created
634613*/
635614router . delete ( '/booking/:id' , function ( req , res , next ) {
636- visitor . set ( 'uid' , uuidv4 ( ) ) ;
637- visitor . pageview ( '/booking/:id' , 'https://restful-booker.herokuapp.com/' , "DELETE /booking/:id" ) . send ( ) ;
638-
639615 if ( globalLogins [ req . cookies . token ] || req . headers . authorization == 'Basic YWRtaW46cGFzc3dvcmQxMjM=' ) {
640616 Booking . get ( req . params . id , function ( err , record ) {
641617 if ( record ) {
@@ -681,9 +657,6 @@ router.delete('/booking/:id', function(req, res, next) {
681657}
682658 */
683659router . post ( '/auth' , function ( req , res , next ) {
684- visitor . set ( 'uid' , uuidv4 ( ) ) ;
685- visitor . pageview ( '/auth' , 'https://restful-booker.herokuapp.com/' , "POST /auth" ) . send ( ) ;
686-
687660 if ( req . body . username === "admin" && req . body . password === "password123" ) {
688661 const token = crypto . randomBytes ( Math . ceil ( 15 / 2 ) )
689662 . toString ( 'hex' )
0 commit comments