parent
08fc7f64ab
commit
4c1199c6ba
Binary file not shown.
@ -1,8 +1,13 @@
|
||||
const express = require('express');
|
||||
const router = express.Router();
|
||||
const AuthController = require('../controllers/AuthController');
|
||||
const SessionController = require('../controllers/SessionController');
|
||||
|
||||
// Routes pour l'authentification
|
||||
router.post('/auth/signup', AuthController.signUp);
|
||||
router.post('/auth/signin', AuthController.signIn);
|
||||
|
||||
// Routes pour les sessions
|
||||
router.get('/session', SessionController.getUserInformation);
|
||||
|
||||
module.exports = router;
|
||||
|
@ -0,0 +1,27 @@
|
||||
class SessionService {
|
||||
static async getSession() {
|
||||
try {
|
||||
const response = await fetch('http://localhost:3000/session', {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
credentials: 'include',
|
||||
});
|
||||
|
||||
if (response.ok) {
|
||||
const result = await response.json();
|
||||
return result;
|
||||
} else {
|
||||
const errorResponse = await response.json();
|
||||
throw new Error(errorResponse.error);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default SessionService;
|
||||
|
Loading…
Reference in new issue