teleren/devto huggingface dataset:
3-Nodejs Course 2023: Project Structure
Tags: node, typescript, mongodb, fastify
Published: 2022-10-27 15:25:29

---
title: 3-Nodejs Course 2023: Project Structure
published: true
description: 
series: Nodejs Course 2023
tags: nodejs, typescript, mongodb, fastify
# cover_image: https://direct_url_to_image.jpg
# Use a ratio of 100:42 for best results.
---

## 📁 Project Structure

Now we've a good understanding of our `package.json` file, now let's start create our project structure.

Our project directories tree will look like this:
  
  ```bash
  ├── src
  │   ├── app
  │   │   ├── moduleName
  │   │   │   ├── controllers
  │   │   │   │   ├── moduleName.controller.ts
  │   │   │   ├── database
  │   │   │   │   ├── models
  │   │   │   │   │   ├── moduleName.model.ts
  │   │   │   ├── middleware
  │   │   │   ├── responses
  │   │   │   ├── routes.ts
  │   ├── core
  │   ├── config
  │   ├── utils
  │   ├── index.ts
  ├── storage  
  │   ├── assets
  ├── .env
```

This is going to be our project structure, we will have a `src` directory that will contain all our source code, and a `storage` directory that will contain all our data.

The `.env` file will contain all our environment variables and sensitive data.

### 📁 app

The `app` directory will contain all our modules, each module will have its own directory, and inside that directory we will have all the files related to that module.

### 📁 core

The `core` directory will contain all our core files, like our application manager, request manager, and other core files.

### 📁 config

The `config` directory will contain all our configuration files, like our database configuration, and other configuration files.

### 📁 utils

The `utils` directory will contain all our utility files, like our logger, and other utility files.

### 📁 index.ts

The `index.ts` file will be our entry point, it will contain all our application initialization code.

### 📁 storage

The `storage` directory will contain uploads, cached files, and any other files.

Inside the `storage` directory we will have an `assets` directory, this directory will contain all our assets, like images, videos, and other assets.

## 🎨 Project Repository

