again and again 🐛
continuous-integration/drone/push Build is passing Details

BackupApi
Emre KARTAL 2 years ago
parent 3f24541eb0
commit 2a87fbbc81

@ -1,129 +0,0 @@
// import { useState } from "react";
// import SpotifyService from "../services/spotify/spotify.service";
// import { makeRedirectUri, useAuthRequest } from 'expo-auth-session';
// class StubManager{
// // injection de dépences
// spotifyService = new SpotifyService();
// // userService = new userService();
// private currentUser = useState(null);
// private discovery = {
// authorizationEndpoint: 'https://accounts.spotify.com/authorize',
// tokenEndpoint: 'https://accounts.spotify.com/api/token',
// };
// constructor() {
// }
// // spotify methods
// apiAuthorization(url : string){
// const [, response, promptAsync] = useAuthRequest(
// {
// clientId: '1f1e34e4b6ba48b388469dba80202b10',
// scopes: ['user-read-email', 'playlist-modify-public'],
// // In order to follow the "Authorization Code Flow" to fetch token after authorizationEndpoint
// // this must be set to false
// usePKCE: false,
// redirectUri: makeRedirectUri({
// scheme: 'flad'
// }),
// },
// this.discovery
// );
// }
// getCompleteMusic = async (id : string) :Promise<Music> =>{
// // Map info = await spotifyService.getTrackInfo(id);
// // return Music(id, info['name'], info['artist'], info['cover']);
// }
// removeFromPlaylist(id : string) {
// this.spotifyService.removeFromPlaylist(id);
// }
// addToPlaylist(id : string) {
// this.spotifyService.addToPlaylist(id);
// }
// playTrack(id : string) {
// this.spotifyService.playTrack(id);
// }
// ////////////////////////////////////////////
// // private readonly getTaskById: RequestHandler = async (
// // req: Request,
// // res: Response,
// // next: NextFunction
// // ): Promise<Response | void> => {
// // try {
// // const id = req.params.taskId;
// // const userId = req.params.userId;
// // const data = await this.Taskservice.getTaskById(id, userId);
// // res.status(201).send(data);
// // }
// // catch(error){
// // next(new HttpException(400, 'Cannot create post'));
// // }
// // }
// // private delete = async (
// // req: Request,
// // res: Response,
// // next: NextFunction
// // ): Promise<Response | void> => {
// // try {
// // const id = req.params.taskId;
// // const userId = req.params.userId;
// // await this.Taskservice.DeleteTask(id, userId);
// // return res.status(200).send({ status: "Success", msg: "Data Removed" });
// // } catch (error) {
// // next(new HttpException(400, 'Cannot create post'));
// // }
// // };
// // private updateTask = async (
// // req: Request,
// // res: Response,
// // next: NextFunction
// // ): Promise<Response | void> => {
// // try {
// // const taskId = req.params.taskId;
// // const userId = req.params.userId;
// // const reqBody:CreateTaskReqBody = Object.assign({}, req.body);
// // const updatedTask = await this.Taskservice.UpdateTask(
// // // req.auth!.uid,
// // taskId,
// // userId,
// // // firebase.auth().currentUser.getIdToken()
// // reqBody.nom,
// // reqBody.description,
// // reqBody.logo,
// // reqBody.duration,
// // reqBody.done,
// // // reqBody.tags,
// // reqBody.repepat,
// // reqBody.deb,
// // reqBody.fin
// // );
// // // res.send('Success add');
// // // res.status(201).json({ task });
// // res.status(204).send(`Update a new contact: ${updatedTask}`);
// // } catch (error) {
// // console.log(error);
// // next(new HttpException(403, 'Cannot create post'));
// // }
// // };
// }
// export default StubManager;

@ -1,30 +0,0 @@
import { useState } from 'react';
import { View, Text, StyleSheet, TextInput } from 'react-native'
interface InputProps {
name: string;
placeholder: string;
}
const FladInput = ({ name, placeholder }: InputProps) => {
const [focused, setFocused] = useState<boolean>(false);
return (
<View>
<Text></Text>
<TextInput style={[styles.input]}>
</TextInput>
</View>
);
};
const styles = StyleSheet.create({
input: {
justifyContent: 'center',
alignItems: 'center',
placeholder: "placeholde"
},
})
export default FladInput;

