Skip to content

Commit

Permalink
Make repo public
Browse files Browse the repository at this point in the history
  • Loading branch information
pclavier92 committed Sep 26, 2020
0 parents commit a763931
Show file tree
Hide file tree
Showing 130 changed files with 16,701 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"presets": [
"@babel/preset-env",
"@babel/preset-react"
],
"plugins": [
"@babel/plugin-proposal-class-properties"
]
}
13 changes: 13 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"parser": "babel-eslint",
"extends": ["airbnb"],
"env": {
"browser": true,
"node": true
},
"rules": {
"no-console": "off",
"comma-dangle": "off",
"react/jsx-filename-extension": "off"
}
}
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.vscode
node_modules
dist
*.log
3 changes: 3 additions & 0 deletions nodemon.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"watch": ["src/server/"]
}
9,995 changes: 9,995 additions & 0 deletions package-lock.json

Large diffs are not rendered by default.

64 changes: 64 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
{
"name": "radio-i",
"version": "1.0.0",
"repository": {
"type": "git",
"url": "git://github.com/pclavier92/radio-i.git"
},
"description": "App based on Spotify Web API to stream playlist live and share music",
"main": "src/server/index.js",
"scripts": {
"build": "webpack --env.SCOPE=prod --mode production",
"build-preprod": "webpack --env.SCOPE=preprod --mode production",
"start": "env SCOPE=prod node src/server/index.js",
"preprod": "npm run build-preprod && env SCOPE=preprod node src/server/index.js",
"client": "webpack-dev-server --env.SCOPE=dev --mode development --devtool inline-source-map --hot",
"server": "nodemon src/server/index.js",
"dev": "env SCOPE=dev concurrently \"npm run server\" \"npm run client\""
},
"author": "Philippe Clavier",
"license": "ISC",
"dependencies": {
"axios": "^0.19.2",
"webpack": "^4.5.0",
"babel-polyfill": "^6.26.0",
"express": "^4.17.1",
"express-session": "^1.17.1",
"cookie-parser": "^1.4.4",
"cors": "^2.8.5",
"mysql": "^2.18.1",
"crypto-js": "^4.0.0",
"prop-types": "^15.7.2",
"react": "^16.5.2",
"react-dom": "^16.5.2",
"@material-ui/core": "^4.9.13",
"@material-ui/icons": "^4.9.1",
"react-emoji-render": "^1.2.4",
"react-router-dom": "^5.1.2",
"request": "^2.88.0",
"ws": "^7.2.5"
},
"devDependencies": {
"@babel/core": "^7.0.0",
"@babel/plugin-proposal-class-properties": "^7.0.0",
"@babel/preset-env": "^7.0.0",
"@babel/preset-react": "^7.0.0",
"babel-eslint": "^10.0.0",
"babel-loader": "^8.0.0",
"clean-webpack-plugin": "^1.0.0",
"concurrently": "^5.3.0",
"css-loader": "^2.0.0",
"eslint": "^5.0.0",
"eslint-config-airbnb": "^17.0.0",
"eslint-plugin-import": "^2.11.0",
"eslint-plugin-jsx-a11y": "^6.0.3",
"eslint-plugin-react": "^7.7.0",
"file-loader": "^3.0.0",
"html-webpack-plugin": "^3.2.0",
"nodemon": "^2.0.3",
"style-loader": "^0.23.0",
"url-loader": "^1.0.1",
"webpack-cli": "^3.3.12",
"webpack-dev-server": "^3.1.3"
}
}
Binary file added public/favicon.ico
Binary file not shown.
20 changes: 20 additions & 0 deletions public/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>RadioI</title>
<link
href="https://fonts.googleapis.com/css?family=Montserrat:100,200,300,300i,400,500&display=swap"
rel="stylesheet"
/>
<link
href="https://fonts.googleapis.com/icon?family=Material+Icons"
rel="stylesheet"
/>
</head>
<body>
<div id="root"></div>
</body>
</html>
39 changes: 39 additions & 0 deletions schema.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
DROP DATABASE IF EXISTS radioidb;
CREATE DATABASE radioidb;
USE radioidb;

