Nicolas Borboën
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Versions and GitHub Sync Note Insights Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       owned this note    owned this note      
    Published Linked with GitHub
    Subscribed
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    Subscribe
    --- title: Introduction à node.js author: Nicolas Borboën <nicolas.borboen@epfl.ch> tags: Talk description: Une petite introduction à node.js slideOptions: transition: slide theme: simple spotlight: enabled: false progress: true --- # node.js ![logo](https://i.imgur.com/oKZmRrc.png) <br> <br> <div class="footer2"><small>2020-02-17 / EPFL-SI / <a href="nicolas.borboen@epfl.ch">nicolas.borboen@epfl.ch</a></small></div> <!-- .slide: data-background="https://i.imgur.com/KRryd1r.png" data-contrast="on" --> <!-- credit photo: https://unsplash.com/photos/S22KDIJdOUs --> ---- ## wikipedia > Node.js est une plateforme logicielle libre en JavaScript, orientée vers les applications réseau événementielles hautement concurrentes qui doivent pouvoir monter en charge. > Elle utilise la machine virtuelle V8, la librairie libuv pour sa boucle d'évènements, et implémente sous licence MIT les spécifications CommonJS. <cite>https://fr.wikipedia.org/wiki/Node.js</cite> <!-- .slide: data-background="https://i.imgur.com/EWeTSO4.jpg" data-contrast="on" --> <!-- credit photo: https://unsplash.com/photos/CLAWRoZtlAg --> ---- ## nodejs > Node.js® est un environnement d’exécution JavaScript construit sur le [moteur JavaScript V8 de Chrome](https://v8.dev/). <cite>https://nodejs.org/fr/</cite> <!-- .slide: data-background="https://i.imgur.com/OSUszlD.png" data-contrast="on" --> <!-- credit photo: https://unsplash.com/photos/dwKiHoqqxk8 --> ---- ## V8 > V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++. It is used in Chrome and in Node.js, among others. It implements ECMAScript and WebAssembly, and runs on Windows 7 or later, macOS 10.12+, and Linux systems that use x64, IA-32, ARM, or MIPS processors. V8 can run standalone, or can be embedded into any C++ application. <cite>https://v8.dev/</cite> <!-- .slide: data-background="https://i.imgur.com/V9l85eo.jpg" data-contrast="on" --> <!-- credit photo: https://unsplash.com/photos/DNm_VO7tgUI --> ---- ## ECMAScript > ECMAScript est un ensemble de normes concernant les langages de programmation de type script et standardisées par Ecma International dans le cadre de la spécification ECMA-262. Il s'agit donc d'un standard, dont les spécifications sont mises en œuvre dans différents langages de script, comme JavaScript ou ActionScript. C'est un langage de programmation orienté prototype. <cite>https://fr.wikipedia.org/wiki/ECMAScript</cite> <!-- .slide: data-background="https://i.imgur.com/WLcVIO3.jpg" data-contrast="on" --> <!-- credit photo: https://unsplash.com/photos/JzJSybPFb3s --> ---- ## javascript > JavaScript est un langage de programmation de scripts principalement employé dans les pages web interactives et à ce titre est une partie essentielle des applications web. Avec les technologies HTML et CSS, JavaScript est parfois considéré comme l'une des technologies cœur du World Wide Web. <cite>https://fr.wikipedia.org/wiki/JavaScript</cite> <!-- .slide: data-background="https://i.imgur.com/tuMmC4l.jpg" data-contrast="on" --> <!-- credit photo: https://unsplash.com/photos/4JHMt29fvj8 --> ---- ## node vs javascript > JavaScript est un langage. node.js n'est pas un langage mais un "environnement/ensemble de logiciels" qui exécute du JavaScript normal. > Tous les navigateurs ont des moteurs JavaScript qui exécutent le JavaScript des pages web (Spidermonkey pour Firefox, V8 pour Chrome). <cite>https://stackoverflow.com/questions/38424672/newbie-javascript-vs-node-js</cite> <!-- .slide: data-background="https://i.imgur.com/CwZimz6.jpg" data-contrast="on" --> <!-- credit photo: https://unsplash.com/photos/caWM9fGhIVc --> ---- ## node vs javascript > Node.js est simplement le moteur V8 fourni avec certaines bibliothèques pour faire les I/O et du réseau, de sorte de pouvoir utiliser **JavaScript en dehors du navigateur** (par exemple pour créer des services de backend). <cite>https://stackoverflow.com/questions/38424672/newbie-javascript-vs-node-js</cite> <!-- .slide: data-background="https://i.imgur.com/FZobNFg.jpg" data-contrast="on" --> <!-- credit photo: https://unsplash.com/photos/fUEP0djb1hA --> --- # historique <!-- .slide: data-background="https://i.imgur.com/bgvtcuI.png" data-contrast="off" --> <!-- credit photo: https://learntocodetogether.com/javascript-es6-history/ --> ---- ## <!-- .slide: data-background="https://i.imgur.com/K85xoWf.png" data-contrast="off" --> <!-- credit photo: https://www.innofied.com/familiar-javascript-functions-really/ --> ---- {%youtube Sh6lK57Cuk4 %} <!-- https://youtu.be/Sh6lK57Cuk4 --> --- # fonctionnement https://fr.wikipedia.org/wiki/Moteur_JavaScript https://fr.wikipedia.org/wiki/Compilation_%C3%A0_la_vol%C3%A9e https://fr.wikipedia.org/wiki/Bytecode <cite>http://blog.js-republic.com/v8-engine-comment-ca-marche/</cite> <!-- .slide: data-background="https://i.imgur.com/F4uGM9G.png" data-contrast="on+" --> <!-- credit photo: https://unsplash.com/photos/76w_eDO1u1E --> ---- # typescript > TypeScript est un langage de programmation libre et open source développé par Microsoft qui a pour but d'améliorer et de sécuriser la production de code JavaScript. Il s'agit d'un sur-ensemble syntaxique strict de JavaScript (c'est-à-dire que tout code JavaScript correct peut être utilisé avec TypeScript). Le code TypeScript est transcompilé en JavaScript, et peut ainsi être interprété par n'importe quel navigateur web ou moteur JavaScript. <cite>https://fr.wikipedia.org/wiki/TypeScript</cite> <!-- .slide: data-background="https://i.imgur.com/MtSAgc6.jpg" data-contrast="on" --> <!-- credit photo: https://unsplash.com/photos/_fOL6ebfECQ --> ---- # Hello World <!-- .slide: data-background="https://i.imgur.com/0b9YvDd.jpg" data-contrast="on" --> <!-- credit photo: https://unsplash.com/photos/-iJgjj33eEk --> ---- ## javascript ```js <!DOCTYPE HTML> <html> <body> <p>Before the script...</p> <script> alert( 'Hello, world!' ); </script> <p>...After the script.</p> </body> </html> ``` <br> <!-- .slide: data-background="https://i.imgur.com/Bo7iZaD.png" data-contrast="on" --> <!-- credit photo: https://unsplash.com/photos/ad_0wMHtvlU --> ---- ## nodejs ```js console.log('Hello World') ``` <br> <!-- .slide: data-background="https://i.imgur.com/QCmv4Ls.jpg" data-contrast="on" --> <!-- credit photo: https://unsplash.com/photos/E-n2f1BBVI0 --> ---- ## typescript ```js let message: string = 'Hello, World!'; console.log(message); ``` <br> <!-- .slide: data-background="https://i.imgur.com/yE9inVP.jpg" data-contrast="on" --> <!-- credit photo: https://unsplash.com/photos/cWCXBzeubbc --> --- # commencer Pour commencer un projet en node.js, on utilise `npm` ou `yarn`. <!-- .slide: data-background="https://i.imgur.com/Im75ck8.jpg" data-contrast="on" --> <!-- credit photo: https://unsplash.com/photos/0BKZfcamvGg --> ---- ## npm > npm est le gestionnaire de paquets officiel de Node.js. [...] En avril 2020, GitHub annonce l'acquisition de npm. <cite>https://fr.wikipedia.org/wiki/npm</cite> <center><a href="https://www.npmjs.com/">https://www.npmjs.com</a></center> <!-- .slide: data-background="https://i.imgur.com/Dtc3DZ1.jpg" data-contrast="on" --> <!-- credit photo: https://unsplash.com/photos/Atupl1Ub51Q --> ---- ## yarn > Yarn is a package manager for your code. It allows you to use and share code with other developers from around the world. Yarn does this quickly, securely, and reliably so you don't ever have to worry. <cite>https://yarnpkg.com/getting-started</cite> <center><a href="https://yarnpkg.com/">https://yarnpkg.com/</a></center> <!-- .slide: data-background="https://i.imgur.com/aGZl9lj.png" data-contrast="on" --> <!-- credit photo: https://unsplash.com/photos/a-QH9MAAVNI --> ---- ## npm vs yarn Yarn s'appuie sur la même infrastructure que npm mais est plus rapide car il utilise du cache et parallélise ses tâches. * https://www.blogduwebdesign.com/yarn-gestionnaire-de-paquets-pour-nodejs/ * https://medium.com/javascript-in-plain-english/npm-vs-yarn-choosing-the-right-package-manager-a5f04256a93f <!-- .slide: data-background="https://i.imgur.com/2xdVL12.jpg" data-contrast="on" --> <!-- credit photo: https://unsplash.com/photos/WSLdpFngoQk --> ---- ## bower On peut encore mentionner `bower` qui est aussi un package manager pour les projets node.js. <center><a href="https://bower.io/">https://bower.io/</a></center> <!-- .slide: data-background="https://i.imgur.com/NO5A1DL.jpg" data-contrast="on" --> <!-- credit photo: https://unsplash.com/photos/JdrVcS0z2fk --> ---- ## init * `npm init` * `yarn init` <!-- .slide: data-background="https://i.imgur.com/vdtN3pP.jpg" data-contrast="on" --> <!-- credit photo: https://unsplash.com/photos/BfZ3b61V50k --> ---- ## package.json > npm suit les modules installés dans un projet avec le fichier package.json, qui réside dans le répertoire d'un projet et contient : > > * Tous les modules nécessaires à un projet et leurs versions installées > * Toutes les métadonnées d'un projet, telles que l'auteur, la licence, etc. > * Les scripts pouvant être exécutés pour automatiser des tâches dans le cadre du projet <cite>https://www.digitalocean.com/community/tutorials/how-to-use-node-js-modules-with-npm-and-package-json-fr</cite> <center><a href="https://docs.npmjs.com/cli/v7/configuring-npm/package-json">https://docs.npmjs.com/cli/v7/configuring-npm/package-json</a></center> <!-- .slide: data-background="https://i.imgur.com/UqvrSyx.jpg" data-contrast="on" --> <!-- credit photo: https://unsplash.com/photos/J6iLgznwL1c --> ---- ## package-lock.json > * npm install n’est pas déterministe, et génère un package-lock.json > * package-lock.json permet d’avoir un node_modules déterministe avec la commande npm ci > * Rouler un npm ci sur un package-lock.json va TOUJOURS générer le MÊME node_modules <cite>https://nexusinno.com/quest-ce-quun-package-lock-json-et-quest-ce-que-ca-mange-en-hiver/</cite> <!-- .slide: data-background="https://i.imgur.com/CEOEykG.jpg" data-contrast="on" --> <!-- credit photo: https://unsplash.com/photos/Z0-jPbWwhZE --> --- # asynchrone > Asynchrone fait référence à un environnement de communication où chaque partie reçoit et traite les messages lorsque c'est possible ou plus pratique, au lieu de le faire au même moment. > Il peut être utilisé pour décrire un environnement de communication humain comme le courriel : l'expéditeur envoie un courriel et le destinataire se contente d'y répondre quand cela lui convient ; il n'a pas à répondre immédiatement. <cite>https://developer.mozilla.org/fr/docs/Glossaire/Asynchronous</cite> <!-- .slide: data-background="https://i.imgur.com/MOVS39C.jpg" data-contrast="on" --> <!-- credit photo: https://unsplash.com/photos/j1GiPlvSGWI --> <!-- https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Asynchronous --> ---- ![](https://i.imgur.com/KiNoSgf.png) ---- # promesses ```js function resolveAfter2Seconds() { return new Promise(resolve => { setTimeout(() => { resolve('resolved'); }, 2000); }); } async function asyncCall() { console.log('calling'); const result = await resolveAfter2Seconds(); console.log(result); // expected output: "resolved" } asyncCall(); ``` <cite>https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/async_function</cite> <!-- .slide: data-background="https://i.imgur.com/J1WaXQg.jpg" data-contrast="on" --> <!-- credit photo: https://unsplash.com/photos/3vW1kmFBSx8 --> --- # frameworks * pour faire du web "simple", [Express](https://expressjs.com/) * pour le frontend [Vue](https://vuejs.org/), [React](https://reactjs.org/), [Angular](https://angularjs.org/) ou [Svelt](https://svelte.dev/) * pour le backend [Nest](https://nestjs.com/) ou [Meteor](https://www.meteor.com/) <!-- .slide: data-background="https://i.imgur.com/ZNVjftv.jpg" data-contrast="on" --> <!-- credit photo: https://unsplash.com/photos/ySm-r5NqPbA --> --- # apprendre 1. https://developer.mozilla.org/fr/docs/Apprendre/JavaScript 2. https://eloquentjavascript.net/ 3. https://nodeschool.io/ <!-- .slide: data-background="https://i.imgur.com/UuyHL18.jpg" data-contrast="on" --> <!-- credit photo: https://unsplash.com/photos/LRjp6KgyLNo --> ---- # tutos * https://grafikart.fr/tutoriels/nodejs * https://nodejs.developpez.com/cours/ * https://practicalprogramming.fr/nodejs/ * https://openclassrooms.com/en/courses/6390246-passez-au-full-stack-avec-node-js-express-et-mongodb * https://www.udemy.com/fr/topic/nodejs/free/ <!-- .slide: data-background="https://i.imgur.com/NXmMp99.jpg" data-contrast="on" --> <!-- credit photo: https://unsplash.com/photos/iIkE_2RZNis --> ---- # webographie * https://javascript.info/ * https://nodejs.dev/learn * https://makina-corpus.com/blog/metier/2014/introduction-a-nodejs * https://www.toptal.com/nodejs/why-the-hell-would-i-use-node-js <!-- .slide: data-background="https://i.imgur.com/B52XSXV.jpg" data-contrast="on" --> <!-- credit photo: https://unsplash.com/photos/5nf_8-zmrO0 --> --- # info ![><](https://i.imgur.com/3Ph9LPI.png) Présentation faite sur hackmd : <br>https://hackmd.io/@ponsfrilus/nodejs <!-- This style apply by default to all slides, unless .slide is used. Note the use of the reveal class selector: this mean that only the presentation is affected by this style, and the makrdown preview or the book mode of hackmd.io is style intact. If you want/need a resizable background image, add the background-size: cover; property and change background-position: 0px 0px; --> <style> .reveal { background-color: #e6e6e6; background-image: url('https://epfl-idevelop.github.io/elements/svg/epfl-logo.svg'); background-repeat: no-repeat; background-position: 5px 5px; } .reveal { color: #111; } .reveal h1, .reveal h2, .reveal h3, .reveal h4, .reveal h5, .reveal h6 { color: #212121; } .reveal a { color: #f009; } .reveal a:hover { color: #f00; } .reveal .more { color: #339; } .reveal code { padding-top: 0.2em; padding-bottom: 0.2em; margin: 0; font-size: 85%; background-color: rgba(255, 255, 255, 0.46); border-radius: 3px; } [data-contrast="on"] > div { background-color: #ffffff50; } [data-contrast="on+"] > div { background-color: #ffffff99; } /* https://stackoverflow.com/a/39614958/960623 */ img[alt$=">"] { float: right; } img[alt$="<"] { float: left; } img[alt$="><"] { display: block; max-width: 100%; height: auto; margin: auto; float: none!important; } .reveal section img[alt$="logo"] { border: 0 } .reveal h1 { font-size: 2em; } .reveal h2 { font-size: 1.6em; } .reveal h3 { font-size: 1.4em; } .reveal h4 { font-size: 1.2em; } .reveal h5 { font-size: 1.1em; } .border { border: 1px solid #555; } .reveal blockquote { width: 100% } .reveal blockquote:before { display: block; padding-left: 10px; content: "\201C"; font-size: 80px; position: absolute; left: -20px; top: -20px; color: #7a7a7a; } .reveal cite:before { content: "\2009 \2015 \2009"; } .reveal cite { font-size: 80%; } .reveal code { color: #fff; background-color: #101010; border-radius: 3px; font-family: courier, monospace; padding: 0 3px; font-size: 0.8em; } .reveal .footer1 { position: absolute; bottom: 1em; left: 1em; font-size: 0.5em; } .footer2 {} position: absolute; bottom: 0%; left: 0%; } </style>

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully