Skip to content

Commit 42b71c5

Browse files
committed
feat(server): add cinemas
1 parent 295ff5e commit 42b71c5

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

server.ts

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,16 @@ enum Errors {
6060
CREATOR_FETCH_FAILED = 'CREATOR_FETCH_FAILED',
6161
SEARCH_FETCH_FAILED = 'SEARCH_FETCH_FAILED',
6262
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',
6465
}
6566

6667
enum Endpoint {
6768
MOVIE = '/movie/:id',
6869
CREATOR = '/creator/:id',
6970
SEARCH = '/search/:query',
70-
USER_RATINGS = '/user-ratings/:id'
71+
USER_RATINGS = '/user-ratings/:id',
72+
CINEMAS = '/cinemas'
7173
}
7274

7375
type ErrorLog = {
@@ -173,6 +175,19 @@ app.get(Endpoint.USER_RATINGS, async (req, res) => {
173175
}
174176
});
175177

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+
176191
app.use((req, res) => {
177192
const log: ErrorLog = { error: Errors.PAGE_NOT_FOUND, message: 'The requested endpoint could not be found.' };
178193
logMessage('warn', log, req);

0 commit comments

Comments
 (0)