-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 1a4b81b
Showing
13 changed files
with
3,019 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
.git | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
lts/carbon |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
language: node_js | ||
|
||
node_js: | ||
- "lts/*" | ||
|
||
cache: | ||
directories: | ||
- "node_modules" | ||
|
||
install: | ||
- npm ci | ||
|
||
script: | ||
- npm -v | ||
- node -v | ||
|
||
deploy: | ||
- provider: script | ||
skip_cleanup: true | ||
script: npm run release | ||
on: | ||
branch: master | ||
|
||
- provider: script | ||
skip_cleanup: true | ||
script: npm run deploy:prod | ||
on: | ||
branch: master | ||
|
||
- provider: script | ||
skip_cleanup: true | ||
script: npm run deploy:stage | ||
on: | ||
branch: beta | ||
|
||
- provider: script | ||
skip_cleanup: true | ||
script: npm run release | ||
on: | ||
branch: beta | ||
|
||
notifications: | ||
email: | ||
on_success: never |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
FROM mhart/alpine-node:latest AS build | ||
WORKDIR /app | ||
ADD package*.json /app/ | ||
RUN npm ci | ||
|
||
FROM mhart/alpine-node:base | ||
COPY --from=build /app . | ||
ADD *.js ./ | ||
CMD node bin.js --port 3000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
[![Build Status](https://travis-ci.com/ricardocasares/radio-gql.svg?branch=master)](https://travis-ci.com/ricardocasares/radio-gql) | ||
![Docker Pulls](https://img.shields.io/docker/pulls/ricardocasares/radio-gql.svg) | ||
[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release) | ||
|
||
# GraphQL API for http://www.radio-browser.info | ||
|
||
Check the [playground](https://radio-gql.analogic.al) | ||
|
||
[![Deploy to now](https://deploy.now.sh/static/button.svg)](https://deploy.now.sh/?repo=https://github.com/ricardocasares/radio-gql) | ||
|
||
## Sample query | ||
|
||
```gql | ||
{ | ||
stations(query: "Electro") { | ||
url | ||
name | ||
tags | ||
} | ||
} | ||
``` | ||
|
||
## Stack | ||
|
||
- ▲ [now](https://now.sh) | ||
- docker | ||
- [polka](https://github.com/lukeed/polka) | ||
- [express-graphql](https://github.com/graphql/express-graphql) | ||
- [radio-browser](http://www.radio-browser.info) | ||
|
||
## Running the npm package | ||
|
||
```bash | ||
npm i -g radio-gql | ||
radio-gql --port 3000 | ||
``` | ||
|
||
## Running the docker image | ||
|
||
```bash | ||
docker run -p 3000:3000 ricardocasares/radio-gql | ||
``` | ||
|
||
### Build from scratch | ||
|
||
Clone the repository and inside the root folder run: | ||
|
||
```bash | ||
docker build . -t radio-gql | ||
docker run -p 3000:3000 radio-gql | ||
``` | ||
|
||
You can now visit the playground at [http://localhost:3000](http://localhost:3000) | ||
|
||
## Contributing | ||
|
||
Feel free to open an issue, pull requests are preferred. | ||
|
||
**IMPORTANT** Make sure you always create new branches from `beta`. | ||
|
||
### Automated versioning | ||
|
||
We use `semantic-release` to automate the versioning process, make sure you follow the [commit message convention explained here](https://github.com/semantic-release/semantic-release#commit-message-format). | ||
|
||
**HEADS UP:** If you are not sure how write a commit message, make your changes in your feature branch and run `npm run commit` and follow the assistant. | ||
|
||
### Releases | ||
|
||
#### Beta | ||
|
||
Create a feature branch and make a pull-request to `beta` branch. | ||
Once its merged, you can try and install the package using `@beta` dist tag on `npm`. | ||
|
||
```bash | ||
npm i -g radio-gql@beta | ||
``` | ||
|
||
#### Production | ||
|
||
Create a new pull-request from `beta` to `master` branch. | ||
Once it gets merged, the final version will be released using `@latest` dist tag on `npm`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/usr/bin/env node | ||
const server = require("./"); | ||
const port = parseInt(process.argv.slice(3), 10); | ||
|
||
const log = msg => err => { | ||
if (err) throw new Error(err); | ||
console.log(msg); | ||
}; | ||
|
||
if (!port || isNaN(port)) { | ||
throw new Error("You must provide --port NUMBER"); | ||
} | ||
|
||
server.listen(port, log(`> Listening on http://localhost:${port}/`)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
const fetch = require("isomorphic-unfetch"); | ||
|
||
const URL = "http://www.radio-browser.info/webservice"; | ||
const BY_NAME = "/json/stations/byname"; | ||
const SERVICE = `${URL}/${BY_NAME}`; | ||
const cfg = { | ||
method: "POST", | ||
headers: { | ||
Accept: "application/json", | ||
"Content-Type": "application/json", | ||
"User-Agent": "bemba/radio-gql" | ||
}, | ||
body: JSON.stringify({ order: "votes", reverse: "true", limit: 50 }) | ||
}; | ||
|
||
async function search(name) { | ||
return fetch(`${SERVICE}/${name}`, cfg).then(res => res.json()); | ||
} | ||
|
||
module.exports = { | ||
search | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
const cors = require("cors"); | ||
const polka = require("polka"); | ||
const graphql = require("express-graphql"); | ||
const schema = require("./schema"); | ||
const server = polka() | ||
.use(cors()) | ||
.use( | ||
"/", | ||
graphql({ | ||
schema, | ||
graphiql: true | ||
}) | ||
); | ||
|
||
module.exports = server; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"version": 1, | ||
"name": "radio-gql", | ||
"type": "docker", | ||
"features": { | ||
"cloud": "v2" | ||
}, | ||
"alias": ["radio-gql.analogic.al"] | ||
} |
Oops, something went wrong.