Skip to content

Commit 85857a8

Browse files
committed
feat(server): add cinemas
1 parent 7c8653f commit 85857a8

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
@@ -58,14 +58,16 @@ enum Errors {
5858
CREATOR_FETCH_FAILED = 'CREATOR_FETCH_FAILED',
5959
SEARCH_FETCH_FAILED = 'SEARCH_FETCH_FAILED',
6060
USER_RATINGS_FETCH_FAILED = 'USER_RATINGS_FETCH_FAILED',
61-
PAGE_NOT_FOUND = 'PAGE_NOT_FOUND'
61+
CINEMAS_FETCH_FAILED = 'CINEMAS_FETCH_FAILED',
62+
PAGE_NOT_FOUND = 'PAGE_NOT_FOUND',
6263
}
6364

6465
enum Endpoint {
6566
MOVIE = '/movie/:id',
6667
CREATOR = '/creator/:id',
6768
SEARCH = '/search/:query',
68-
USER_RATINGS = '/user-ratings/:id'
69+
USER_RATINGS = '/user-ratings/:id',
70+
CINEMAS = '/cinemas'
6971
}
7072

7173
type ErrorLog = {
@@ -170,6 +172,19 @@ app.get(Endpoint.USER_RATINGS, async (req, res) => {
170172
}
171173
});
172174

175+
176+
app.get(Endpoint.CINEMAS, async (req, res) => {
177+
try {
178+
const result = await csfd.cinema(1, 'today');
179+
logMessage('success', { error: null, message: `${Endpoint.CINEMAS}` }, req);
180+
res.json(result);
181+
} catch (error) {
182+
const log: ErrorLog = { error: Errors.CINEMAS_FETCH_FAILED, message: 'Failed to fetch cinemas data: ' + error }
183+
logMessage('error', log, req);
184+
res.status(500).json(log);
185+
}
186+
});
187+
173188
app.use((req, res) => {
174189
const log: ErrorLog = { error: Errors.PAGE_NOT_FOUND, message: 'The requested endpoint could not be found.' };
175190
logMessage('warn', log, req);

0 commit comments

Comments
 (0)