You can find the latest updates of this project on [Github](https://github.com/hassanzohdy/nodejs-2023)

## 😍 Join our community

Join our community on [Discord](https://discord.gg/vtZE9YzaFz) to get help and support (Node Js 2023 Channel).
🎉 Thanks to Seeed Studio for sending us some boards
Tags: hardware, opensource, luos, seeedstudio
Published: 2022-10-27 15:22:51

Our friends at [Seeed Studio](https://www.seeedstudio.com/) send us some boards! We will work together to make them compatible with Luos technology and build great projects using Seeed Studio and Luos.

There will be more news on this soon!
Twitter Bot that is generating unique color grids
Tags: python, twitter, art, bot
Published: 2022-10-27 15:18:51

The NFT craze came and went and whether you believe in them or not, no one can deny the possibilities and the coding behind the technology.
I have always been amazed by Fractals and random computer generated art.so what is better than creating a twitter bot that shares the Fractals I generate with the world? a bot that responds to mentions and generate something.

The basic and simple idea behind it is by using tweepy and creating a bot that fetches mentions and check if certain words (command) and then creates something and send it back to the user who tweeted at the bot. that is exactly what I did..just for fun.

if you mention @machineation on twitter with "make grid" then the bot will take your twitter username, hash it, then create a random color grid seeded by the username.

I don't know if that would be an interesting post/tutorial to show how to code such a bot. If anyone is interested, then i will invest some time in it for sure.
Vue and HTML5 Form Validation
Tags: vue, typescript
Published: 2022-10-27 15:16:09

The browser form validation has gotten better over the years and I have started to find simply adding some minor customization to the HTML5 form validation effective and a huge time saver.


For the times you want a custom error message along with a regex pattern:

```
<template>
  <input type="tel" pattern="^[0-9]{5}?$" required name="zipCode" v-model.trim="zipCode" @keyup="customInvalid" />
</template>

<script setup lang="ts">
const zipCode = ref('');
interface InputTextKeyboardEvent extends KeyboardEvent {
  currentTarget: HTMLInputElement;
}

const customInvalid = (e: InputTextKeyboardEvent) => {
  if (e.currentTarget.validity.patternMismatch) {
    e.currentTarget.setCustomValidity('Please enter a valid 5 digit US Postal Code');
  } else {
    e.currentTarget.setCustomValidity('');
  }
};
</script>

```

The key to the above solution is using the `@keyup`.  This way it  re-evaluates the validity after the browser updates the validity.  This is the only event I could find that allowed me to hide the error message as soon as the user enters a valid value.  

ref:
https://reactgo.com/html5-custom-validation-message/
How to Create a Container DB In Oracle12c
Tags: oracle, database, oracle12c
Published: 2022-10-27 15:06:44

Here we are going to see the steps for creating a container DB in oracle 12c

[](https://medium.com/geekculture/how-to-create-a-container-db-in-oracle-c8bf1c0b3bbd)

Follow us:

[](https://medium.com/@mynotesoracledba)
In One Minute : Django
Tags: django, python, beginners, oneminute
Published: 2022-10-27 15:04:12

Django is an open-source server-side web application framework written in Python.
It is designed to reduce the effort required to create complex data-driven websites and web applications, with a special focus on less code, no-redundancy and being more explicit than implicit.

Django was created in the fall of 2003, when the web programmers at the Lawrence Journal-World newspaper, Adrian Holovaty and Simon Willison, began using Python to build applications.

In June 2008, it was announced that a newly formed Django Software Foundation (DSF) would maintain Django in the future.

{% embed https://youtu.be/5H8a6zmlrtw %}

Django follows the mvc (model-view-controller) architectural pattern. This consists of:

- an object-relational mapper that mediates between data models
- (Python classes) and a relational database ("Model")
- a system for processing requests with a web templating system ("View")
- a regular-expression-based URL dispatcher ("Controller")

Some well-known sites that use Django include Instagram, Mozilla, Disqus, Bitbucket, Nextdoor and Clubhouse.

Official website :- https://www.djangoproject.com/
Documentation :- https://docs.djangoproject.com/
Download :- https://www.djangoproject.com/download/
How to install pg_repack in Linux
Tags: postgres, pgrepack, database
Published: 2022-10-27 15:04:07

Here we are going to see installation steps for pg_repack in linux machine

What is a pg_repack?

- Pg_repack is an extension that was created and maintained as an open-source project by several authors.

- It removes the bloat from tables and indexes and optionally restores the physical order of clustered indexes.

[](https://www.youtube.com/watch?v=09NjATJdTck)

Follow us in medium:

[](https://medium.com/@mynotesoracledba)
Bought first hardware for my company
Tags: linux, startup, computerscience, ai
Published: 2022-10-27 14:58:03

today is a very special day! I decided to take sometime and start building my own software/robotics company. it wasn't an easy decision, giving up a very high role and starting from scratch, but I had an eye-opener discussion with my employer about a software he wanted me to build. He wanted me to make a surveillance software that detect when workers are talking to each other instead of working. 

As much as I am interested in AI and advancing my knowledge in the field, I instantly felt that I don't want to go ahead with this project. To him, this dev work was meaningless unless it serves a need in society. Of course, there are some good causes which we could've advanced, but he chose to proceed with this particular cause. We had a heated discussion about the ethics of AI and then I went home and did some more reading about it, until I came across this article: https://en.wikipedia.org/wiki/Ethics_of_artificial_intelligence which discussed many things among which there were the 3 laws that govern ethics of robotics imagined by the science fiction writer Isaac Asimov. 
- Robot should never harm human by action or inaction. 
- Robot should always obey human as long as the order didn't contradict with law 1 
- Robot should protect themselves as long as it doesn't contradict the first 2 laws. 

It does sound a bit science fictiony, but in a sense it is true. You can easily spot if a worker is slacking off and give them a penalty, rich people will get richer and the poor will get poorer. 

which brings us to the birth of my Company "Good robotics" :tada: :D 

well, I started my first working day today and thought I would write about it. 

The tech bit: 

Today I tried installing a dual boot on my macbook air using disk utility. Main purpose is to be able to use it for development as well as for writing stuff online. The disk utility is taking forever to finish, so I will stop here and maybe comeback with the results later.
Building an Object Schema Validator From Scratch
Tags: typescript, javascript, node
Published: 2022-10-27 14:53:04

Quite recently i took some time to build a Object schema validator, this was a direct result of working with MongoDB and mongoose. I thought about how the Schema validator worked in mongoose and what else is better than reinventing the wheel? If you've worked with mongoose and MongoDB you will understand what I'm talking about. This is not meant to replace the real deal, however I undertook this ordeal to get a better understanding of how the schema validator works under the hood and to deepen our problem solving skills.

When we are working with mongoose we will define an schema, this schema will validate the objects we try to add to the collection we attach the schema to, a typical example of a mongoose schema will look like below;

```typescript
import { Schema } from 'mongoose'

const UserSchema = new Schema({
  name: {
	 type: String,
  },
  age: {
	 type: Number
  },
  hobbies: {
	type: Array
  }
});
```

We then use this schema to create a model, whenever we try to add a new document to the collection, the schema will ensure that we define the right properties with the right values. Okay, we are going to be building our implementation with typescript. First we will define the types.

```typescript
export  interface  ISchema {
	[Key: string]: schemaProp
}

type  schemaProp = {
	type: schmeValueType
	required?: [boolean, string]
	default?: schmeValueType
	minLength?: [number, string]
	maxLength?: [number, string]
	min?: [number, string]
	max?: [number, string]
	validate?: [(v: string) =>  boolean, string];
}

type  schmeValueType = String | Number | Boolean | Object | Array<any> | null;
```

We used a dictionary type to type the property key on the schema, this is because we cannot explicitly tell the property key, but for sure we know that it will be a string. We expect every key on the schema to follow the `schemaProp` type.  On the `SchemaProp` type, we define some properites that will determine how we will validate each field on the object. The only required property is the `type`, which equals to the constructor of some basic types provided by TypeScript, let's create a schema class;


Continue To [Netcreed](https://netcreed-blog.vercel.app/post/YVDsblqy4BvtB0mVqpSz) read more about [this](https://netcreed-blog.vercel.app/post/YVDsblqy4BvtB0mVqpSz) and [more articles](https://netcreed-blog.vercel.app/post/YVDsblqy4BvtB0mVqpSz) like [this](https://netcreed-blog.vercel.app/post/YVDsblqy4BvtB0mVqpSz)
Common Gateway Interface (CGI)
Published: 2022-10-27 14:29:27

Providing the middleware between servers, external databases and information sources, a gateway interface is the mode in which the web application interacts with the external world. 

On typing _https://dev.to/_ your browser would redirect you to the homepage of DEV. But is that all you really use the web for?

As you traverse further in the world of World Wide Web, you'll come across documents that make you wonder, "How did they do this?"

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nvmix6ol8a0krtvc6tbm.png)
In this example, there are two pieces of dynamic information: the alphanumeric address (IP name) of the remote user and the load average on the serving machine. This is a very simple example but how was it done?

A more common use case would be forms. when a user fills out a form on a Web page and sends it in, it usually needs to be processed by an application program. The Web server typically passes the form information to a small application program that processes the data and may send back a confirmation message. This method or convention for passing data back and forth between the server and the application is called the common gateway interface (CGI). It is part of the Web's Hypertext Transfer Protocol (HTTP).



CGI turns the Web from a simple collection of static hypermedia documents into a whole new interactive medium, in which users can ask questions and run applications
👀 Looking for a Rating Component made with TailwindCSS?
Tags: react, html, tailwindcss, news
Published: 2022-10-27 14:24:54

Say no more,in our latest update we’ve added Rating Components and on top of that, we supercharged them with 16 variations! 

[https://wind-ui.com/components/ratings/](https://wind-ui.com/components/ratings/)

Grad it, use it & share the love 💚
How To Fix Dropbox Broken Links and Paths on The Latest Versions on The Mac
Tags: dropbox, broken, links, paths
Published: 2022-10-27 14:13:50

---
title: How To Fix Dropbox Broken Links and Paths on The Latest Versions on The Mac
published: true
description: How To Fix Dropbox broken Links and Paths on the latest versions
tags: dropbox, broken, links, paths
cover_image: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wpg4kj0pc2gcb48rww39.jpeg
# Use a ratio of 100:42 for best results.
# published_at: 2022-10-27 14:01 +0000
---

I opened Dropbox last night and it prompted me to update to the latest version to be ready for macOS 12. Which I did.

This morning I realized that all my links and paths using Dropbox files where broken. I opened `iTerm` to start working and it's yelling at me about not being able to find one file that contains aliases for some bash commands.

In other words Dropbox will now work more like Google Drive Desktop does. If you need the latest version of a file it needs to be open to sync, especially if you are using it on different devices.

The solution:
- Old Dropbox path: `~/Dropbox`
- New Dropbox path: `~/Library/CloudStorage/Dropbox`

Here you go! Go ahead and update your links/paths.
How to publish my Next.js app into npm package
Tags: help
Published: 2022-10-27 13:59:46

I built a simple Next.js app and want to publish it into npm package so we can reuse it in any other Next.js app.
I have npm user and published myself but failed.
It seems I had issue because of configuration of Webpack and Babel.

Next.js app is built with Typescript.

How can I make this successful?
It will be great if you share with me a public blog or documentation.
How many programming languages should one learn?
Tags: programming, beginners, tutorial
Published: 2022-10-27 13:59:07


You should learn all of them. 

One time I seen a job post that required a person to know php, python, java, ruby, C++, JavaScript, Objective-C, .Net, and COBOL.

To your point, I am highly doubtful that any one job would require you to simultaneously use so many languages. It was probably a lazy copy/paste or very poorly written job posting.

Over the years, I have learned and worked with all of those languages and am quite proficient in many, except COBOL--which I have never even encountered because it was before my time.

When I studied Computer Science at UC Berkeley, I remembered the professor for the Intro to Programming class telling a lecture hall with 300+ students that they don't teach programming languages at UC Berkeley because they expect anyone who understands the fundamentals to be able to pick up any programming language over a weekend and start running with it.

Learn all of the ones that are immediately useful to you to the point that you can become "conversationally fluent" in them.

In the OP's question details, a choice seems to be between mobile vs web, when in reality, the world of software engineering is much broader than that, i.e. the choice isn't between A or B, but A ... Z of possibilities. I had someone recently ask me how to decide between machine learning and computer security.

Here is a (non-exhaustive) list of sub-disciplines within computer science that I can think of, and some of their related programming languages:

Embedded devices - C
Mobile - iOS (Mac OS X, iPhone, iPad, Apple Watch) - Objective C, Swift
Mobile - Android - Java
Financial systems engineering - Java and C++
Ecommerce - Java
Computer Graphics (Rendering) / Gaming - C++, Unity
Computer Graphics (Vision) - ?
Data Science / Machine Learning - Python, R
Web (Backend) - too many to choose from; really depends on the shop you're working at and the stack they're already using.
Python + Django | Pylons | Flask
Ruby + Rails
JavaScript + NodeJS
C# + .Net
PHP + Laravel | CakePHP | Symphony
Databases - SQL (know ANSI SQL, and some of the tradeoffs between MySQL and PostgreSQL)
Web (Frontend) - HTML(5), CSS(3), JavaScript + a ton of JS libs
General - Unix Shell Scripting, Bash
Computer Music - ChucK
The above list is just barely scratching the surface, but hopefully is beneficial enough to the point that the reader can get started.
evalidate: secure eval() for python
Tags: python, security, eval
Published: 2022-10-27 13:54:51

[Evalidate](https://github.com/yaroslaff/evalidate) is python module for safe eval()'uating user-supplied (possible malicious) logical expressions in python syntax.

Install: `pip3 install evalidate`

Usage:
```python
from evalidate import safeeval, EvalException

src="a+b" # source code
# src="__import__('os').system('clear')"
c={'a': 1, 'b': 2} # context, variables which will be available for code

try:
    result = safeeval(src,c)
    print(result)
except EvalException as e:
    print("ERR:", e)
```

Gives output:

3
In case of dangerous code `src="__import__('os').system('clear')"`
output will be: `ERR: Operation type Call is not allowed`

Evalidate can be easily configured to allow/restrict special function calls (e.g. allow `int()` function, but not `os.system()`)

If compare to [asteval](https://newville.github.io/asteval/) (which is actually has much more features), evalidate is much faster in my benchmarks (benchmark code in repo): 0.017s vs 1.232s

Git repo: https://github.com/yaroslaff/evalidate
tuitorial npm run build..err
Tags: tuitorialrunbuilderr
Published: 2022-10-27 13:52:39

i m getting error at stage in npm run build after installing n creating the 4 files in the tuitorial, pls advise a solution.
C:\Users\sp128w10p>npm run build
npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.

> build
> tsc

Version 2.6.2
Syntax:   tsc [options] [file ...]

Examples: tsc hello.ts
          tsc --outFile file.js file.ts
          tsc @args.txt
How to host your site on netlify as a beginner developer
Tags: webdev, beginners, hosting, codenewbie
Published: 2022-10-27 13:43:52

Getting started as a beginner you must be thinking… How can I get my project online? Rest assured. Today will be the last day you’ll think like this. Because the answer is finally here.

Is your project ready for deployment?
Let’s go!

## What is netlify?
Netlify is a remote-first cloud computing company that offers a development platform that includes building, deploying, and serverless backend services for web applications and dynamic websites. In simple terms, it’s for getting your project online for the world to see.
![Netlify landing page screenshot](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jts56i2909etefv52pw6.png)

There are two significant methods to make deployment on netlify:

1. - Drag and drop
2. - Connecting your deployed project on GitHub or any remote git repositories to netlify.
We will go through both methods.

## Method 1:
Let's start by signing up on netlify. 
Sign Up 👉 [Here](https://www.netlify.com/)

After signing up. Click on the sites tab on your dashboard.

![Netlify user dashboard](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wtw4qafnlprwan40tlli.png)

![Upload photos Section](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1qt1zrp8mz2au0oj11oa.png)
Drag and drop your files folder 📂 as instructed. 
Congrats 🎊 You have deployed your site successfully. 
Easy right? :)




## Method 2:
You still signed up for netlify right? 
Alright! For this part, we will be using GitHub as our preferred git repository manager. 
Create an account on GitHub.
Go to [github.com](https://github.com/) to sign up/create one if you don’t have to.

![Github home page](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/d5fdu2nimu2lejqy88xh.png)
Deploy your project to GitHub using git. Check out how to do that [here](https://docs.github.com/en/get-started/importing-your-projects-to-github/importing-source-code-to-github/adding-locally-hosted-code-to-github)

Go back to your account on netlify. Navigate to your dashboard.
Click on **sites** tab. then click on add an existing project in the drop-down options.
![Deploy tab](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/evcukhu5ytxvgzohrl2r.png)

Click GitHub to connect your GitHub account.
![Remote git repository](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/iea5yjayar3z3h24ulxh.png)

Choose the project you want to host.
![Select Project Tab](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fihlghy83mrvgz42jt23.png)

Wait for the deployment process...

Congrats 🎊 You just made a deployment.
Your site is now live. 


**Note:** Netlify has a fancy feature where you won't have to make any more updates directly to your netlify deployment. It'll be in total sync with your GitHub repository. That means every time you push a new commit, it'll automatically update your live site.
Cool right 😎?

## Conclusion
I hope with this short guide, I am able to help you deploy your project online. Cheers 🥂