teleren/devto huggingface dataset:
Building a simple REST api with Express: A walkthrough.
Published: 2023-01-10 22:57:48


**Project Description**
This article is meant for developers and other technical audiences, looking to understand the implementation of a blogging app or any app really with the Express framework. Furthermore, this article is organized in a way that would cover the main areas of the project such as the technical requirements, design and implementation, challenges, deployment and testing and conclusion.

This project is a web application using Node.js, Express, and MySQL, It also demonstrates a one-to-many SQL relationship.

**Technology Stack**
- server side : Node.js, Express.js

- Database: MySQL

**Prerequisites**
- Basic knowledge of JavaScript, and SQL.
- MySQL server, Node.js and npm installed on your Machine.

**Step 1: Setting up the server**
- Create a new directory for the project.
- Navigate to the terminal of the directory. 
- Initialize a new Node.js project with the code below 

```
`npm init -y`
```

**Install the following dependencies**

nodemon - nodemon is a tool that helps develop node-based applications by automatically restarting the node application when file changes in the directory are detected.

Express - Express is a free and open-source Node.js web application framework.

bcrypt - bcrypt turns a simple password into fixed-length characters called a hash.

body-parser - body-parser is the Node.js body parsing middleware. 

crypto-js - crypto-js is a module in Node. js which deals with an algorithm that performs data encryption and decryption.

dotenv - The dotenv package is a great way to keep passwords, API keys, and other sensitive data out of your code.

express-rate-limit - express-rate-limiting is a strategy you can use to control traffic on a network, secure backend API and limits the number of unwanted requests that a user can make within a specific time frame.

helmet - helmet fills in the gap between Node.js and Express.js by securing HTTP headers that are returned by your Express apps.

joi - joi is used for schema description and data validation.

joi-password - joi-password is an extension of joi that helps in validating passwords.

jsonwebtoken - Often called JWT, or JSON Web Token. JWTs are mainly used for authentication. After a user signs in to an application, the application then assigns JWT to that user.

morgan - morgan is a Node. js and Express middleware to log(taking records of events that occur in a software) HTTP requests and errors, and simplifies the process.


winston - winston is designed to be a simple and universal logging library with support for multiple transports.
How to Upgrade MySQL 5.7 to 8.0 on Mac
Tags: mysql, webdev, howto
Published: 2023-01-10 22:54:29

As new versions of MySQL are coming out, at one point you will need to upgrade your MySQL version as well.

In this article, we will assume that we are using MySQL 5.7 for your local development on Mac and want to upgrade it the latest version (MySQL 8.0).

Followings are the steps to follow:

### Step # 1

Make sure to do database dump for all of your databases, as you will need these to re-import it again when MySQL is successfully upgraded.

### Step # 2

Confirm that your running MySQL 5.7 via the following command:

```bash
brew services list
```
this should show the `mysql` with `5.7` version running.


![brew services list with mysql](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vkjxx0ek0y1xaisrsh84.png)

Before you start upgrading process, make sure to double-check that your existing MySQL 5.7 setup ticks all the boxes on the sanity checklist before upgrading to MySQL 8.0.

You can do it by running the following command:

```bash
mysqlcheck -u root -p --all-databases --check-upgrade
```

The above command should `OK` for all without any errors.

### Step # 3

Check for MySQL processes via the following command:

```bash
ps -ax | grep mysql
```

![list of processes with PID](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nmfj2n2fi9r9fg028d3m.png)

Stop and kill any MySQL processes via the following command:

```bash
kill {PID}
```

### Step # 4

Take a backup of `my.cnf` located at: `/usr/local/etc/my.cnf`

and remove this file via command: `rm /usr/local/etc/my.cnf`

### Step # 5

Uninstall MySQL via the following command:

```bash
brew remove mysql
brew cleanup
```

You can confirm the uninstall by running `brew services list` and there should not be `mysql` listed


![brew services list not including mysql](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xjlvg8dj51luonbjeisn.png)

### Step # 6

Install latest version 8.0 of the MySQL:

```bash 
brew install mysql
brew services start mysql
```
Once done, you can confirm the version of the MySQL by running the command: `mysql --version` which should show the latest version of the MySQL


![mysql version](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xz5lmljp93f07el3msje.png)

### Step # 7

