Giter Site home page Giter Site logo

js-node-projects's Introduction

Hi there 👋

Azlou77/Azlou77 is a ✨ special ✨ repository because its README.md (this file) appears on your GitHub profile.

Here are some ideas to get you started:

  • 🔭 I’m currently working on PHP cURL project
  • 🌱 I’m currently learning JS and Frameworks like React, ExpressJS
  • 👯 I’m looking to collaborate on ...
  • 📫 How to reach me: [email protected]
  • 😄 Pronouns: Azlou77
  • ❤️ Loves:
  • 🏅 Pratice sport: running, biking
  • 📚 Romans classic with authors: Hugo, Balzac, Stendhal, Alexander Dumas
  • 🔍 Investigation books: Agatha Christie, Conan Doyle
  • 🇬🇷 Greek culture and Mythologies

js-node-projects's People

Contributors

azlou77 avatar

Stargazers

 avatar

Watchers

 avatar

js-node-projects's Issues

Add fetch with Javascript

First to protect API key or others:

View issues #51

List record:

  • Use fetch fetch
  • Method GET
  • With async function
  • Add new headers
  • Stock sensitive variables in .env file
  • Call back with env.process.NameofVariable

Features form and database map

To do:

  • Delete all data in JS folder data
  • Search what field to put in form html

HTML:

  • Create form
  • Field name
  • Field addresse
  • Groups coordinates with 2 fields long and lat
  • Button submit

PHP:

  • Connection to bdd with PDO method
  • Check if columns lat and long is created for table map
  • Check if the connection is correct else send error message
  • Save data in bdd
  • After create the Form, get data by curl or fetch
  • Display it in Open Street Map
  • Find a way to update automatically the changes.

Links:
My list API map Github
Converter GPS coordonees
Code box Fecth JS
GeoJson tools
Convert address to lat/long

Remove the markers onchange checkbox

Solve:
Check if the checkbox is unchecked by

  1. Searching by input element with the value
  2. Add event listener onclick
  3. Define different of checked
  4. Use the leaflet function to remove marker.remove();

Connection PDO

  • define data connection
  • instance new PDO
  • get message succes or failed

Using of webpack

Objective:

  • Import libraries, minify packages before putting them into production.
  • Installing Node Js
  • Package.json va lister les dépendances
  • Open shell, and write npm install
  • npm run build le dossier dist est rempli

List records of table weapons

Use Postman:

  1. Go the dashboard
  2. Then in your menu->espace développeurs

Image
3. Go the personnal access
4. Settings the token's name and what you want to do with this token: write, read, delete.
5. Go the Postman
6. Add request with method GET
7. Set authorization to token Bearer
8. Add variables tableIdOrName, token, baseId with values
9. add in the url https://api.airtable.com/v0/{{baseId}}/{{tableIdOrName}}

Image

Test on maps data

Link to #16 for data extraction:

  • SQL request to get 10 first data of city:
    SELECT * FROM companie WHERE zip LIKE '94270' LIMIT 10;

  • Fill the fields lat and lon

  • Same request but with other city

  • Changes if neccessary the name's table and columns

  • Fecth with right url.

  • Change properties to changes icons colors

Post actions

Acess rights:

  • Create role author to modify Post
  • Make a filter date with from = query Params = timestamp in bdd Prisma
  • Ex: GET /api/posts?from=1674560065

Set up data in Airtable table.

  1. Go the artaible count
  2. Go to the dashboard
  3. Add field to the table

For example:

  • name with short text
  • prices with devise
  • quantity with number
  • description with long text
  • category with short text

Image

Connection et login

Avant faire en sorte d'être connecté = token valide

  • Form login
  • Form register
  • View Posts before create function createPost

Store data in BDD and display it

View on:
Github BDD

  1. Make PDO connection and acess it.
  2. Models to make request on BDD
  3. Make simple map data wiht leaflet
  4. Add on this html page a script using fetch method
  5. Link the PHP file which store maps data and display them.

Uncaught reference error

Description:

  • I want to secure my data so I used dotenv package and process.env.
  • I write require response and data

Image
``

Modal projects

what is a modal ❓

  • A modal is an element that when you touch that open up
    a form with several fields like name, email, password for example
    when you have a connexion.

part HTML:

  • create an hero section
  • create button modal
  • add script modal.js

part CSS:

  • /* The Modal (background) */
  • /* Modal Content/Box */
  • /* The Close Button */

part JS:

  • get elements by id
  • get the element by class
  • onclick add open or close events

