Skip to content

Instantly share code, notes, and snippets.

@lebowvsky
lebowvsky / index.js
Created June 2, 2020 10:23
Express 03 - POST
const connection = require('./conf');
const express = require('express');
const app = express();
const port = 3000;
app.use(express.json());
app.use(express.urlencoded({extended: true}));
app.get('/api/employees', (req, res) => {
@lebowvsky
lebowvsky / results.txt
Last active June 1, 2020 15:43
06 SQL Avancé
SELECT t.name, COUNT(p.wizard_id) AS nb_player
FROM player p
LEFT JOIN team t ON t.id=p.team_id
GROUP BY t.name
ORDER BY nb_player DESC;
SELECT t.name, COUNT(p.wizard_id) AS nb_player
FROM player p
LEFT JOIN team t ON t.id=p.team_id
@lebowvsky
lebowvsky / db.sql
Created May 29, 2020 20:39
05 - Les Jointures
SELECT w.firstname, w.lastname, p.role, t.name
FROM wizard w
LEFT JOIN player p ON w.id=p.wizard_id
LEFT JOIN team t ON p.team_id=t.id
ORDER BY t.name, p.role, w.lastname, w.firstname;
SELECT w.firstname, w.lastname, p.role
FROM wizard w
INNER JOIN player p ON w.id=p.wizard_id
@lebowvsky
lebowvsky / requests.http
Last active May 26, 2020 13:55
Protocole HTTP
### GET wilder
GET https://http-practice.herokuapp.com/wilders
Accept: application/json
### GET wilder
GET https://http-practice.herokuapp.com/wilders?language=Java&page=2
Accept: application/json
### POST wilder
POST https://http-practice.herokuapp.com/wilders
@lebowvsky
lebowvsky / notions.txt
Created May 26, 2020 12:46
Introduction au développement back-end JS/TS
- Le protocole HTTP est une manière normalisée de gerer l'émission d'une requête et la reception de la réponse contenant des données.
- La Base de donnée est la partie où sont stockées les données qu'il n'est possible d'interroger que par l'intermediaire d'un langage propre (SQL pour MySQL).
- Le Serveur d'application est l'intermediaire indispensable pour interagir avec la BDD. Ces Serveurs d'application sont généralement codés en ava, PHP, C#, Python et Ruby et plus récemment Javascript grâce à Node.js.
@lebowvsky
lebowvsky / index.js
Created May 26, 2020 12:30
EXPRESS 2
const connection = require('./conf');
const express = require('express');
const app = express();
const port = 3000;
app.get('/api/employees', (req, res) => {
connection.query('SELECT * from employee', (err, results) => {
if(err) {
console.log(err);
@lebowvsky
lebowvsky / db.sql
Created May 25, 2020 15:21
03 - Manipulation des données
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);
UPDATE school SET country='Sweden' WHERE name='Durmstrang Institute';
UPDATE school SET capacity=700 WHERE name='Mahoutokoro School of Magic';
DELETE FROM school WHERE name LIKE '%Magic';
+----+-----------+----------+------------+-------------+---------------------------------------+-----------+
| id | firstname | lastname | birthday | birth_place | biography | is_muggle |
+----+-----------+----------+------------+-------------+---------------------------------------+-----------+
| 1 | harry | potter | 1980-07-31 | london | | 0 |
| 2 | hermione | granger | 1979-09-19 | | Friend of Harry Potter | 0 |
| 4 | ron | weasley | 1980-03-01 | | Best friend of Harry | 0 |
| 5 | ginny | weasley | 1981-08-11 | | Sister of Ron and girlfriend of Harry | 0 |
| 6 | fred | weasley | 1978-04-01 | | | 0 |
| 7 | george | weasley | 1978-04-01 | | | 0 |
| 10 | drago | malefoy | 1980-06-05 |
@lebowvsky
lebowvsky / script.ts
Created May 18, 2020 22:39
Découverte du TypeScript
function hello(name: string) {
console.log("Hello " + name);
}
var firstName = "bob";
hello(firstName);
hello(firstName + " marley");
function concat(a: string, b: string) {
@lebowvsky
lebowvsky / index.js
Created March 29, 2020 15:26
Express1 - Découverte d'Express
const express = require('express');
const app = express();
const port = 3000;
app.get('/api/movies', (req, res) => {
res.send('Récupération de tous les films');
});
app.get('/api/movies/:id', (req, res) => {