Setup default root password with the following command:

```bash
mysql_secure_installation
```
It should prompt you steps like the following screenshot:


![set mysql password](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/uewldo3bp0ynq2hieaio.jpeg)

### Step # 8

Connect to `mysql` via `Sequel Ace`

![sequel ace connection settings for mysql](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/84q41iauhg8d7wfwc6ib.png)

and create any relevant databases and import them from your previous backup dump.
Day 670 : The Sun
Tags: hiphop, code, coding, lifelongdev
Published: 2023-01-10 22:31:53

_liner notes_:
- Professional : Had a good day. Published the Web Component I've been working on and included it into the different sample demo apps and verified that they work. Updated some repos and got everything looking good.

- Personal : Last night, I worked on figuring out how to get a working Stripe app that I can use in side project. First, I tried StackBlitz, but for some reason I couldn't get Stripe to work. Could be because it's not really using a server but the browser. I redid it in Glitch and got the sample app working. Spent the rest of the night playing around with the API to get a better understanding. Also, watched some videos about a new laptop that I'm interested in that will be coming out in April. It's pretty awesome!

![View from the top of a mountain in Haleakala Crater, HI, USA looking over the clouds](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/oczdao0hnoj4uipuq91d.jpg)

Going to go through some more of the Stripe documentation and play around with the demo I got working. I downloaded "Glass Onion" and "Vinland Saga" last night and will probably watch those before going to be. I may also go through some tracks for the radio show. Sidenote, it's been cloudy and getting dark so early, I'm really missing the sun! haha

Have a great night!

peace piece
Dwane / conshus
https://dwane.io / https://HIPHOPandCODE.com
{% youtube c1GnrbfjGXU %}
Phalcon 5.1.4 Released and Update
Tags: phalcon, phalcon5, release
Published: 2023-01-10 23:42:04

---
title: Phalcon 5.1.4 Released and Update
published: true
date: 2023-01-10 22:21:09 UTC
tags: phalcon,phalcon5,release
canonical_url: 
---

Phalcon 5.1.4 is now available! This release contains a bug fix for the ACL adapter producing warnings.

Thank you to our community member that discovered this, otherwise those that used the `Phalcon\Acl\Adapter\Memory` would have been inundated with warnings about a deprecated Reflection method.

### Update

We have not been very active with our bug fixes or new functionality in the `phalcon/cphalcon` repository lately. This is because we have been working hard on the `phalcon/phalcon` repository (the v6 version), to _translate_ all the code from Zephir to PHP.

The reason behind this shift is that there are several issues with our ORM, pertaining to related records, and finding the issues and fixing them in `cphalcon` was going to be a very time consuming task. As such, we opted to work on v6, find the bugs there and then move them over to `cphalcon`.

Right now, the `Phalcon\Http` namespace is nearly done and after that there are a couple of files left for the `Phalcon\Mvc` namespace. With those two we will be in a position to debug and diagnose the issues at hand.

This will also bring us closer to having v6 ready and potentially release an alpha version for it.

A big thank you to our community!
How to create a single-tier highly available architechture on AWS
Tags: aws, bootstrap, devops, cloudformation
Published: 2023-01-10 22:07:03

### Scenario
This tutorial would take you on the process of easily creating a highly available single tier architecture on AWS.

<figure>
  <img
  src="https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sl3c8v95co2epk9aens8.png"
  alt="Deployment architecture.">
  <figcaption>Figure 1: Single tier, fault resistant, highly available AWS Architecture</figcaption>
</figure>

Figure 1 explains the entire architecture setup which includes:
* A Custom VPC with two Availability Zones for High Availability
* Each Availability Zone has a public subnet and a private subnet.
* There are two EC2 instances, which are in private subnets and the Application Load Balancer(ALB) is attached to two public subnets as expected.
* Two Network Address Translation(NAT) Gateways are attached to the the two public subnets and they allow Internet traffic to the instances in the private subnets via an associated Elastic IP  
* ALB is coupled with Auto Scaling
* There is one Target Group connecting both the EC2 instances
* EC2 Apache installation happens with the user data fromm the Auto Scaling Launch template
* CloudFormation, an Infrasture as code tool would be used to automatically Provision the servers and Network Infrastructure