Notions:

  • data-bs-toggle="modal":
  • data-bs-target="#exampleModal"
    L'attribut data-toggle contient le type d'événement qui va être lié à un bouton

Image

CRUD routes

  • User:

Routes:

  • /admin/user/delete = seul un User ayant le role admin doit pouvoir être capable de supprimer un autre User
  • /user/ la valeur du rôle est définie à user par défaut

Functions:

  • deleteUser();
  • createUser();
  • updateUser();
  • readUser();

Comments
Routes:

  • /author/post/comment/delete = seul l’auteur du Comment peut le modifier ou le supprimer
  • /author/post/comment/update
  • /admin/post/comment/delete= un admin doit pouvoir supprimer un Comment

Functions:

  • deleteComment();
  • createCommentr();
  • updateComment();
  • readComment();

Posts
Routes:

  • /user/post/delete = seul l’auteur du Post peut le modifier ou le supprimer
  • /user/post/update
  • /admin/post/delete= Un admin doit pouvoir supprimer un Post

Functions:

  • deletePost();
  • createPost();
  • updatePost();
  • readPost();

Mange multiple fetch getLatLng and file PHP

Solve:

  1. Display variables maps data
  2. Concatenate adresse with street, zip and city
  3. Make function to get lon&lat properties using fetch open street map
  4. Display function and the data in HTML front.

Results:

Image

Asynchrones function wtih JSON

🔗 Links:

What is async functions:

  • It was a technique that allow you to continue to react to others events during the execution of the tasks.
  • At the end you will receive the result.

What is programm synchrone

  • It a programm which it write lign per lign

What is first numbers

  • A number is first if he has only 2 divisors itself or by one
  • For example: 7 has can be divisable only by 7 and 1

Exercise:

  • Create a function to welcoming a personn
  • Create variable to welcoming a personn
  • Create function with first numbers

Image

Image

The problem of function synchrone is if you submit the button to generate first numbers you can't do other things like write some text.
To solve this issue:

  • start operation long with function
  • start others events next to the main function
  • Receive a notification when the programm is done

image

🔗 Links:

View how work API geolocation

Work with function like:

  • Getcurrent position
  • WatchPosition
  • Handling errors
  • Events activated only if we click on buttons

Increases the performances of requests

Pour améliorer les performances en JavaScript, voici quelques bonnes pratiques à suivre :

  1. Minification du code : La minification consiste à supprimer les caractères inutiles du code JavaScript, tels que les espaces, les commentaires et les noms de variables non utilisés. Cela permet de réduire la taille du fichier JavaScript et d'accélérer le temps de chargement de la page¹.

  2. Optimisation des boucles : Les boucles sont souvent des points sensibles en termes de performances. Essayez d'optimiser vos boucles en évitant les opérations coûteuses à l'intérieur de celles-ci et en utilisant des techniques telles que la mise en cache des valeurs répétées².

  3. Utilisation de requêtes asynchrones : Lorsque vous effectuez des appels réseau ou des opérations longues, utilisez des requêtes asynchrones (par exemple, AJAX) pour éviter de bloquer l'exécution du reste du code JavaScript. Cela permet d'améliorer la réactivité de l'application et d'éviter les temps d'attente inutiles³.

  4. Optimisation des sélecteurs CSS : Lorsque vous utilisez des sélecteurs CSS pour cibler des éléments dans le DOM, essayez d'utiliser des sélecteurs spécifiques plutôt que des sélecteurs génériques. Cela permet au navigateur d'effectuer une recherche plus rapide et plus efficace dans le DOM.

  5. Gestion de la mémoire : Assurez-vous de libérer la mémoire utilisée par votre code JavaScript lorsque vous n'en avez plus besoin. Cela peut être fait en supprimant les références aux objets non utilisés ou en utilisant des techniques telles que le garbage collection.

Ces pratiques peuvent contribuer à améliorer les performances de vos applications JavaScript. N'hésitez pas à consulter la documentation spécifique à votre environnement de développement pour obtenir des conseils supplémentaires.

J'espère que cela vous aide ! N'hésitez pas à me poser d'autres questions.

Source : conversation avec Bing, 21/09/2023
(1) Comment minifier JavaScript — Outils et méthodes recommandés - Kinsta. https://kinsta.com/fr/blog/minifier-javascript/.
(2) Performance Web - Apprendre le développement web | MDN. https://developer.mozilla.org/fr/docs/Learn/Performance.
(3) Mesure des performances - Apprendre le développement web | MDN. https://developer.mozilla.org/fr/docs/Learn/Performance/Measuring_performance.

Counter projects

This project will give you more practice working with the DOM and you can use this simple counter in other projects like a pomodoro clock.

