Skip to content

Commit b8fe814

Browse files
author
Dan Zajdband
committed
move to firebase + zeit
1 parent 3f293ea commit b8fe814

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+8457
-2477
lines changed

.gitignore

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1 @@
1-
node_modules
2-
.DS_Store
3-
config.json
4-
npm-debug.log
5-
public/app.js
6-
public/*.app.js
7-
public/uploads/*
8-
!public/uploads/.gitkeep
9-
!public/uploads/s
10-
public/uploads/s/*
11-
!public/uploads/s/.gitkeep
1+
.env

api.js

Lines changed: 0 additions & 105 deletions
This file was deleted.

api/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules

api/assets/search.js

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/**
2+
* Module dependencies
3+
*/
4+
5+
const axios = require('axios');
6+
7+
/**
8+
* Module constants
9+
*/
10+
11+
const FLICKR_BASE_URL = 'https://api.flickr.com/services/rest/?method=flickr.photos.search'
12+
const FLICKR_PARAMS = `&per_page=5&license=1,2,3,4,5,6,7&format=json&nojsoncallback=1&extras=url_o,url_k,url_t&api_key=${process.env.FLICKR_SECRET_KEY}`
13+
const FREESOUND_BASE_URL = 'http://www.freesound.org/apiv2'
14+
15+
module.exports = (req, res) => {
16+
const { type, query } = req.query
17+
18+
switch (type) {
19+
case 'image':
20+
axios.get(`${FLICKR_BASE_URL}${FLICKR_PARAMS}&text=${query}`)
21+
.then(({ data }) => res.json(data.photos.photo))
22+
.catch(() => res.status(500).send('error'))
23+
break
24+
case 'panorama':
25+
default:
26+
axios.get(`${FLICKR_BASE_URL}${FLICKR_PARAMS}&group_id=44671723@N00&text=${query}`)
27+
.then(({ data }) => res.json(data.photos.photo))
28+
.catch(() => res.status(500).send('error'))
29+
break
30+
case 'audio':
31+
axios.get(`${FREESOUND_BASE_URL}/search/text/?query=${query}&token=${process.env.FREESOUND_SECRET_KEY}`)
32+
.then(({ data }) => {
33+
if (!data.length) return ''
34+
35+
fetch(`${FREESOUND_BASE_URL}/sounds/${results[0].id}/?token=${process.env.FREESOUND_SECRET_KEY}`)
36+
.then(({ data }) => res.json(data.previews['preview-hq-mp3'].replace('http://', 'https://')))
37+
.catch(() => res.status(500).send('error'))
38+
})
39+
.catch(() => res.status(500).send('error'))
40+
break
41+
}
42+
}

0 commit comments

Comments
 (0)