@ -0,0 +1,68 @@
|
||||
import express, { Application } from 'express';
|
||||
// import compression from 'compression';
|
||||
import cors from 'cors';
|
||||
// import db from './database';
|
||||
// import morgan from 'morgan';
|
||||
import Controller from './controller/Icontroller';
|
||||
// import ErrorMiddleware from './middleware/error.middleware';
|
||||
import bodyParser from 'body-parser';
|
||||
|
||||
// to secure
|
||||
// import helmet from 'helmet';
|
||||
|
||||
import http from 'http';
|
||||
|
||||
class App {
|
||||
public express: Application;
|
||||
public port: number;
|
||||
public dataBase: null;
|
||||
|
||||
public server : any;
|
||||
|
||||
constructor(controllers: Controller[], port: number) {
|
||||
this.express = express();
|
||||
this.port = port;
|
||||
this.dataBase = null;
|
||||
|
||||
// this.initialiseDatabase();
|
||||
this.initialiseMiddleware();
|
||||
this.initialiseControllers(controllers);
|
||||
|
||||
// this.initialiseErrorHandling();
|
||||
}
|
||||
|
||||
private initialiseMiddleware(): void {
|
||||
// this.express.use(helmet());
|
||||
this.express.use(cors());
|
||||
// this.express.use(morgan('dev'));
|
||||
this.express.use(express.json());
|
||||
this.express.use(express.urlencoded({ extended: false }));
|
||||
// this.express.use(compression());
|
||||
// mine
|
||||
this.express.use(bodyParser.json());
|
||||
this.express.use(bodyParser.urlencoded({
|
||||
extended: true
|
||||
}));
|
||||
|
||||
}
|
||||
|
||||
private initialiseControllers(controllers: Controller[]): void {
|
||||
controllers.forEach((controller: Controller) => {
|
||||
this.express.use('/api', controller.router);
|
||||
});
|
||||
}
|
||||
|
||||
// private initialiseErrorHandling(): void {
|
||||
// this.express.use(ErrorMiddleware);
|
||||
// }
|
||||
|
||||
public listen(): void {
|
||||
const server = this.express.listen(this.port, () => {
|
||||
console.log(`⚡️[server] : App listening on the port ${this.port}`);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
export default App;
|
@ -0,0 +1,15 @@
|
||||
import { Router } from 'express';
|
||||
|
||||
interface Controller {
|
||||
path: string;
|
||||
router: Router;
|
||||
// constructor() {
|
||||
// this.initialiseRoutes();
|
||||
// }
|
||||
|
||||
// initialiseRoutes(): void ;
|
||||
|
||||
}
|
||||
// il y a un truc inject
|
||||
|
||||
export default Controller;
|
@ -0,0 +1,27 @@
|
||||
import { Router } from "express";
|
||||
import Controller from "./Icontroller";
|
||||
|
||||
type PingResponse = {
|
||||
message: string;
|
||||
}
|
||||
|
||||
export default class PingController implements Controller {
|
||||
public path = '/ping';
|
||||
public router = Router();
|
||||
|
||||
constructor() {
|
||||
this.initialiseRoutes();
|
||||
}
|
||||
|
||||
private initialiseRoutes(): void {
|
||||
this.router.get("/ping", async (_req, res) => {
|
||||
const response = await this.getMessage();
|
||||
return res.send(response);
|
||||
});
|
||||
}
|
||||
async getMessage(): Promise<PingResponse> {
|
||||
return {
|
||||
message: "pong",
|
||||
};
|
||||
}
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
// export const loggerOptions: expressWinston.LoggerOptions = {
|
||||
// transports: [new winston.transports.Console()],
|
||||
// format: winston.format.combine(
|
||||
// winston.format.json(),
|
||||
// winston.format.prettyPrint(),
|
||||
// winston.format.colorize({ all: true })
|
||||
// ),
|
||||
// };
|
@ -0,0 +1,11 @@
|
||||
import App from "./app";
|
||||
import PingController from "./controller/TestCtrl";
|
||||
|
||||
const app = new App(
|
||||
[new PingController()],
|
||||
Number(8080)
|
||||
// Number(process.env.PORT)
|
||||
|
||||
);
|
||||
|
||||
app.listen();
|
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 142 KiB |
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 142 KiB |
After Width: | Height: | Size: 5.8 KiB |
After Width: | Height: | Size: 1.9 KiB |
After Width: | Height: | Size: 1.3 KiB |
After Width: | Height: | Size: 2.4 KiB |
Before Width: | Height: | Size: 46 KiB After Width: | Height: | Size: 51 KiB |
@ -1,73 +1,80 @@
|
||||
import { View, Text, Image, Animated ,PanResponder, Dimensions } from 'react-native'
|
||||
import React, { useRef, useState, useTransition } from 'react'
|
||||
import { View, Text, Image, Animated ,PanResponder, Dimensions, StyleSheet, ImageBackground, Button, Pressable } from 'react-native'
|
||||
import React, { useCallback, useRef, useState, useTransition } from 'react'
|
||||
import { LinearGradient } from 'expo-linear-gradient';
|
||||
import * as Haptics from 'expo-haptics';
|
||||
|
||||
import Card from '../components/Card';
|
||||
|
||||
import { cards as cardArray } from '../FakeData/data'
|
||||
|
||||
const {width : wWidht} = Dimensions.get("window");
|
||||
const width = wWidht *0.75;
|
||||
const height = wWidht * (465/264);
|
||||
const borderRadius = 24;
|
||||
|
||||
interface SpotProps {
|
||||
title: string;
|
||||
image: any;
|
||||
onSwipe: (direction: "left" | "right") => void;
|
||||
}
|
||||
|
||||
}
|
||||
const Spot: React.FC<SpotProps> = () => {
|
||||
|
||||
const Spot: React.FC<SpotProps> = ({ title, image, onSwipe }) => {
|
||||
const [cards, setCards] = useState(cardArray);
|
||||
const aIndex = useTransition();
|
||||
const onSwipe = (index: number, direction: 'left' | 'right') => {
|
||||
const [cards, setCards] = useState(cardArray);
|
||||
const onSwipe = (index: number, direction: 'left' | 'right') => {
|
||||
if (direction === 'right') {
|
||||
// Swiped right
|
||||
console.log('Swiped right');
|
||||
|
||||
// Swiped right
|
||||
console.log("===================")
|
||||
} else if (direction === 'left') {
|
||||
console.log('Swiped left');
|
||||
// Swiped left
|
||||
}
|
||||
// update the state of the card or the app
|
||||
setCards(cards.filter((_, i) => i !== index));
|
||||
};
|
||||
};
|
||||
|
||||
const hapti = (() => {
|
||||
|
||||
// const [currentCard, setCurrentCard] = useState(0);
|
||||
// Haptics.NotificationFeedbackType.Success
|
||||
Haptics.impactAsync(Haptics.ImpactFeedbackStyle.Heavy)
|
||||
});
|
||||
|
||||
return (
|
||||
|
||||
<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center', position : 'absolute', backgroundColor : '' }}>
|
||||
<View style={styles.spot}>
|
||||
|
||||
{cards.map((card, index) => (
|
||||
<View key={card.name}>
|
||||
|
||||
<View key={card.name} style = {{ position:'absolute'
|
||||
}} >
|
||||
<Pressable onLongPress={hapti}>
|
||||
|
||||
<Card
|
||||
title={card.name}
|
||||
image={card.sourceUrl}
|
||||
onSwipe={(direction) => onSwipe(index, direction)}
|
||||
/>
|
||||
</Pressable>
|
||||
<Button
|
||||
title="Success"
|
||||
onPress={
|
||||
() =>
|
||||
Haptics.notificationAsync(
|
||||
Haptics.NotificationFeedbackType.Success
|
||||
)
|
||||
}
|
||||
/>
|
||||
</View>
|
||||
))}
|
||||
</View>
|
||||
|
||||
|
||||
|
||||
// <View style={styles.container}>
|
||||
// <Text>Open up App.tsx to start working on your app!</Text>
|
||||
// {/* <View>
|
||||
// <Animated.View>
|
||||
{/* <LinearGradient
|
||||
// Background Linear Gradient
|
||||
colors={['rgba(0,0,0,0.8)', 'transparent']}
|
||||
|
||||
// </Animated.View>
|
||||
// {cardArray.map( ({index}) => currentCard < index && step + step && (
|
||||
// <Card card={card} ></Card>
|
||||
/> */}
|
||||
|
||||
// ) )}
|
||||
</View>
|
||||
|
||||
// </View> */}
|
||||
// <View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
|
||||
// <Card title="Swipe me left or right" />
|
||||
// </View>
|
||||
// <StatusBar style="auto" />
|
||||
// </View>
|
||||
);
|
||||
};
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
spot : {
|
||||
flex: 1,
|
||||
alignItems: 'center',
|
||||
justifyContent: 'center',
|
||||
}
|
||||
})
|
||||
|
||||
export default Spot;
|
@ -0,0 +1,21 @@
|
||||
|
||||
// export class ApiSpotifyIdentification {
|
||||
|
||||
// private state : string;
|
||||
// private codeVerifier : string;
|
||||
// private codeChallenge : string;
|
||||
// private encodedLogs : string;
|
||||
// constructor(){
|
||||
// // this.state = _generateRandomString(16);
|
||||
// // this.codeVerifier = _generateRandomString(_generateRandomInt(43, 128));
|
||||
// // this.codeChallenge = _generateCodeChallenge();
|
||||
// // this.encodedLogs = base64.encode(utf8.encode("$clientId:$_clientSecret"));
|
||||
// }
|
||||
|
||||
// setCode(url : string){
|
||||
// throw new Error("Not implemented");
|
||||
// }
|
||||
// createToken(url : string){
|
||||
// throw new Error("Not implemented");
|
||||
// }
|
||||
// }
|
@ -1,23 +1,30 @@
|
||||
// import { ApiSpotifyIdentification } from "./ApiSpotifyIdentification";
|
||||
// import { SpotifyRequest } from "./spotifyRequestHandler/spotifyRequest";
|
||||
|
||||
export class SpotifyService {
|
||||
|
||||
private identification : ApiSpotifyIdentification;
|
||||
public request : SpotifyRequest;
|
||||
// export class SpotifyService {
|
||||
|
||||
constructor() {
|
||||
// private identification : ApiSpotifyIdentification;
|
||||
// public request : SpotifyRequest;
|
||||
|
||||
}
|
||||
// constructor() {
|
||||
// this.identification= new ApiSpotifyIdentification();
|
||||
// this.request = new SpotifyRequest();
|
||||
// }
|
||||
|
||||
get identification{
|
||||
// get id(){
|
||||
// return this.identification;
|
||||
// }
|
||||
|
||||
}
|
||||
// async apiAuth(url : string) {
|
||||
// await this.identification.setCode(url);
|
||||
// this.request = ApiSpotifyRequests(await this.identification.createToken());
|
||||
// }
|
||||
|
||||
async uploadName() {
|
||||
// async getSpotifyCredentials() {
|
||||
// const res = await axios.get('/api/spotify-credentials')
|
||||
// const spotifyCredentials = res.data
|
||||
// return spotifyCredentials
|
||||
// }
|
||||
|
||||
}
|
||||
async apiAuth(url : string) {
|
||||
await this.identification.setCode(url);
|
||||
this.request = ApiSpotifyRequests(await this.identification.createToken());
|
||||
}
|
||||
|
||||
}
|
||||
// }
|
||||
|
@ -0,0 +1,14 @@
|
||||
// import { Linking } from 'react-native';
|
||||
|
||||
|
||||
|
||||
// export class SpotifyRequest {
|
||||
|
||||
|
||||
|
||||
// constructor() {
|
||||
|
||||
// }
|
||||
|
||||
|
||||
// }
|