@ -6,24 +6,15 @@ import { makeRedirectUri, useAuthRequest } from 'expo-auth-session';
import { Buffer } from 'buffer'; import { Buffer } from 'buffer';
import * as SecureStore from 'expo-secure-store'; import * as SecureStore from 'expo-secure-store';
//generate random string
export const MY_SECURE_AUTH_STATE_KEY = 'MySecureAuthStateKey' export const MY_SECURE_AUTH_STATE_KEY = 'MySecureAuthStateKey'
WebBrowser.maybeCompleteAuthSession() WebBrowser.maybeCompleteAuthSession()
// Endpoint
const discovery = { const discovery = {
authorizationEndpoint: 'https://accounts.spotify.com/authorize', authorizationEndpoint: 'https://accounts.spotify.com/authorize',
tokenEndpoint: 'https://accounts.spotify.com/api/token', tokenEndpoint: 'https://accounts.spotify.com/api/token',
}; };
// save the spotifyToken
async function save(key: string, value: string) {
await SecureStore.setItemAsync(key, value)
}
export default function Login() { export default function Login() {
const [request] = useAuthRequest( const [request] = useAuthRequest(
{ {
@ -42,7 +33,6 @@ export default function Login() {
const scopesArr = ['user-read-private', 'user-read-email', 'user-read-playback-state', 'user-read-currently-playing', 'user-read-recently-played', 'playlist-modify-public', 'ugc-image-upload', 'user-modify-playback-state']; const scopesArr = ['user-read-private', 'user-read-email', 'user-read-playback-state', 'user-read-currently-playing', 'user-read-recently-played', 'playlist-modify-public', 'ugc-image-upload', 'user-modify-playback-state'];
const scopes = scopesArr.join(' '); const scopes = scopesArr.join(' ');
//work so use this for my implementation
const getAuthorizationCode = async () => { const getAuthorizationCode = async () => {
try { try {
const redirectUrl = "https://auth.expo.io/@anonymous/FLAD-7eafd441-fd6b-4fb6-924c-ec2b0ed5ce6d" const redirectUrl = "https://auth.expo.io/@anonymous/FLAD-7eafd441-fd6b-4fb6-924c-ec2b0ed5ce6d"
@ -64,7 +54,7 @@ export default function Login() {
const getTokens = async () => { const getTokens = async () => {
try { try {
const authorizationCode = await getAuthorizationCode() const authorizationCode = await getAuthorizationCode()
const response = await fetch('https://accounts.spotify.com/api/token', { await fetch('https://accounts.spotify.com/api/token', {
method: 'POST', method: 'POST',
headers: { headers: {
Authorization: 'Basic ' + (Buffer.from('1f1e34e4b6ba48b388469dba80202b10' + ':' + '779371c6d4994a68b8dd6e84b0873c82').toString('base64')), Authorization: 'Basic ' + (Buffer.from('1f1e34e4b6ba48b388469dba80202b10' + ':' + '779371c6d4994a68b8dd6e84b0873c82').toString('base64')),

@ -67,7 +67,7 @@ export default class SpotifyService implements IspotifyService {
} }
public async searchMusic(text: string): Promise<Music[]> { public async searchMusic(text: string): Promise<Music[]> {
var requestData: string = '/search'; const requestData: string = '/search';
const fetchOptions: FetchOptions = { const fetchOptions: FetchOptions = {
params: { params: {
q: text, q: text,
@ -114,7 +114,6 @@ export default class SpotifyService implements IspotifyService {
}; };
const respMusic = await this.spotifyRequestHandler.spotifyFetch(requestData, fetchOptions, this.token); const respMusic = await this.spotifyRequestHandler.spotifyFetch(requestData, fetchOptions, this.token);
console.log(respMusic.data); console.log(respMusic.data);
return;
} }
public async getSimilarTrack(musicId: string, limit: number = 1, market?: string): Promise<Music[]> { public async getSimilarTrack(musicId: string, limit: number = 1, market?: string): Promise<Music[]> {
@ -122,7 +121,7 @@ export default class SpotifyService implements IspotifyService {
'?limit=' + limit + '?limit=' + limit +
'&market=FR' + '&market=FR' +
'&seed_tracks=' + musicId; '&seed_tracks=' + musicId;
var respSimilarMusic; let respSimilarMusic;
try { try {
respSimilarMusic = await this.spotifyRequestHandler.spotifyFetch(requestData, {}, this.token); respSimilarMusic = await this.spotifyRequestHandler.spotifyFetch(requestData, {}, this.token);
} catch (error) { } catch (error) {

@ -34,9 +34,7 @@ export class RequestHandler {
}); });
return resp; return resp;
} }
catch(error : any){ catch(error : any){}
const errorMessage = error.response.data?.error?.message;
}
} }
} }

Loading…
Cancel
Save