teleren/devto huggingface dataset:
NestJS Boilerplate using Typescript Generics.
Tags: nestjs, typescript, mongodb, node
Published: 2023-08-27 11:48:03

Just finished coding a [NestJS](https://github.com/BrahimAbdelli/nestjs-boilerplate) boilerplate project (and an explicative [Article ](https://www.brahimabdelli.com/nestjs-boilerplate)about it) using :

✔ MongoDB.

✔ TypeORM.



That provides :

✔ Abstract Base Module (Controller, Service, Entity and DTOS) that you can use for your modules.

✔ Two modules (category, product) mock and e2e tested.

✔ Ready to use APIs (CRUD, pagination, a powerful search API etc ..).

✔ A users module including a middleware.

✔ A mailer service using (MailJet) integrated with a handlebar .hbs template.

✔ A Postman Collection for every API.

✔ Pipes such as : Abstract validation pipe for objects, ObjectID validation pipe.

✔ Utils for finding by field, checking field uniqueness, custom error throwing etc..

✔ A logger middleware.

✔ Dev and prod environments.

✔ Dockerized app.



I wrote an article explaining step by step how this boilerplate was built and how you can use it efficiently.

You can access the Github repository to get the full project below and use it to your liking.

I'm open for your suggestions so feel free to give me your opinions 😀.
How to create series on dev.to?
Tags: question, help, answer, qa
Published: 2023-08-27 11:43:17

---
title: How to create series on dev.to?
tags: question, help, answer, qa
---

Wanted to create a series about github actions. I added the frontmatter meta like so

```
---
title: Github Actions introduction
tags: ...
series: Github Actions
---
```

I also added a second draft article, that is not visible yet. However, there is no series shown in the article that I expected (see screenshot of example). Is there something I am missing? Thanks for any help :) 

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/02poidqthi1i1u2tt9ri.png)
Java - Singly Linked Lists: Playing Detective with `find(data)` 🕵️‍♂️
Tags: java, singlylinkedlist, computerscience, dsa
Published: 2023-08-27 11:40:36

Hello Dev.to enthusiasts! 🌟

We've been on quite the journey with singly linked lists, haven't we? After adding, deleting, and printing nodes, let's put on our detective hats and learn how to search with the `find(data)` method.

### A Tiny Flashback: Singly Linked List 📜

For those who've just tuned in:

```java
class Node {
    int data;
    Node next;

    Node(int data) {
        this.data = data;
        this.next = null;
    }
}

class SinglyLinkedList {
    Node head;
    SinglyLinkedList() {
        this.head = null;
    }
}
```

Each node is a tiny vault of data, safely guarded and pointing to its successor.

### Launching the Search Party with `find(data)` 🔍

Think of the `find(data)` method as your personal detective. 

```java
public Node find(int data) {
    // We kick off our investigation at the head of the list
    Node current = head;
    
    // As long as there are nodes loop
    while (current != null) {
        // If we get a match, case closed!
        if (current.data == data) {
            return current;
        }
        // If not, we continue our inquiry
        current = current.next;
    }
    
    // If not found, it's a null report
    return null;
}
```

### Why Bother Searching? 🤔

Well, what's a list without the ability to find specifics in it? Whether you're validating data, making updates, or simply checking for the existence of a value, `find(data)` ensures your list is more than just a passive container.

### Conclusion 🎤

Armed with the `find(data)` method, we are ready to transform singly linked list into an interactive database of possibilities.

