Environment variables in Node.js

Learn how to work with environment variabes in Node.js Can check environment variables: Start node REPL: node in terminal (before this check if node is installed by node -v) console.log(process.env) const app = require('http').createServer((req, res) => res.send('Ahoy!')); //in case of PORT, this particular var is undefined usually in all cloud providers, so this way works - gets 3000, or prefers if YOU define something in sys env const PORT = process....

May 31, 2022 · 4 min · Anant

Day11 #100DaysOfCode

To begin with, To begin, obtain OAuth 2.0 client credentials from the Google API Console Got this from below: Google Documentation https://developers.google.com/identity/protocols/oauth2 Configuration https://console.developers.google.com/apis/credentials Then your client application requests an access token from the Google Authorization Server, extracts a token from the response, and sends the token to the Google API that you want to access. Same steps in detail: given here: https://developers.google.com/identity/protocols/oauth2 New Project: on same page, asks for Authorized redirect URI...

May 30, 2022 · 1 min · Anant

Day10 #100DaysOfCode (Next app Part 2)

Continuing the 100doc challenge, although with a break 😜 Read Part 1 here. Submit the ‘message sent to a user’ to DB, by username How to fetch promise version async await version https://rapidapi.com/guides/fetch-api-async-await Dont forget to add req body! in client: in /[username].js function addNoteHandler(noteData) { //console.log(`in [username], got noteData: ${JSON.stringify(noteData)}`); //submit to DB API fetch("/api/add-note", { method: "POST", body: JSON.stringify({ test: "test" }), // Adding headers to the request. It is actually optiona here....

May 28, 2022 · 3 min · Anant

Some cool Git Shortcuts

git commit -am “message” git commit -am "message Adds all the files in current working directory Alias git config --global alias.ac "commit -am" # How to use it: > git ac "message" Reword the last commit message git commit --amend -m "new message" Also useful when you forgot to include or stage a couple of files with last commit. git commit --amend --no-edit #if want no change in prev commit message This only works until before you havent alreday pushed your code to a remote repo....

May 28, 2022 · 3 min · Anant

My Next Project

npx create-next-app took ~ 1min Add components\note\NewNoteForm.js and its css return above component from main index.js pages\index.js import NewNoteForm from "../components/note/NewNoteForm"; export default function Home() { return <NewNoteForm />; } Notice that Card is needed Add: components\ui\Card.js components\ui\Card.module.css Note finally looks: Styling needed at root: Remember this, maybe _app.js that will work on ALL pages. Will do later Customize NewNoteForm Add a heading remove unwanted fields and code to read them...

May 17, 2022 · 11 min · Anant