### Essentials:
* An AWS Account with IAM admin Priviledges
* Git installed for cloning repository

### Procedures
* Navigate to the AWS Console or aws CLI 
* If youre using the console, search for cloudformation, Click on Create a new stack.
   * Two Stacks would be needed for this set up
* Click this [cloudformation](https://github.com/wandexdev/singletier-aws-architecture/tree/main/cloudformation) and follow instructions on the readme file.

Let me know in the comment section if you have any questions, I'll be happy to oblige.
Neco Date 2023
Published: 2023-01-10 22:03:45

[https://multischolar.com/neco-timetable/
](https://multischolar.com/neco-timetable/#utm_source=backlinks&utm_medium=search&utm_campaign=darry+ring+us&utm_content=Michelle)
https://plaza.rakuten.co.jp/chenlee/diary/202301110000/
https://www.provenexpert.com/necodate/
https://www.producthunt.com/@necodate2
https://www.divephotoguide.com/user/necodate/
https://www.diggerslist.com/necodate/about
http://www.heromachine.com/forums/users/necodate/
https://wakelet.com/@necodate973
https://vocal.media/authors/necodate
https://www.lifeofpix.com/photographers/necodate/
https://seedandspark.com/user/necodate
https://rosalind.info/users/necodate/
http://phillipsservices.net/UserProfile/tabid/43/userId/192813/Default.aspx
https://app.roll20.net/users/11494417/neco-date
http://uid.me/necodate
https://speakerdeck.com/necodate
https://social.msdn.microsoft.com/Profile/necodate
https://www.iheart.com/podcast/269-neco-exam-council-2023-107079810/
https://active.popsugar.com/@necodate/profile
https://www.longisland.com/profile/necodate
https://camp-fire.jp/profile/necodate
https://plazapublica.cdmx.gob.mx/profiles/necodate/activity
https://www.metal-archives.com/users/necodate
https://artmight.com/user/profile/912504
https://storium.com/user/necodate
https://trabajo.merca20.com/author/necodate/
https://telegra.ph/Neco-Date-2023-01-10
https://www.intensedebate.com/people/necodate
https://www.mifare.net/support/forum/users/necodate/
https://pinshape.com/users/2551672-necodate
http://foxsheets.com/UserProfile/tabid/57/userId/117752/Default.aspx
https://www.credly.com/users/neco-date/badges
https://www.myminifactory.com/users/necodate
https://www.speedrun.com/user/necodate
https://www.sqlservercentral.com/forums/user/necodate
https://leanin.org/circles/neco-date
https://myanimelist.net/profile/necodate
ChatGPT Is Taking Over
Tags: chatgpt, openai, ai, machinelearning
Published: 2023-01-10 22:02:35

OpenAI's ChatGPT has quickly become one of the most popular language models in the industry. ChatGPT, short for "chat generative pre-training transformer," is a state-of-the-art language model that generates human-like text.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/73n6qmya25u2xyfxq6ni.png)
One of the key reasons for ChatGPT's growing popularity is its ability to produce highly-readable and coherent text, which makes it a prime tool for a wide range of applications, such as content creation, creative ideas, automated tasks, and think tanks. Additionally, its scalability allows it to handle a wide variety of inputs and generate output on a wide range of topics. This has made it a great choice for businesses and organizations that need to generate large amounts of content.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/neqmnpzoeg8pl0ckajg5.jpg)
Another advantage is the ability to fine-tune the model for more specific tasks, which makes it accessible to a wide range of businesses regardless of their size or resources. OpenAI also provides a user-friendly API and tutorials to help developers and businesses get started with the model.

While ChatGPT has many advantages, it's important to note that it is still a machine-learning model and may have limitations. Researchers and engineers are working to improve and overcome these issues.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9c0r2m7c2wkmau3fklcm.jpg)
All in all, the growing popularity of OpenAI's ChatGPT is a testament to the powerful capabilities of AI in natural language processing. With its ability to generate human-like text, scalability, and ease of use, it's no wonder that ChatGPT has become a go-to tool for many businesses and organizations.
Phaser+ Tutorials: Create new Phaser project in less than a minute
Tags: gamedev, tutorial, html, phaser
Published: 2023-01-10 22:00:04

Hi,

this is my first Phaser tutorial, so I hope it will be useful for all those who plan to start a new project using Phaser.

As part of a phaser-plus project I started recently, there is **@phaser-plus/cli** - a command line tool for creating and developing Phaser projects.

## What is Phaser?
Phaser. is a free and open source software developed and owned by Richard Davey. You can visit their funding page and help them to make Phaser even better.

## How do I make a project?
Before you start creating a project, you need to have NodeJS 16+ installed on your machine. If you already have NodeJS 16+ installed, you can create a project by executing:

```
npx @phaser-plus/cli init --template=phaser my-phaser-game
```

## CLI Features
- Simple setup
- Hot module reload
- Optimized production build
- Support for Web workers
#DevDiscuss: Uses of WebAssembly
Tags: discuss, webassembly, devdiscuss
Published: 2023-01-10 21:53:16

*image created by [Margaux Peltat](https://www.patreon.com/margauxpeltat) for the [Chilled Cow YouTube channel](https://www.youtube.com/watch?v=lTRiuFIWV54)* 

Time for #DevDiscuss — right here on DEV 😎

{% embed https://dev.to/cocoandrew/revolutionizing-the-web-with-webassembly-a-comprehensive-guide-fa5 %}
Inspired by [@cocoandrew](https://dev.to/cocoandrew)'s Top 7 post, tonight’s topic is...uses of WebAssembly!

---

Questions:
- **What are the best uses for WebAssembly, in your experience?**
- **When should you avoid using WebAssembly?**
- **Do you have any stories of WebAssembly triumphs and/or fails?**
Reduce a JSON Object to just Entries of a Specific Type with jq
Tags: webdev, jq, json, javascript
Published: 2023-01-10 21:28:48

A large JSON object can be hard to work with when it has tons of top-level fields that you have to wade through. One way to make that data exploration more approachable is to reduce what is there — filtering by type is a great starting point. Here is how I do that with [the `jq` utility](https://stedolan.github.io/jq/manual/).

Let's say I want to start with a view of the JSON that is restricted to just the field whose values are of type `array`.

To do this, I need to use a couple different `jq` helper functions.

The `select` function produces the input value as the output if the given boolean expression is true. This is where I can do the `type` check. In this case, does the type of `.value` match `"array"`.

```
select(.value | type | match("array"))
```

Combining that `select` with `map`, I can filter an array to just those values that match my condition.

```
map(select(.value | type | match("array")))
```

Because `map` expects an array and I'm starting with an object, I need to open up with a `to_entries` call. This turns the object into an array of `.key` and `.value` pairs. Hence, the `.value` that appears inside the `select`. Putting a `from_entries` on the other end of the map will take the reduced array of key-value pairs and turn it back into an object.

```bash
some_obj | to_entries | map(...) | from_entries
```

Putting this all together:

```bash
jq '. | to_entries | map(select(.value | type | match("array"))) | from_entries' data.json
```

There is a less verbose way to do the above. The `to_entries` and `from_entries` can be collapsed into a [`with_entries`](https://stedolan.github.io/jq/manual/#to_entries,from_entries,with_entries) that replaces the `map` call.

```bash
jq '. | with_entries(select(.value | type | match("array"))' data.json
```

> `with_entries(foo)` is a shorthand for `to_entries | map(foo) | from_entries`, useful for doing some operation to all keys and values of an object.

This can be extended to select for multiple types with a little conditional logic like so:

```bash
jq '. | with_entries(select((.value | type) == "array" or (.value | type) == "object"))' data.json
```

That's just a drop in the bucket for how `jq` can be used to explore JSON data files.

With this tool being so general-purpose and having so many utilities, workflows like this one are where things get most interesting. Share your `jq` workflows with me in the comments below 👇

_If you enjoyed this post, consider [joining my newsletter](https://crafty-builder-6996.ck.page/e169c61186) or following me on [twitter](https://twitter.com/jbrancha). If this helped you or you have a question, feel free to drop me note wherever. I'd love to hear from you!_
A beautiful TUI for caniuse.com
Tags: webdev, go, javascript, cli
Published: 2023-01-10 21:25:26

---
title: A beautiful TUI for caniuse.com
published: true
description: caniuse release
tags: webdev,golang,javascript,cli
cover_image: ![cover](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4tpbccuza6kjd71uskxz.png)
---

Hey, I just released a TUI for caniuse.com. I tried to keep the most important informations from the web version. It work offline as well after the initial launch and it update itself as well on regular basis.

more details here: https://github.com/fkhadra/caniuse

![main screen](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/b4ex5vvxkevzbcdjc9pp.png)

![search](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/y9u4gsyt3ooewm7iwh57.png)

![support table](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ibeh2bioliygudb882ox.png)
How to send a file in form of a Buffer as a FormData in node.js
Tags: dailystruggle, node
Published: 2023-01-10 20:30:22

---
title: How to send a file in form of a Buffer as a FormData in node.js
published: true
description: 
tags: dailystruggle, nodejs
# cover_image: https://direct_url_to_image.jpg
# Use a ratio of 100:42 for best results.
# published_at: 2023-01-10 20:26 +0000
---

This is slightly modified excerpt from https://github.com/octet-stream/form-data#readme

```ts
import {Readable} from "stream"

import {FormData} from "formdata-node"

class BlobFromStream {
  #stream: Readable
  size: number

  constructor(stream: Readable, size: number) {
    this.#stream = stream
    this.size = size
  }


  stream() {
    return this.#stream
  }

  get [Symbol.toStringTag]() {
    return "Blob"
  }
}

const content = Buffer.from("Stream content")

const stream = new Readable({
  read() {
    this.push(content)
    this.push(null)
  }
})

const form = new FormData()

form.set("stream", new BlobFromStream(stream, content.length), "file.txt")

await fetch("https://httpbin.org/post", {method: "post", body: form})

```

just in case anyone would be struggling with this same as me.
Sharing Early: Quick Review with a Preview 👀
Tags: blog, softwareengineering
Published: 2023-01-10 20:18:13

Freelancers and remote workers are particularly aware of the necessity to share the work. But there are always questions about why and how.

What do you think about sharing early?

<h3>Work in Progress</h3>
Sharing work in progress can be beneficial. Even though we often think sending <a href="https://codingforspeed.com/fighting-perfectionism/" title="Fighting Perfectionism">incomplete work</a> is wrong, there are many reasons why you should start doing this.

<h3>Saves time</h3>
It's easy to lose creativity and a compass while working under <a href="https://codingforspeed.com/are-deadlines-pointless-or-necessary/" title="Deadlines: pointless or necessary?">pressure</a>. Sharing your work with clients confirms if the direction you're going in is correct.

If not, some further explanation will surely help and save time.

<h3>Work is better</h3>
The project you're working on can be great without previewing it before it's finished, but clients could give an idea or two with a preview.

And this could make it perfect. And truthfully, we are all in the business of making our clients/bosses happy. Greater satisfaction equals greater reward.

<h3>Brings more people</h3>
Sharing work before it's completed could bring help in the shape of ideas, resources, and most importantly, people and collaborators. This will make the process far easier and maybe even bring more clients.

Maybe many people are scared or hesitant when sharing work in progress, but this could bring many positive things, save time and build relationships.

Considering that today we all live in a "remote world", most of your clients will be somewhere far away from you, so the preview is a must.

When will you start using it?

Reposted to [Blog](https://codingforspeed.com/sharing-early-quick-review-with-a-preview/)
Testing and Deploying your Blog API
Tags: webdev, tutorial, node, api
Published: 2023-01-10 20:00:00

Welcome to the last part of the series where I'd be talking about testing the routes and deploying.

### Testing
In order to test this api, I created an [api documentation](https://naija-diary.cyclic.app/api-docs/) with [swaggerUI](https://swagger.io/tools/swagger-ui/). It allows you to supply values based on the schema defined and also returns the appropriate response, error messages and status codes.

## Deployment

The deployment was done on [cyclic.sh](https://cyclic.sh). It is as simple as signing up with your github account then linking the repository containing your project then you finally set your environmental variables.
Voila! Your project is already deployed and ready for use.

### Conclusion
Kudos to you for reaching the last article of the series. I believe you have been able to pick one or two concepts to apply to your next project. Kindly do well to reach me on [twitter](https://twitter.com/jhhornn) if there's any part you would like me to write extensively on.
I also owe all of this to leading tech institution in Africa, [AltSchool Africa](https://www.altschoolafrica.com/).