Skip to content

Commit 48c0aeb

Browse files
Update routes
1 parent c6f39f4 commit 48c0aeb

File tree

5 files changed

+77
-21
lines changed

5 files changed

+77
-21
lines changed

src/routes/api.routes.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
import * as express from 'express';
2-
import { publishRouter } from './publish.routes';
2+
import { eventsRouter } from './events.routes';
3+
import { locationsRouter } from './locations.routes';
4+
import { artworksRouter } from './artworks.routes';
35

46
const router = express.Router();
57

68
router.get('/', (req, res) => {
79
res.send("HackOSS API at your service. Don't get any funny ideas.");
810
});
911

10-
router.use('/publish', publishRouter);
12+
router.use('/events', eventsRouter);
13+
router.use('/locations', locationsRouter);
14+
router.use('/artworks', artworksRouter);
1115

1216
export const apiRouter = router;

src/routes/artworks.routes.ts

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import * as express from 'express';
2+
import { eventbriteService } from '../services/eventbrite/eventbrite.service';
3+
4+
const router = express.Router();
5+
6+
router.post('/:artworkId', async (req, res) => {
7+
8+
const artworkId = req.body.artworkId;
9+
10+
try {
11+
await eventbriteService.uploadMedia(artworkId);
12+
res.send('OK');
13+
} catch (e) {
14+
res.status(500).send(e.message);
15+
}
16+
17+
});
18+
19+
export const artworksRouter = router;

src/routes/events.routes.ts

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import * as express from 'express';
2+
import { publishService } from '../services/publish/publish.service';
3+
import { eventbriteService } from '../services/eventbrite/eventbrite.service';
4+
5+
const router = express.Router();
6+
7+
router.post('/:eventId', async (req, res) => {
8+
9+
const eventId = req.body.eventId;
10+
11+
try {
12+
await eventbriteService.createEvent(eventId);
13+
res.send('OK');
14+
} catch (e) {
15+
res.status(500).send(e.message);
16+
}
17+
18+
});
19+
20+
router.post('/:eventId/publish', async (req, res) => {
21+
22+
const eventId = req.params.eventId;
23+
const platform = req.body.platform;
24+
25+
try {
26+
await publishService.publish(eventId, platform);
27+
res.send('OK');
28+
} catch (e) {
29+
res.status(500).send(e.message);
30+
}
31+
});
32+
33+
export const eventsRouter = router;

src/routes/locations.routes.ts

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import * as express from 'express';
2+
import { eventbriteService } from '../services/eventbrite/eventbrite.service';
3+
4+
const router = express.Router();
5+
6+
router.post('/:locationId', async (req, res) => {
7+
8+
const eventId = req.body.locationId;
9+
10+
try {
11+
await eventbriteService.createLocation(eventId);
12+
res.send('OK');
13+
} catch (e) {
14+
res.status(500).send(e.message);
15+
}
16+
17+
});
18+
19+
export const locationsRouter = router;

src/routes/publish.routes.ts

-19
This file was deleted.

0 commit comments

Comments
 (0)