In [`the next article`](https://dev.to/hunorvadaszperhat/java-finding-your-nodes-place-with-getindex-41f6) we will look at `get(index)` method


Cheers and happy coding! 🚀
The Tale of Three Variables: let, const, and var in JavaScript Land
Published: 2023-08-27 11:36:30

Once upon a time in the magical realm of JavaScript Land, there were three remarkable characters: `var`, the old guardian; `let`, the flexible friend; and `const`, the steadfast sentinel. Together, they held the secrets of variable declaration, each with its unique characteristics. Journey with us as we explore their stories and unveil their mysteries.

## Chapter 1: `var`, the Old Guardian
A Wise But Confusing Character
In the early days of JavaScript Land, var was the most experienced guardian. He had a knack for adapting to various situations, but his function-scoped nature sometimes led to confusion.

```
function confusion() {
 var a = 10;
 if (true) {
 var a = 20;
 }
 console.log(a); // Outputs 20
}
```
In the tale of the young programmer Emily, var helped her define variables, but his hoisting behaviour perplexed her.

“Why does it behave like that?” Emily pondered. var smiled and said, “I’m function-scoped, dear Emily. I have my own rules.”

##Chapter 2: `let`, the Flexible Friend
A Modern and Adaptable Resident
As the era of ES6 unfolded in JavaScript Land, let made its appearance. More predictable and contemporary than var, it brought a friendly and modern touch to the realm.

```
function clarity() {
 let b = 10;
 if (true) {
 let b = 20;
 }
 console.log(b); // Outputs 10
}
```
One day, let met a developer named Jack, struggling with a problem that `var` couldn’t solve. `let` introduced himself, “I’m block-scoped, Jack. I behave differently within different blocks of code.” Jack’s code worked flawlessly, and they became fast friends.

##Chapter 3: `const`, the Steadfast Sentinel
A Reliable and Unchangeable Character
In the same era as let, const stood tall as a sentinel, guarding values with unwavering dedication.

```
const c = 10;
// c = 20; // This will throw an error
```
In a tale where a critical piece of information had to be preserved, const was the hero of the day. "I'm immutable," he declared, "Once assigned, my value shall never change!" The people of JavaScript Land praised his reliability.

##The Gathering of the Three
One beautiful day, the three characters gathered to share their stories. Here’s a summary of their characteristics:


![comparison between let, const and var](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v0aoqedhjyk3so4wgtq1.png)


They laughed and celebrated their unique strengths, knowing that each had a place in the heart of JavaScript Land.

##Conclusion: Lessons from JavaScript Land
And so, dear reader, we’ve explored the fascinating tales of `let`, `const`, and `var`. Each has its role and purpose:

Use `var` if you need function scope (though its usage is less common these days).
Choose `let` when you need a variable that can be reassigned within block scope.
Opt for `const` when you want to preserve a value that should never change.

Embark on your own adventures in JavaScript Land, and may these three characters guide you along the way. Happy coding!
Java - Singly Linked Lists: Showcasing with `printList()` 🌟
Tags: java, singlylinkedlist, computerscience, dsa
Published: 2023-08-27 11:35:49

Hello Dev.to enthusiasts! 🌟

After exploring adding and deleting nodes in our linked list, today we’re diving into something visually satisfying: displaying. Bring in the spotlight for the `printList()` method!

### Quick Revisit: Singly Linked List 📖

For our newly arrived friends:

```java
class Node {
    int data;
    Node next;

    Node(int data) {
        this.data = data;
        this.next = null;
    }
}

class SinglyLinkedList {
    Node head;
    SinglyLinkedList() {
        this.head = null;
    }
}
```

### Unveiling the `printList()` Method 🖨

Here’s how you display your linked list:

```java
public void printList() {
    // We start at the head of the list
    Node current = head;

    while (current != null) {
        System.out.print(current.data + " -> ");
        current = current.next;
    }
    
    // And cap it off with "null"
    System.out.println("null");
}
```

### Why a Print Method? 🧐

Visualization is key. Whether you're debugging, ensuring data integrity, or just want to admire the nodes you've worked hard to put together, `printList()` is your friendly tool to see everything at a glance.

### Wrapping Up 🎁

The `printList()` method lets you stroll through each node, looking into its data. Remember, while data structures can sometimes be tricky, visual feedback makes everything better!

In [`the next article`](https://dev.to/hunorvadaszperhat/java-singly-linked-lists-playing-detective-with-finddata-2pe2) we will look at `find(data)` method



Cheers and happy coding! 🚀
Axios return async await
Published: 2023-08-27 10:50:44

##Installing
Package manager
`Using npm:`

```javascript
$ npm install axios
```

Once the package is installed, you can import the library using import or require approach:

```javascript
const axios = require( 'axios' )
```

or

```javascript
import axios from 'axios'
```

then, create return function

```javascript
async function myPromise() {
    	
    // return axios( 'https://example.com' )
    return await axios( 'https://example.com' )
        .then( function ( response ) {
    
            // Process html...
            return ( response )
    
        } )
        .catch( function ( err ) {
    
            // Crawling failed...
            return ( err )
    
        } );
	
}
```

And, call the function

```javascript
(async () => {
    
    try {
        
        console.log( await myPromise() )
        
    } catch ( error ) {
        
        console.error( `Something went wrong. ${error.message}` );
        
    }
    
})();
```

---

All Code

```javascript
/*
	https://www.npmjs.com/package/axios
	https://github.com/axios/axios
	https://axios-http.com/
 */

const axios = require('axios');

async function myPromise() {
    	
    // return axios( 'https://example.com' )
    return await axios( 'https://example.com' )
        .then( function ( response ) {
    
            // Process html...
            return ( response )
    
        } )
        .catch( function ( err ) {
    
            // Crawling failed...
            return ( err )
    
        } );
	
}

/* --- */

(async () => {
    
    try {
        
        console.log( await myPromise() )
        
    } catch ( error ) {
        
        console.error( `Something went wrong. ${error.message}` );
        
    }
    
})();
```

[repl.it](https://replit.com/@antelove19/NodeJS-axios-return-async#index.js)

Thank you

---
Building a Dynamic Quiz App using HTML, CSS, and JavaScript
Tags: html, css, javascript, quizapp
Published: 2023-08-27 10:29:10

Hey Dev Community! 👋 Are you ready to take your web development skills to the next level? In this post, we'll walk through the process of creating a fun and interactive quiz app from scratch using HTML, CSS, and JavaScript. Whether you're a beginner looking to learn or an experienced developer wanting to brush up on your skills, this project is a great way to enhance your front-end development prowess.

**What We'll Cover:**

- Setting up the project structure
- Designing the quiz interface with HTML and CSS
- Creating the quiz logic using JavaScript
- Styling for interactivity and feedback

**1. Setting Up the Project Structure:**
Let's start by setting up our project structure. Create a new folder for your project and organize it like this:

markdown
Copy code
- quiz-app/
  - index.html
  - styles.css
  - script.js

**2. Designing the Quiz Interface with HTML and CSS:**
In the index.html file, build the basic structure of the quiz app. Create sections for the question, options, and a submit button. Style your app using CSS to make it visually appealing.

**3. Creating the Quiz Logic using JavaScript:**
In the script.js file, define an array of objects to hold your quiz questions, options, and correct answers. Use JavaScript to dynamically load questions and choices, handle user selections, and track the user's score.

**4. Styling for Interactivity and Feedback:**
Use CSS to highlight selected options, change button styles on hover, and provide visual feedback for correct and incorrect answers.

Remember, the beauty of this project is that you can customize it as much as you want. You can add features like a timer, multiple quiz categories, or even a high-score leaderboard.

**Additional Tips:**

Break your tasks into smaller steps. Tackle one feature at a time, and make sure it works before moving on.
Utilize version control (Git) to keep track of your changes and collaborate with others more effectively.
Don't be afraid to Google and consult documentation when you encounter challenges. The web development community is rich with resources.

**Conclusion:**
Building a quiz app with HTML, CSS, and JavaScript is a fantastic way to apply your web development skills in a practical project. By following this guide, you'll gain hands-on experience in structuring web pages, handling user interactions, and creating dynamic content. Have fun coding, and remember that practice makes perfect!
Live on [Quizapp](http://quizapp.sadiqmagbul.host20.uk/)
Feel free to ask questions, share your progress, and showcase your quiz app in the comments below. Happy coding! 🚀👨‍💻👩‍💻
The Migration Adventure: CRA to Vite and npm to pnpm
Tags: javascript, npm, pnpm, vite
Published: 2023-08-27 10:24:46

As I was migrating a client's project from CRA to Vite I encountered plenty of issues. Some of which were due to certain imports that are specific to Webpack, the other ones were due to me using `pnpm` as opposed to `npm`.

That wasn't a smart move, migrating to another build tool as well as another package manager at once. So I switched back to using `npm` to finish my Vite migration, fixed the errors, all good.

When I tried using `pnpm` again and installed the packages using it, it kept throwing many errors that package X, Y, Z are not installed, which is weird, because the `npm` version works just fine!

Via `pnpm import`, the existing lock files are parsed and `pnpm-lock.yaml` gets generated, so the lock files should have the same content.

It is true that all the dependencies that are mentioned in the lock files will be installed by `pnpm` without fault. However, due to how `npm` installs packages and their dependencies, you will find yourself being able to use a dependency of a package without explicitly installing.

That's exactly what happened, notably with `date-fns` and some other packages. How `npm` structures your `node_modules/` allows you to import `date-fns` even if it wasn't present as a dependency in your `package.json`, as long as some other package depends on it.

Bottom line, explicit is better than implicit.

I downloaded the missing packages like a good boy and life moved on 🙂.

## References

I followed [this article](https://www.robinwieruch.de/vite-create-react-app/) to switch from CRA to Vite, it was very helpful.
how to learn coding in 1 week?
Tags: beginners, programming, webdev, javascript
Published: 2023-08-27 10:13:10

Choose a Language: Select a beginner-friendly language like Python. It has a clear syntax and is widely used for learning.

Online Tutorials: Utilize online resources like Codecademy, Khan Academy, and freeCodeCamp. Follow step-by-step tutorials to grasp fundamental concepts.

Focus on Basics: Learn about variables, data types, loops, conditions, and functions. Understand how these elements work together to create programs. if you want to learn more [click on link](https://knowledgedetective.com/)
Perguntas Frequentes sobre Websockets: Respostas para Dúvidas Comuns
Tags: webdev, javascript, beginners, programming
Published: 2023-08-27 09:55:52

Pergunta 1: O que são websockets e como eles funcionam?

Websockets são uma tecnologia que permite a comunicação bidirecional em tempo real entre um navegador web (cliente) e um servidor. Diferentemente do HTTP tradicional, que é baseado em solicitações e respostas separadas, os websockets mantêm uma conexão aberta contínua, permitindo a troca instantânea de informações.

Pergunta 2: Quais são os benefícios dos websockets?

Os websockets oferecem diversos benefícios, como comunicação em tempo real, interatividade aprimorada, atualizações instantâneas de dados, menor latência e economia de largura de banda, pois não há necessidade de constantes solicitações ao servidor.

Pergunta 3: Quais linguagens de programação posso usar para implementar websockets?

Você pode implementar websockets em várias linguagens de programação. Algumas opções populares incluem JavaScript (Node.js), Python, Ruby e Java. Cada linguagem possui bibliotecas e frameworks que facilitam a criação e a gestão de conexões websocket.

Pergunta 4: Websockets são seguros?

Sim, os websockets podem ser seguros desde que sejam implementados corretamente. É importante implementar mecanismos de autenticação, criptografia e validação de dados para proteger as comunicações. Use tokens de autenticação e estabeleça conexões seguras por meio de HTTPS.

Pergunta 5: Como lidar com escalabilidade em implementações de websockets?

A escalabilidade em implementações de websockets pode ser abordada usando balanceadores de carga, servidores dedicados, serviços em cloud e estruturas serverless. É importante projetar sua arquitetura de modo que ela possa lidar com um grande número de conexões simultâneas sem comprometer o desempenho.

Pergunta 6: Quais são os casos de uso comuns para websockets?

Websockets são usados em diversos casos de uso, como chat em tempo real, notificações instantâneas, atualizações de dados em tempo real (como placares esportivos), jogos online, colaboração remota, streaming ao vivo e muito mais.

Pergunta 7: Como posso testar e depurar implementações de websockets?

Você pode usar ferramentas de desenvolvimento, como navegadores com ferramentas de inspeção, para monitorar as mensagens websocket e depurar sua implementação. Também é recomendável realizar testes de carga e simulação de cenários de uso intenso para identificar possíveis problemas de desempenho.

Pergunta 8: Qual é o futuro dos websockets?

Os websockets continuarão a evoluir para atender às demandas de aplicações cada vez mais interativas e em tempo real. A integração com tecnologias emergentes, como IoT e IA, e sua adoção em setores como saúde e educação são algumas das tendências que moldarão o futuro dos websockets.
Introducing My '🌟 10 CSS Card Wonders' Project! 💫
Tags: codepen, webdev, css, ui
Published: 2023-08-27 09:47:26

<p>Introducing my "10 CSS Card Wonders" project. These 10 mesmerizing CSS cards redefine user interaction with elegant hover effects and stunning designs.</p>
<p>I've made these CSS cards with pure HTML and CSS. **Feel free to use these cards for your projects, personal or commercial.** **They are completely free to use!** You can find the code for each card on my GitHub repository.</p>

{% codepen https://codepen.io/Smit29/pen/GRPogVz %}

🟡[All cards](https://smit-prajapati.github.io/css-cards/)
🟡[Source Code](https://github.com/Smit-Prajapati/css-cards)
Almost every project I posted on dev.to has been acquired, here's another one.
Tags: react, javascript, webdev, productivity
Published: 2023-08-27 09:19:46

So almost every single project I have announced on dev.to has been acquired for a decent amount of money, these projects were used by thousands of users around the world. 

Here's another one.

https://feedful.app is a modern news reader in tweet deck style. 

Please support on Producthunt if you liked feedful - https://www.producthunt.com/posts/feedful


Here's a demo - 

{% youtube osAwp_rchBM %}
As I learn in public, I'm super curious about what you think I should share!
Tags: learning, opensource, tutorial
Published: 2023-08-27 08:06:36

As I learn in public, I'm super curious about what you think I should share! 📚 Any thoughts? What kind of content do you all enjoy reading? 📖

I'm contemplating two options:

1️⃣ Should I spill the beans and share my discoveries in real-time as I learn? 🧐

2️⃣ Or maybe I should take my time to craft some awesome threads, posts, and blogs based on what I've learned? 📝

What do you think? Your input means a lot! 🙌😊
OpenAI API Requests in JavaScript 2023
Tags: webdev, ai, chatgpt
Published: 2023-08-27 08:05:56

Ok so I recently tried my hand at using the OpenAI api for the first time and discovered, the recent migration from v3 to v4.
The version change introduces syntax and breaking changes. If you are in the process of migrating check   [this](https://github.com/openai/openai-node/discussions/217) out.

### Make sure you have an API key for [OpenAI](https://openai.com/), as it is required for the client.

## Installing openai-node
First, install the openai-node package using npm:
`npm install openai
`
## Basic Query in JavaScript
Create an app.js file.

In this example we're using an environment variable for our API key using the dotenv package. You can also hardcode the key, but it's not recommended.

`require("dotenv").config();
`
Next we'll bring in the OpenAI package:

`const OpenAI = require('openai');
const openai = new OpenAI({
	apiKey: process.env.OPENAI_API_KEY, // This is also the default, can be omitted
});`

Okay now we can start consulting the api...

## Making a Request

I'm using the free-tier gpt-3.5-turbo model. The model will return an object with a choices key, with a nested message(s) array.
The array will have at least one object with a role and content.

Let's get a poem about the future of web development from gpt-3.5-turbo.

`async function getPoem() {
    const response = await openai.chat.completions.create({
		model: 'gpt-3.5-turbo',
    // content is hard coded but can come dynamically from user
		messages: [
			{ role: 'user', content: 'generate a short 
     poem about the future of web development' },
		],
	});
    // Log first response
	console.log(response.choices[0]);
}`

This returns an object with role: 'assistant' and the generated response under the key content. So to log only the assistants response,

`console.log(response.choices[0].content`

And that's it for the most basic of requests from OpenAI GPT API's using the openai-node client. Now everytime we run the getPoem function, our assistant will create a new poem about the future of web development.
Exploring Different HTTP Request Methods🚀
Tags: webdev, programming, web3, beginners
Published: 2023-08-27 07:55:01

## 
Hey fellow developers! 👋

I wanted to share some insights about different HTTP request methods that are fundamental in web development. Understanding these methods is crucial for building interactive and dynamic web applications. Let's dive in!

1. **GET Request:**
   - Syntax: `GET /path/to/resource HTTP/1.1`
   - Example: `GET /api/users/123 HTTP/1.1`

2. **POST Request:**
   - Syntax: `POST /path/to/resource HTTP/1.1`
   - Example: `POST /api/posts HTTP/1.1`

3. **PUT Request:**
   - Syntax: `PUT /path/to/resource HTTP/1.1`
   - Example: `PUT /api/users/123 HTTP/1.1`

4. **DELETE Request:**
   - Syntax: `DELETE /path/to/resource HTTP/1.1`
   - Example: `DELETE /api/posts/456 HTTP/1.1`

5. **PATCH Request:**
   - Syntax: `PATCH /path/to/resource HTTP/1.1`
   - Example: `PATCH /api/users/123 HTTP/1.1`

6. **HEAD Request:**
   - Syntax: `HEAD /path/to/resource HTTP/1.1`
   - Example: `HEAD /api/posts/789 HTTP/1.1`

7. **OPTIONS Request:**
   - Syntax: `OPTIONS /path/to/resource HTTP/1.1`
   - Example: `OPTIONS /api/users HTTP/1.1`

8. **CONNECT Request:**
   - Syntax: `CONNECT server.com:443 HTTP/1.1`
   - Example: `CONNECT example.com:80 HTTP/1.1`

9. **TRACE Request:**
   - Syntax: `TRACE /path/to/resource HTTP/1.1`
   - Example: `TRACE /api/debug HTTP/1.1`

10. **PROPFIND Request:**
    - Syntax: `PROPFIND /path/to/resource HTTP/1.1`
    - Example: `PROPFIND /files/docs/ HTTP/1.1`

I hope you find this overview helpful. Let's continue discussing the importance of these methods and their practical applications in modern web development!

Feel free to share your thoughts and experiences below. 🚀