-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.ts
29 lines (23 loc) · 928 Bytes
/
server.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
require('custom-env').env()
import * as express from 'express';
import { Request, Response } from 'express';
import { searchArtists, getTopArtists, getArtistDetails, getTopAlbums } from './repos';
const app = express()
app.get('/api/artists', async (req: Request, res: Response) => {
const artists = await searchArtists(req.query.search as string)
res.status(200).send(artists);
})
app.get('/api/chart/topartists', async (_req: Request, res: Response) => {
const artists = await getTopArtists();
res.status(200).send(artists);
})
app.get('/api/artist/:name', async (req: Request, res: Response) => {
const details = await getArtistDetails(req.params.name)
res.status(200).send(details);
})
app.get('/api/artist/:name/topalbums', async (req: Request, res: Response) => {
const albums = await getTopAlbums(req.params.name);
res.status(200).send(albums);
})
app.use(express.static('public'))
app.listen(3000)