@@ -60,14 +60,16 @@ enum Errors {
60
60
CREATOR_FETCH_FAILED = 'CREATOR_FETCH_FAILED' ,
61
61
SEARCH_FETCH_FAILED = 'SEARCH_FETCH_FAILED' ,
62
62
USER_RATINGS_FETCH_FAILED = 'USER_RATINGS_FETCH_FAILED' ,
63
- PAGE_NOT_FOUND = 'PAGE_NOT_FOUND'
63
+ CINEMAS_FETCH_FAILED = 'CINEMAS_FETCH_FAILED' ,
64
+ PAGE_NOT_FOUND = 'PAGE_NOT_FOUND' ,
64
65
}
65
66
66
67
enum Endpoint {
67
68
MOVIE = '/movie/:id' ,
68
69
CREATOR = '/creator/:id' ,
69
70
SEARCH = '/search/:query' ,
70
- USER_RATINGS = '/user-ratings/:id'
71
+ USER_RATINGS = '/user-ratings/:id' ,
72
+ CINEMAS = '/cinemas'
71
73
}
72
74
73
75
type ErrorLog = {
@@ -173,6 +175,19 @@ app.get(Endpoint.USER_RATINGS, async (req, res) => {
173
175
}
174
176
} ) ;
175
177
178
+
179
+ app . get ( Endpoint . CINEMAS , async ( req , res ) => {
180
+ try {
181
+ const result = await csfd . cinema ( 1 , 'today' ) ;
182
+ logMessage ( 'success' , { error : null , message : `${ Endpoint . CINEMAS } ` } , req ) ;
183
+ res . json ( result ) ;
184
+ } catch ( error ) {
185
+ const log : ErrorLog = { error : Errors . CINEMAS_FETCH_FAILED , message : 'Failed to fetch cinemas data: ' + error }
186
+ logMessage ( 'error' , log , req ) ;
187
+ res . status ( 500 ) . json ( log ) ;
188
+ }
189
+ } ) ;
190
+
176
191
app . use ( ( req , res ) => {
177
192
const log : ErrorLog = { error : Errors . PAGE_NOT_FOUND , message : 'The requested endpoint could not be found.' } ;
178
193
logMessage ( 'warn' , log , req ) ;
0 commit comments