1
1
"use strict" ;
2
+ var __createBinding = ( this && this . __createBinding ) || ( Object . create ? ( function ( o , m , k , k2 ) {
3
+ if ( k2 === undefined ) k2 = k ;
4
+ var desc = Object . getOwnPropertyDescriptor ( m , k ) ;
5
+ if ( ! desc || ( "get" in desc ? ! m . __esModule : desc . writable || desc . configurable ) ) {
6
+ desc = { enumerable : true , get : function ( ) { return m [ k ] ; } } ;
7
+ }
8
+ Object . defineProperty ( o , k2 , desc ) ;
9
+ } ) : ( function ( o , m , k , k2 ) {
10
+ if ( k2 === undefined ) k2 = k ;
11
+ o [ k2 ] = m [ k ] ;
12
+ } ) ) ;
13
+ var __setModuleDefault = ( this && this . __setModuleDefault ) || ( Object . create ? ( function ( o , v ) {
14
+ Object . defineProperty ( o , "default" , { enumerable : true , value : v } ) ;
15
+ } ) : function ( o , v ) {
16
+ o [ "default" ] = v ;
17
+ } ) ;
2
18
var __importStar = ( this && this . __importStar ) || function ( mod ) {
3
19
if ( mod && mod . __esModule ) return mod ;
4
20
var result = { } ;
5
- if ( mod != null ) for ( var k in mod ) if ( Object . hasOwnProperty . call ( mod , k ) ) result [ k ] = mod [ k ] ;
6
- result [ "default" ] = mod ;
21
+ if ( mod != null ) for ( var k in mod ) if ( k !== "default" && Object . prototype . hasOwnProperty . call ( mod , k ) ) __createBinding ( result , mod , k ) ;
22
+ __setModuleDefault ( result , mod ) ;
7
23
return result ;
8
24
} ;
9
25
var __importDefault = ( this && this . __importDefault ) || function ( mod ) {
@@ -17,25 +33,25 @@ class Router {
17
33
constructor ( server ) {
18
34
const router = express . Router ( ) ;
19
35
const cats = new Map ( ) ;
20
- cats [ uuid_1 . v4 ( ) ] = { genus : "feline" , name : "Cosmo" , isHungry : true , lastFedDate : new Date ( ) } ;
21
- cats [ uuid_1 . v4 ( ) ] = { genus : "feline" , name : "Emmy" , isHungry : true , lastFedDate : new Date ( ) } ;
36
+ cats [ ( 0 , uuid_1 . v4 ) ( ) ] = { genus : "feline" , name : "Cosmo" , isHungry : true , lastFedDate : new Date ( ) } ;
37
+ cats [ ( 0 , uuid_1 . v4 ) ( ) ] = { genus : "feline" , name : "Emmy" , isHungry : true , lastFedDate : new Date ( ) } ;
22
38
router . get ( '/' , ( req , res ) => {
23
39
res . json ( {
24
40
message : `Nothing to see here, [url]/cats instead.`
25
41
} ) ;
26
42
} ) ;
27
43
//get all cats
28
- router . get ( '/cats' , cors_1 . default ( ) , ( req , res ) => {
44
+ router . get ( '/cats' , ( 0 , cors_1 . default ) ( ) , ( req , res ) => {
29
45
res . json ( {
30
46
cats
31
47
} ) ;
32
48
} ) ;
33
49
//create new cat
34
- router . post ( '/cats' , cors_1 . default ( ) , ( req , res ) => {
50
+ router . post ( '/cats' , ( 0 , cors_1 . default ) ( ) , ( req , res ) => {
35
51
try {
36
52
let cat = { } ;
37
53
Object . assign ( cat , req . body ) ;
38
- const newUUID = uuid_1 . v4 ( ) ;
54
+ const newUUID = ( 0 , uuid_1 . v4 ) ( ) ;
39
55
cats [ newUUID ] = cat ;
40
56
res . json ( {
41
57
uuid : newUUID
@@ -46,7 +62,7 @@ class Router {
46
62
}
47
63
} ) ;
48
64
//get cat by id
49
- router . get ( '/cats/:id' , cors_1 . default ( ) , ( req , res ) => {
65
+ router . get ( '/cats/:id' , ( 0 , cors_1 . default ) ( ) , ( req , res ) => {
50
66
if ( ! ! cats [ req . params . id ] ) {
51
67
res . json ( {
52
68
cat : cats [ req . params . id ]
@@ -57,7 +73,7 @@ class Router {
57
73
}
58
74
} ) ;
59
75
//update cat
60
- router . put ( '/cats/:id' , cors_1 . default ( ) , ( req , res ) => {
76
+ router . put ( '/cats/:id' , ( 0 , cors_1 . default ) ( ) , ( req , res ) => {
61
77
try {
62
78
if ( ! ! cats [ req . params . id ] ) {
63
79
let cat = { } ;
@@ -76,7 +92,7 @@ class Router {
76
92
}
77
93
} ) ;
78
94
//delete cat
79
- router . delete ( '/cats/:id' , cors_1 . default ( ) , ( req , res ) => {
95
+ router . delete ( '/cats/:id' , ( 0 , cors_1 . default ) ( ) , ( req , res ) => {
80
96
if ( ! ! cats [ req . params . id ] ) {
81
97
delete cats [ req . params . id ] ;
82
98
res . json ( {
@@ -87,7 +103,7 @@ class Router {
87
103
res . status ( 404 ) . send ( JSON . stringify ( { "error" : "no such cat" } ) ) ;
88
104
}
89
105
} ) ;
90
- router . options ( '*' , cors_1 . default ( ) ) ;
106
+ router . options ( '*' , ( 0 , cors_1 . default ) ( ) ) ;
91
107
server . use ( '/' , router ) ;
92
108
}
93
109
}
0 commit comments