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
// challenge.ts | |
interface User { | |
name: string; | |
age?: number; | |
birthday?: string; | |
} | |
const prettyPrintWilder = (users: User[]): void => { | |
users.map((user: User) => { | |
console.log(`${user.name} is ${user.age} years old`); |
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
const authRouter = require('express').Router(); | |
const User = require('../models/user'); | |
const { calculateToken } = require('../helpers/users'); | |
authRouter.post('/sessions', (req, res) => { | |
const { email, password } = req.body; | |
User.findByEmail(email).then((user) => { | |
if (!user) res.status(401).send('Invalid credentials'); | |
else { | |
User.verifyPassword(password, user.hashedPassword).then( |
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
moviesRouter.get('/', (req, res) => { | |
const { user_token } = req.cookies; | |
User.findByToken(user_token).then((user) => { | |
User.movies(user.id).then((movies) => { | |
res.send(movies) | |
}).catch(() => res.status(500).send('Error')) | |
}).catch(()=>res.status(401).send('Unauthorized access')) | |
}); |
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
const authRouter = require('express').Router(); | |
const User = require('../models/user'); | |
authRouter.post('/checkCredentials', (req, res) => { | |
const { email, password } = req.body; | |
User.findByEmail(email).then((user) => { | |
if (!user) res.status(401).send('Invalid credentials'); | |
else { | |
User.verifyPassword(password, user.hashedPassword).then( |
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
SELECT team.name, COUNT(*) as nb_player FROM team INNER JOIN player ON player.team_id=team.id GROUP BY team.name ORDER BY nb_player DESC; | |
+------------+-----------+ | |
| name | nb_player | | |
+------------+-----------+ | |
| Gryffindor | 36 | | |
| Slytherin | 21 | | |
| Ravenclaw | 15 | | |
| Hufflepuff | 12 | | |
+------------+-----------+ |
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
1/Retourne les noms, prénoms, rôle et équipe de tous les joueurs, classés dans l’ordre alphabétique par équipe, puis par rôle dans l’équipe, puis par nom de famille, puis par prénom : | |
SELECT firstname,lastname,name,role | |
FROM player | |
INNER JOIN wizard ON wizard.id=player.wizard_id | |
INNER JOIN team ON team.id=player.team_id | |
ORDER BY name,role,firstname,firstname; | |
2/Retourne uniquement les prénoms et noms des joueurs ayant le rôle de seeker (attrapeur), classés par ordre alphabétique de nom puis prénom : |
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
const connection = require('./db-config'); | |
const express = require('express'); | |
const app = express(); | |
const Joi = require('joi'); | |
const port = process.env.PORT || 3000; | |
connection.connect((err) => { | |
if (err) { | |
console.error('error connecting: ' + err.stack); |
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
\A\. | |
[0-9]./[0-9]./[0-9]{4} | |
\ [0-9]\/[0-9]{2} | |
[a-z]{14}/gi | |
/\w+(:\/\/)\w+\.\w+\.\w+\/\w+\/\w+/ |
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
const connection = require("./db-config"); | |
const express = require("express"); | |
const app = express(); | |
const port = process.env.PORT ?? 3000; | |
connection.connect((err) => { | |
if (err) { | |
console.error("error connecting: " + err.stack); | |
} else { |
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
const connection = require("./db-config"); | |
const express = require("express"); | |
const app = express(); | |
const port = process.env.PORT ?? 3000; | |
connection.connect((err) => { | |
if (err) { | |
console.error("error connecting: " + err.stack); | |
} else { |
NewerOlder