Steps:

  • HTML : create 3 buttons and title counter

  • on click plus add events listener 🖱

  • incrementation ➕

  • Use query selector for button and 0:

Image

Notions:

  • document.querySelectorAll()
  • forEach()
  • addEventListener()
  • currentTarget property
  • classList
  • textContent

JSON exercise heroes

  • dowload html and css file
  • load JSON to interact with DOM ( Document Object Model)

Image

  • add createElement h1
  • add createElement p
  • add text with the value of "squadName"

Image

  • create function showheroes
  • work in section element
  • add createElement h2
  • add createElement p *2 for "secret identity" & "age"
  • add createElement ul for "superpower"
  • add createElement li

Image

Duplicate for second and last members:

  • second member
  • third member

Image

Gitlens coding part x ChartJS

Link to Azlou77/devops-tools#17
Exemple in Vscode:
For example I willl create a chart JS and use Gitlens to inscrease my productivity.

How to create a chartJS ?
Go the 3wschool site

  • Add script
  • Add canvas
  • Add instance new chart
  • Custom options with your data.

Image

Take project NodeJS projects:

NodeJS fakerKS

Description:

  1. Go the codebox io.
  2. install faker by cmd : npm install @faker-js/faker --save-dev
  3. For NodeJS apps make import by require import:
    const { faker } = require("@faker-js/faker");
  4. Custom what do you want for dake data.
  5. Here I generate fake data of user

Image

Access to token

Description:
There was an error in evaluating the test script: TypeError: Cannot read properties of undefined (reading 'access_token')

Image

View hooks

Notions:

  • What is the hooks
  • Use state
  • Use effect
  • Use context
  • Use ref
  • Use Reducer
  • Use callback
  • Use memo
  • Use custom hooks
  • Exercise to not load the same page.

Links:
Hooks

JSON exercise caracters

  • Create a list of caracters
    With properties:
  • name
  • weapons
  • nickname
  • class
  • abilities
  • noble phantasm
  • Create HTMl page with
    <script type="text/javascript">

Create for 7 servants:

  • saber ⚔
  • lancer
  • archer 🏹
  • assasssin
  • berserker
  • caster 🧙
  • rider 🏇

Servants:

  • Artoria
  • Karna
  • Gilgamesh
  • King Hassan
  • Heracles
  • Solomon
  • Alexander the Great

Image

Make form part

HTML part

  • h1 form map
  • field addresse
  • field company
  • field long
  • field lat
  • field submit

PHP

  • Check if all field is write before submit
  • Add fields required addresse, company
  • Check is the addresse is valide
  • Check is the mail is valide
  • Check is the phone is valid

Protect secrets variables with Github Actions

Link:
NodeJs Github Actions

  1. Create build.js
    console.log(`Hello ${process.env.HELLO}`)
  1. Create package.json
    "scripts": {
      "build": "node build.js"
    }
  }
  1. Create Github Action file
name: npm run build
on: [push]
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v3
    - uses: actions/setup-node@v3
      with:
        node-version: 16
    - run: npm install
    - run: npm run build
      env:
        DOTENV_KEY: ${{ secrets.DOTENV_KEY }}

  1. Install dotenv
    npm install dotenv --save
  2. Create .env file
  3. Set build.js
// build.js
require('dotenv').config()
console.log(process.env) // remove this after you've confirmed it is working

console.log(`Hello ${process.env.HELLO}`)
  1. Run file build js
  2. Results expectud: Hello world

Image

Add console data to the HTML page

Link to issue #55

  • When writing: npm run fetch

Image

  • Same but display in HTML page

  • Add import 'dotenv/config'

  • Stringtify data
    Image

Link to issue #54 ⚠ Abort to use node.js and dotenv package ⚠

HTML part:

  1. Create carte with id:
  2. For title: id="titles"

JS part:

  1. Get element by id
  2. Create url elements for API
  3. Create functions append and createElement
  4. Create simple resp and data functions.
  5. Loop troughts the titles and put each titles in li elements
  6. Create element with createNode
  7. Use innerHTML to put the titles in span element
  8. Appened elements

Image

Features extraction/filter map

Filter PHP/SQL

SQL/PHP: View: #21 Make function convert addresse to maps data

Send new data in API blob JSON #24

Obligatoires:

  • id, nom, lat, lon
  • View on #19 testing maps filter by zip code

Optionnels:

  • city
  • addresse
  • cp
  • by differents domaines

Extraction bdd:
View the video Youtube :
Extraction bdd
or Github repo:
Github repo

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.