<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: briankarlsayen</title>
    <description>The latest articles on Forem by briankarlsayen (@blu3fire89).</description>
    <link>https://forem.com/blu3fire89</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F706483%2F54a41f5c-1fab-42d9-a035-b8b2a367540f.jpeg</url>
      <title>Forem: briankarlsayen</title>
      <link>https://forem.com/blu3fire89</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/blu3fire89"/>
    <language>en</language>
    <item>
      <title>Create an NodeJs Server in Typescript</title>
      <dc:creator>briankarlsayen</dc:creator>
      <pubDate>Fri, 25 Aug 2023 06:38:27 +0000</pubDate>
      <link>https://forem.com/blu3fire89/create-an-expressjs-server-in-typescript-32g4</link>
      <guid>https://forem.com/blu3fire89/create-an-expressjs-server-in-typescript-32g4</guid>
      <description>&lt;p&gt;If you're a beginner on typescript or some veteran who tends to forget how to setup a typescript server the you've come to the right place.&lt;/p&gt;

&lt;p&gt;Here are the steps to create a typescript server up and running:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Make a folder then, initialize the node project
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm init -y
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Install dependencies, in this case I'm installing expressjs as my web app framework but feel free to use others like fastify
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm i express cors dotenv
npm i -D typescript @types/node @types/express concurrently
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Initialize tsconfig
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npx tsc --init
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Edit tsconfig.json
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"outDir": "./dist"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Edit package.json scripts
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"scripts": {
"build": "npm install typescript &amp;amp;&amp;amp; npx tsc",
"start": "node dist/index.js",
"dev": "concurrently \"npx tsc --watch\" \"nodemon -q dist/index.js\""
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Create a file named index.ts, this will server as the root file for your server. Paste this inside index.ts.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import express, { Express } from 'express';
import dotenv from 'dotenv';
import cors from 'cors';
import http from 'http';
dotenv.config();

const app: Express = express();
const port = process.env.PORT ?? 5905;
app.use(cors());
const server = http.createServer(app);

server.listen(port, () =&amp;gt; {
  console.log(`⚡️[server]: Server is running at http://localhost:${port}`);
});

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Run build
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm run build
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Finally run the server
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm run dev
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>typescript</category>
      <category>node</category>
      <category>javascript</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Add Localstorage to Reduxtoolkit</title>
      <dc:creator>briankarlsayen</dc:creator>
      <pubDate>Wed, 03 Aug 2022 13:52:49 +0000</pubDate>
      <link>https://forem.com/blu3fire89/add-localstorage-to-reduxtoolkit-3de9</link>
      <guid>https://forem.com/blu3fire89/add-localstorage-to-reduxtoolkit-3de9</guid>
      <description>&lt;p&gt;Are you annoyed that your saved data disappear whenever you refresh the page? There are many ways of saving your data, such as saving it in the localstorage, session storage, or in a database. This tutorial is how you can store reduxtoolkit data in your localstorage.&lt;/p&gt;

&lt;p&gt;I presumed in reading this that you already have a &lt;strong&gt;working app that uses reduxtoolkit&lt;/strong&gt; and searching on ways to store the data, so I won't explain details on the installation of reduxtoolkit and such.&lt;/p&gt;

&lt;h2&gt;Introduction&lt;/h2&gt;

&lt;h4&gt;What is a Local Storage?&lt;/h4&gt;

&lt;p&gt;A place where you can store your browser data. The stored data is a key-value pair which can &lt;strong&gt;persist even after reload or browser is closed&lt;/strong&gt;.&lt;br&gt;
    You can access your storage data in google chrome by using inpect tool, then go to the application tab. There you can see the stored data in your localstorage.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fuabxnbhv9p3k1pu7sky0.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fuabxnbhv9p3k1pu7sky0.PNG" alt="localstorage image" width="800" height="426"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;What is ReduxToolKit?&lt;/h4&gt;

&lt;p&gt;Redux in simple terms is a package which has the &lt;strong&gt;ability to store the state of variables globally&lt;/strong&gt;. Reduxtoolkit is a package is intended to be the standard way to write Redux logic. It solves the problems with redux such as the: Complicated redux store, Multiple broiler plates, and lots of packages needed to work.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjldw1po3thd2tb3mmda6.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjldw1po3thd2tb3mmda6.PNG" alt="Redux state image" width="800" height="392"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;How to save my redux state in the localstorage?&lt;/h2&gt;

&lt;p&gt;Lucky for us there is a package called &lt;strong&gt;Redux Persist&lt;/strong&gt; which is used to store data in the local storage.&lt;/p&gt;

&lt;p&gt;To install it type the following in your console:&lt;/p&gt;

&lt;pre&gt;
npm i redux-persist
&lt;/pre&gt;

&lt;p&gt;or in yarn:&lt;/p&gt;

&lt;pre&gt;
yarn add redux-persist
&lt;/pre&gt;

&lt;p&gt;Configure your Store.js like this:&lt;/p&gt;

&lt;pre&gt;
import { configureStore } from '@reduxjs/toolkit'
import fetchPokemons from './reducers/pokemonSlice'
import pokemonTeam from './reducers/pokemonTeamSlice'
import storage from 'redux-persist/lib/storage'
import {combineReducers} from "redux"; 
import { persistReducer } from 'redux-persist'

const reducers = combineReducers({
  fetchPokemons,
  pokemonTeam     
 });

 const persistConfig = {
  key: 'root',
  storage
};

const persistedReducer = persistReducer(persistConfig, reducers)

const Store = configureStore({
  reducer: persistedReducer
})

export default Store
&lt;/pre&gt;

&lt;p&gt;Then configure your index.js like this:&lt;/p&gt;

&lt;pre&gt;
import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import App from './App';
import {Provider} from 'react-redux';
import Store from './Store';
import {BrowserRouter} from 'react-router-dom';
import { PersistGate } from 'redux-persist/integration/react'
import { persistStore } from 'redux-persist'
let persistor = persistStore(Store);

ReactDOM.render(
  &amp;lt; React.StrictMode&amp;gt;
    &amp;lt; BrowserRouter&amp;gt;
      &amp;lt; Provider store={Store}&amp;gt;
        &amp;lt; PersistGate loading={null} persistor={persistor}&amp;gt;
          &amp;lt; App /&amp;gt;
        &amp;lt; /PersistGate&amp;gt;
      &amp;lt; /Provider&amp;gt;
    &amp;lt; /BrowserRouter&amp;gt;
  &amp;lt; /React.StrictMode&amp;gt;,
  document.getElementById('root')
);
&lt;/pre&gt;

&lt;p&gt;After that is done you will now see that the redux state will be saved in your localstorage&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9m7nwrr3nc93gc8qfs3g.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9m7nwrr3nc93gc8qfs3g.PNG" alt="Redux state image" width="800" height="417"&gt;&lt;/a&gt;&lt;br&gt;
For more information you can you can read docs of the &lt;a href="https://redux-toolkit.js.org/usage/usage-guide#use-with-redux-persist" rel="noopener noreferrer"&gt;Reduxtoolkit&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>redux</category>
      <category>react</category>
      <category>javascript</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Login Authentication</title>
      <dc:creator>briankarlsayen</dc:creator>
      <pubDate>Wed, 03 Aug 2022 13:52:47 +0000</pubDate>
      <link>https://forem.com/blu3fire89/login-authentication-3in</link>
      <guid>https://forem.com/blu3fire89/login-authentication-3in</guid>
      <description>&lt;p&gt;//disclaimer, introduction&lt;br&gt;
//overview of the project&lt;br&gt;
//explain each the techs&lt;br&gt;
//show code&lt;br&gt;
This project is a beginner's overview on how to create a login &lt;br&gt;
authentication.&lt;/p&gt;

&lt;h1&gt;
  
  
  Overview
&lt;/h1&gt;

&lt;p&gt;Login authentication is how the web keeps track on users preference by storing individual the data in a server.&lt;br&gt;
This project is done by using JWT, express.js, and bcrypt.&lt;/p&gt;

&lt;h3&gt;
  
  
  What is JWT?
&lt;/h3&gt;

&lt;p&gt;JWT, or JSON Web Token, is an open standard used to share security information between two parties — a client and a server. Each JWT contains encoded JSON objects, including a set of claims. JWTs are signed using a cryptographic algorithm to ensure that the claims cannot be altered after the token is issued. In other words JWT connects the server and the user.&lt;/p&gt;

&lt;h3&gt;
  
  
  What is crypt?
&lt;/h3&gt;

&lt;p&gt;A library to help you hash passwords. It's slowness and multiple rounds ensures that an attacker must deploy massive funds and hardware to be able to crack your passwords.&lt;/p&gt;

&lt;h3&gt;
  
  
  What is NodeJs?
&lt;/h3&gt;

&lt;p&gt;Is an open-source, cross-platform runtime environment that allows developers to create all kinds of server-side tools and applications in JavaScript.&lt;/p&gt;

&lt;h3&gt;
  
  
  What is ExpressJs?
&lt;/h3&gt;

&lt;p&gt;Is the most popular Node web framework, and is the underlying library for a number of other popular Node web frameworks. It is used for designing web apps, apps that run on web browser, easily and quickly.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Login / Register authentication</title>
      <dc:creator>briankarlsayen</dc:creator>
      <pubDate>Wed, 03 Aug 2022 13:52:45 +0000</pubDate>
      <link>https://forem.com/blu3fire89/login-register-authentication-5gg5</link>
      <guid>https://forem.com/blu3fire89/login-register-authentication-5gg5</guid>
      <description>&lt;h3&gt;
  
  
  Overview
&lt;/h3&gt;

&lt;p&gt;This is a simple login authentication for backend. You need to basic understanding on how to use Express.js, Mongoose, and Node.js. I assumed that you already have an app that is connected to MongoDB so I won't explain on that and just focus on the login and register part.&lt;/p&gt;

&lt;p&gt;You need to install the following libraries:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;yarn add express jsonwebtoken bcrypt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Technologies
&lt;/h3&gt;

&lt;p&gt;In high level explanation:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;express.js - backend web application framework for Node.js&lt;/li&gt;
&lt;li&gt;jsonwebtoken - standard way of transmitting information between parties as a JSON object.&lt;/li&gt;
&lt;li&gt;bcrypt - is a password-hashing function.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  The code
&lt;/h3&gt;

&lt;h4&gt;
  
  
  Register
&lt;/h4&gt;

&lt;p&gt;Let's say we are registering a google account. There are rules that we need to follow, those rules should be met in order to successfully create and account. Here we call them error handling.&lt;/p&gt;

&lt;p&gt;Let's check if the request is in proper type and length:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const {username, password, email} = req.body;
  if (!username || typeof username !== "string"){
    return res.json({status: 'error', error: 'Invalid username'})
  }
  if (!password || typeof password !== "string"){
    return res.json({status: 'error', error: 'Invalid password'})
  }
  if (password.length &amp;lt; 6){
    return res.json({status: 'error', error: 'Password too short. Should atleast be 6 characters'})
  }
  if (!email || typeof password !== "string"){
    return res.json({status: 'error', error: 'Invalid Email'})
  }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then check if it is unique:&lt;br&gt;
User is the name of the mongoDB model.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const newUser = await User.findOne({username}).lean()
const newMail = await User.findOne({email}).lean()
if(newUser){
    return res.status(500).json({status: 'error', error: 'Username is already inuse'})
  }
  if(newMail){
    return res.status(500).json({status: 'error', error: 'Email is already inuse'})
  }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After that we hash the password to be unreadable in the database:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const user = new User({
    username: username,
    password: await bcrypt.hash(password, 10),
    email: email
  })
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then try to save the account in the database:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;try {
    const saveUser = await user.save()
    res.status(200).json({status:'ok', message: 'Account succesfully made'})
  }
  catch(err){
    return res.status(400).json({msg: err.message})
  }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When you've register an account you will notice that the password is different from what you've typed. &lt;/p&gt;

&lt;h4&gt;
  
  
  Login
&lt;/h4&gt;

&lt;p&gt;You need first to create a secret token, it is like your housekey, use to prevent others from accessing your important things while making you able to access it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;JWT_SECRET = I'm am the key~~@-@~~E.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Hashing is a one-way operation which means the server cannot decrypt the password. What you can do is to compare the hashed typed(password) and server password(user.password) to verify.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;bcrypt.compare(password, user.password)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;jwt.sign is used to create a token that usually is stored in the localstorage to access the data.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const token = jwt.sign({ id: user._id, username: user.username}, JWT_SECRET)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Login Fullcode
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const {username, password} = req.body;
JWT_SECRET = I'm am the key~~@-@~~E.

  // check username, password, email exist
  if (!username || typeof username !== "string"){
    return res.json({status: 'error', error: 'Invalid username'})
  }
  if (!password || typeof password !== "string"){
    return res.json({status: 'error', error: 'Invalid password'})
  }
  if (password.length &amp;lt; 6){
    return res.json({status: 'error', error: 'Password too short. Should atleast be 6 characters'})
  }

  try {
    const user = await User.findOne({username}).lean()  
    if(!user){
      return res.status(500).json({status: 'error', error: 'Invalid username or password'})
    }
    if(await bcrypt.compare(password, user.password)){
      const token = jwt.sign({ id: user._id, username: user.username}, JWT_SECRET)
      return res.status(200).header('auth-token', token).send({token, status: 'ok'})
    }
    return res.status(500).json({status: 'error', error: 'Invalid username or password'})
  }
  catch(err){
    return res.status(500).json({msg: err.message})
  }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Register Fullcode
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const {username, password, email} = req.body;
  if (!username || typeof username !== "string"){
    return res.json({status: 'error', error: 'Invalid username'})
  }
  if (!password || typeof password !== "string"){
    return res.json({status: 'error', error: 'Invalid password'})
  }
  if (password.length &amp;lt; 6){
    return res.json({status: 'error', error: 'Password too short. Should atleast be 6 characters'})
  }
  if (!email || typeof password !== "string"){
    return res.json({status: 'error', error: 'Invalid Email'})
  }
  const newUser = await User.findOne({username}).lean()
  const newMail = await User.findOne({email}).lean()
  if(newUser){
    return res.status(500).json({status: 'error', error: 'Username is already inuse'})
  }
  if(newMail){
    return res.status(500).json({status: 'error', error: 'Email is already inuse'})
  }
  const user = new User({
    username: username,
    password: await bcrypt.hash(password, 10),
    email: email
  })
  try {
    const saveUser = await user.save();
    //res.send({user: user._id})
    res.status(200).json({status:'ok', message: 'Account succesfully made'})
  }
  catch(err){
    return res.status(400).json({msg: err.message})
  }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Node v17.0.1 bug</title>
      <dc:creator>briankarlsayen</dc:creator>
      <pubDate>Wed, 03 Aug 2022 13:52:44 +0000</pubDate>
      <link>https://forem.com/blu3fire89/node-v1701-bug-146o</link>
      <guid>https://forem.com/blu3fire89/node-v1701-bug-146o</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fafxj0qj7q6fce7hkv4g1.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fafxj0qj7q6fce7hkv4g1.PNG" alt=" " width="799" height="19"&gt;&lt;/a&gt;&lt;br&gt;
Error encountered when running yarn start, npm start.&lt;/p&gt;

&lt;p&gt;Probably caused by issue with webpack &lt;a href="https://github.com/webpack/webpack/issues/14532" rel="noopener noreferrer"&gt;digital envelope routines::unsupported&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;A quick fix is configuring package.json script.&lt;/p&gt;

&lt;pre&gt;
"start": "react-scripts --openssl-legacy-provider start"
&lt;/pre&gt;

</description>
      <category>react</category>
      <category>javascript</category>
      <category>node</category>
    </item>
    <item>
      <title>SonarQube windows setup</title>
      <dc:creator>briankarlsayen</dc:creator>
      <pubDate>Wed, 03 Aug 2022 13:52:42 +0000</pubDate>
      <link>https://forem.com/blu3fire89/sonarqube-windows-setup-1b7h</link>
      <guid>https://forem.com/blu3fire89/sonarqube-windows-setup-1b7h</guid>
      <description>&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Download &lt;a href="https://www.sonarqube.org/downloads/?gads_campaign=Asia-SonarQube&amp;amp;gads_ad_group=SonarQube&amp;amp;gads_keyword=sonarqube" rel="noopener noreferrer"&gt;sonarcube&lt;/a&gt; and &lt;a href="https://docs.sonarqube.org/latest/analysis/scan/sonarscanner/" rel="noopener noreferrer"&gt;sonar-scanner&lt;/a&gt;. &lt;br&gt;
Extract both zip files to to C:\&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;At &lt;code&gt;C:\sonar-scanner\conf\sonar-scanner.properties&lt;/code&gt; paste this:&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#Configure here general information about the environment, such as SonarQube server connection details for example
#No information about specific project should appear here

#----- Default SonarQube server
sonar.host.url=http://localhost:9000

#----- Default source code encoding
sonar.sourceEncoding=UTF-8
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Add window environment variables
&lt;code&gt;ControlPanel &amp;gt; SystemAndSecurity &amp;gt; System &amp;gt; AdvanceSystemSettings &amp;gt; Environment &amp;gt; EnvironmentVariables&lt;/code&gt;
add new path:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;C:\sonar-scanner\bin
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Create a sonarqube project&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In your browser go to:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;http://localhost:9000/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Create a project, then save the generated token and the generated command. We will need the command to run the project later.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;On your code, create file called &lt;code&gt;sonar-project.properties&lt;/code&gt;, paste this:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# must be unique in a given SonarQube instance
sonar.projectKey=my:project

# --- optional properties ---

# defaults to project key
# sonar.projectName=My project
# defaults to 'not provided'
#sonar.projectVersion=1.0

# Path is relative to the sonar-project.properties file. Defaults to .
sonar.sources=.

# Encoding of the source code. Default is default system encoding
#sonar.sourceEncoding=UTF-8
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Change projectKey same with the name of created sonarqube project.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Run the sonarqube&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Run &lt;code&gt;C:\sonarqube\bin\windows-x86-64\StartSonar.bat&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Paste the saved generated command inside your project to run the sonarqube.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdctpslkr04tbix4ohyzt.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdctpslkr04tbix4ohyzt.PNG" alt=" " width="660" height="109"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Go back to &lt;code&gt;http://localhost:9000&lt;/code&gt;&lt;br&gt;
Now you can see the vulnerabilities and given suggestion by sonarqube.&lt;/p&gt;

</description>
      <category>programming</category>
      <category>tutorial</category>
      <category>testing</category>
    </item>
    <item>
      <title>ReactJS + ViteJS</title>
      <dc:creator>briankarlsayen</dc:creator>
      <pubDate>Wed, 03 Aug 2022 13:52:41 +0000</pubDate>
      <link>https://forem.com/blu3fire89/reactjs-vitejs-392k</link>
      <guid>https://forem.com/blu3fire89/reactjs-vitejs-392k</guid>
      <description>&lt;h2&gt;What is ViteJS?&lt;/h2&gt;

&lt;p&gt;In simple terms, it is a web builder that focuses on speed&lt;/p&gt;

&lt;p&gt;Compared to the traditional way of using create-react-app that uses webpack, this has much faster build time&lt;/p&gt;

&lt;h2&gt;How to Install?&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm create @vitejs/app
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;it will prompt you on the settings that you want, or if you want to use default settings, use this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm init vite@latest [app name] -- --template react
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;cd [app name], then install the dependecies:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;time to run the project by typing:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm run dev
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
    </item>
  </channel>
</rss>
