Skip to content

Instantly share code, notes, and snippets.

View CaroD59's full-sized avatar
💻
Web Developer // App Developer

Caroline Dorchies CaroD59

💻
Web Developer // App Developer
View GitHub Profile
// EXERCICE WILD CODE SCHOOL
function hello(name: string) {
console.log('Hello ' + name + ' !!');
}
const surName: string = 'Bob';
hello(surName);
hello(surName + ' Marley');
@CaroD59
CaroD59 / gist:478fe3b7b2dd90f745fe6ab5bb9eb4ff
Created June 8, 2021 08:50
Express 8 - 🔧 POST et PUT en détail : Valider la saisie utilisateur
MYSQL :
As you can see, the email must to be unique.
DESCRIBE users;
+-----------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-----------+--------------+------+-----+---------+----------------+
| id | int | NO | PRI | NULL | auto_increment |
| firstName | varchar(255) | NO | | NULL | |
| lastName | varchar(255) | NO | | NULL | |
@CaroD59
CaroD59 / gist:f76362472cafa4829a63cc32f23cab5d
Created June 7, 2021 10:03
Express 7 - POST et PUT en détail : Renvoyez une réponse adéquate
const express = require('express');
const app = express();
const connection = require('./db-config');
const port = process.env.PORT || 3000;
connection.connect((err) => {
if (err) {
console.error('error connecting: ' + err.stack);
} else {
console.log(
MySQL localhost:3306 ssl wild_db_quest SQL > select t.name team_name, count(*) as nb_player
-> from player p
-> join team t on t.id=p.team_id
-> group by team_name
-> order by nb_player;
+------------+-----------+
| team_name | nb_player |
+------------+-----------+
| Hufflepuff | 12 |
| Ravenclaw | 15 |
@CaroD59
CaroD59 / gist:bc49b9684383a8c30fe69e99480e7cb2
Created June 1, 2021 06:57
Express 6 - GET en détail
app.get('/api/allmovies', (req, res) => {
let sql = 'SELECT * FROM movies';
const sqlValues = [];
if (req.query.color) {
sql += ' WHERE color = ?';
sqlValues.push(req.query.color);
}
if (req.query.max_duration) {
if (req.query.color) {
sql += ' AND duration < ?';
MySQL localhost:3306 ssl wild_db_quest SQL > select wizard.lastname, wizard.firstname, player.role, team.name
-> from player
-> join wizard on wizard.id=player.wizard_id
-> join team on team.id=player.team_id
-> order by team.name ASC,
-> player.role ASC,
-> wizard.lastname ASC,
-> wizard.firstname ASC;
+-----------------+-------------+--------+------------+
| lastname | firstname | role | name |
@CaroD59
CaroD59 / gist:3fef0255e2ee4c714b8bf49279422670
Last active May 4, 2021 10:28
Express 5 - Méthode DELETE et suppression de données
const express = require('express');
const app = express();
const connection = require('./db-config');
const port = process.env.PORT || 3000;
connection.connect((err) => {
if (err) {
console.error('error connecting: ' + err.stack);
} else {
console.log(
mysql> INSERT INTO school (name, country, capacity)
-> VALUES ('Beauxbatons Academy of Magic', 'France', 550),
-> ('Castelobruxo', 'Brazil', 380),
-> ('Durmstrang Institute', 'Norway', 570),
-> ('Hogwarts School of Witchcraft and Wizardry', 'United Kingdom', 450),
-> ('Ilvermorny School of Witchcraft and Wizardry', 'USA', 300),
-> ('Koldovstoretz', 'Russia', 125),
-> ('Mahoutokoro School of Magic', 'Japan', 800),
-> ('Uagadou School of Magic', 'Uganda', 350);
Query OK, 8 rows affected (0.01 sec)
const http = require('http');
const port = 8000;
const url = require('url');
const exampleUrl = '/?name=Ringo&city=Liverpool';
const parsedUrl = url.parse(exampleUrl, true);
LES MONTAGES DE DOCUMENTS
dorch@DESKTOP-STLUBST MINGW64 /
$ mkdir Documents
dorch@DESKTOP-STLUBST MINGW64 /
$ ls
Documents/ cmd/ git-cmd.exe* tmp/ usr/
LICENSE.txt dev/ mingw64/ unins000.dat
ReleaseNotes.html etc/ planets.zip unins000.exe*