CREATE TABLE `User` (
`id` varchar(256) NOT NULL,
`name` varchar(128) DEFAULT NULL,
`email` varchar(128) DEFAULT NULL,
`country` varchar(128) DEFAULT NULL,
`premium` TINYINT(1) DEFAULT 0,
`access_token` varchar(256) DEFAULT NULL,
`last_activity` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

CREATE TABLE `Radio` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`hash` varchar(256) NOT NULL,
`user_id` varchar(256) DEFAULT NULL,
`name` varchar(50) DEFAULT NULL,
`is_public` TINYINT(1) DEFAULT 0,
`is_collaborative` TINYINT(1) DEFAULT 0,
`is_anonymous` TINYINT(1) DEFAULT 0,
`song_id` varchar(256) DEFAULT NULL,
`timestamp_ms` BIGINT UNSIGNED DEFAULT 0,
PRIMARY KEY (`id`),
FOREIGN KEY `FK_Radio_User` (`user_id`) REFERENCES `User` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

CREATE TABLE `RadioQueue` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`radio_id` int(11) NOT NULL,
`song_id` varchar(256) DEFAULT NULL,
`duration` int(11) DEFAULT NULL,
`position` int(11) DEFAULT NULL,
`played` TINYINT(1) DEFAULT 0,
PRIMARY KEY (`id`),
FOREIGN KEY `FK_RadioQueue_Steam` (`radio_id`) REFERENCES `Radio` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
143 changes: 143 additions & 0 deletions src/client/apis/radioi-api.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
import axios from 'axios';

import { serverUrl } from '../config';

import authService from '../services/authentication';

const logOut = () => {
const accessToken = authService.getAccessToken();
return axios.delete(`${serverUrl}/logout`, {
headers: {
Authorization: `Bearer ${accessToken}`
}
});
};

const refreshSession = () => {
const accessToken = authService.getAccessToken();
return axios.get(`${serverUrl}/refresh_session`, {
withCredentials: true,
headers: {
Authorization: `Bearer ${accessToken}`
}
});
};

const refreshAccessToken = () => {
const accessToken = authService.getAccessToken();
const refreshToken = authService.getRefreshToken();
return axios.get(`${serverUrl}/refresh_token`, {
params: { access_token: accessToken, refresh_token: refreshToken }
});
};

const startRadio = (id, name, isPublic, isCollaborative, isAnonymous) => {
const accessToken = authService.getAccessToken();
return axios.post(
`${serverUrl}/api/radio`,
{ id, name, isPublic, isCollaborative, isAnonymous },
{
headers: {
Authorization: `Bearer ${accessToken}`,
'Content-Type': 'application/json'
}
}
);
};

const stopRadio = () => {
const accessToken = authService.getAccessToken();
return axios.delete(`${serverUrl}/api/radio`, {
headers: {
Authorization: `Bearer ${accessToken}`
}
});
};

const getRadio = id => {
const accessToken = authService.getAccessToken();
return axios.get(`${serverUrl}/api/radio`, {
params: { id },
headers: {
Authorization: `Bearer ${accessToken}`
}
});
};

const addSongToRadio = (radioId, songId, duration) => {
const accessToken = authService.getAccessToken();
return axios.post(
`${serverUrl}/api/radio/song`,
{ radioId, songId, duration },
{
headers: {
Authorization: `Bearer ${accessToken}`,
'Content-Type': 'application/json'
}
}
);
};

const removeSongFromQueue = (id, position) => {
const accessToken = authService.getAccessToken();
return axios.delete(`${serverUrl}/api/radio/song`, {
params: { id, position },
headers: {
Authorization: `Bearer ${accessToken}`
}
});
};

const getRadioQueue = id => {
const accessToken = authService.getAccessToken();
return axios.get(`${serverUrl}/api/radio/queue`, {
params: { id },
headers: {
Authorization: `Bearer ${accessToken}`
}
});
};

const getRadioPlayedSongs = id => {
const accessToken = authService.getAccessToken();
return axios.get(`${serverUrl}/api/radio/played`, {
params: { id },
headers: {
Authorization: `Bearer ${accessToken}`
}
});
};

const getLatestRadio = () => {
const accessToken = authService.getAccessToken();
return axios.get(`${serverUrl}/api/radio/latest`, {
headers: {
Authorization: `Bearer ${accessToken}`
}
});
};

const getRadioChats = id => {
const accessToken = authService.getAccessToken();
return axios.get(`${serverUrl}/api/radio/chats`, {
params: { id },
headers: {
Authorization: `Bearer ${accessToken}`
}
});
};

export default {
logOut,
refreshSession,
refreshAccessToken,
startRadio,
stopRadio,
getRadio,
addSongToRadio,
removeSongFromQueue,
getRadioQueue,
getRadioPlayedSongs,
getLatestRadio,
getRadioChats
};
Loading

0 comments on commit a763931

Please sign in to comment.