投稿時間:2022-02-05 06:24:01 RSSフィード2022-02-05 06:00 分まとめ(25件)

カテゴリー等 サイト名等 記事タイトル・トレンドワード等 リンクURL 頻出ワード・要約等/検索ボリューム 登録日
TECH Engadget Japanese 2013年2月5日、Nexusシリーズ最大サイズのタブレット「Nexus 10」が発売されました:今日は何の日? https://japanese.engadget.com/today5-203027393.html android 2022-02-04 20:30:27
AWS AWS for SAP Maintain an SAP landscape inventory with AWS Systems Manager and Amazon Athena https://aws.amazon.com/blogs/awsforsap/maintain-an-sap-landscape-inventory-with-aws-systems-manager-and-amazon-athena/ Maintain an SAP landscape inventory with AWS Systems Manager and Amazon AthenaIntroduction Effective maintenance and operation of SAP systems rely on access to system information to support decision making Inquiries about for example SAP kernel version installed ABAP components or simply active SAP systems are often part of IT operation activities Furthermore these inquiries are typically more elaborate for example listing systems matching a particular version of … 2022-02-04 20:52:58
海外TECH Ars Technica Windows 11’s preview builds are getting more experimental in 2022 https://arstechnica.com/?p=1831730 insider 2022-02-04 20:06:08
海外TECH MakeUseOf How to Install Hyper-V on Windows 11 Home https://www.makeuseof.com/install-hyper-v-windows-11-home/ windows 2022-02-04 20:45:23
海外TECH MakeUseOf What Is Vivid Mode on the Nintendo Switch OLED? https://www.makeuseof.com/what-is-nintendo-switch-oled-vivid-mode/ vivid 2022-02-04 20:30:01
海外TECH MakeUseOf 8 Ways to Fix Blank Icons on Windows 10 https://www.makeuseof.com/windows-10-fix-blank-icons/ windows 2022-02-04 20:16:12
海外TECH DEV Community Month #1: Building a Startup From Scratch https://dev.to/digitalgreyhat/month-1-building-a-startup-from-scratch-2n8b Month Building a Startup From ScratchEvery year I set myself new unattainable goals for the new year I never achieved the goals Year by year passed I looked at tons of “How To Make Money videos on YouTube I was a failure But this year everything should change I set myself one goal Building a Startup From ScratchAlong the way I ll be documenting and sharing the whole process on IndieHackers and Twitter This should serve as a motivation for others but aswell for me My BackgroundI m a self taught developer who learned the wrong programming languages Several years ago I started to learn HTML CSS and PHP I don t regret learning HTML and CSS However I regret learning PHP At the time of learning it PHP was the future Now in PHP is basically dead Over the last two years I have learned Python Machine Learning and Web Security Penetration Testing My current knowledge of design marketing and building a startup is zero Additionally I have a job so I will be a part time Indie Hacker Week This week the challenge has officially started weeks left days I already have a rough idea about what I want to build My idea in a nutshell a web app where users can create save their tools programming languages etc and monitor the cost of those tools To begin with I created a Twitter account with the username digitalgreyhat For the profile picture I chose a slightly more eye catching and creative profile picture than other accounts I created the D model on ReadyPlayerMe me and then I used pfpmaker com for the background border of the profile picture During the first few days I sticked with an account banner made by a generator It had a solid color background and some text on it which looked pretty bad So I decided to design my own banner in Figma I kept it simple by only making a gradient and adding my D character over the follow button Simplicity is the key to success Left old account banner Right new account bannerLast but not least a well written bio on Twitter is very important To write my bio I took inspiration from bigger Indie Hackers on Twitter I rewrote my bio times because I felt like the bio didn t reflect my personality and my goal The last question I asked myself was what to post on this account I decided to post helpful stuff about JavaScript Design Growth and my journey of building a startup My hope is to get most of my customers from my Twitter account when I launch Fun Fact On Sunday I got an invite code for IndieHackers and in the evening IndieHackers was not invite only anymore I wrote an article about it on IH and it got a good amount of views even the founder of IH replied to my article This gave me a lot of confidence and motivation Week In order to stay organized I need a place where I can keep all my stuff and be able to manage it all Therefore I started the week by setting up a structured Notion so workspace It contains everything from design to growth This is how the main part of my notion workspace looks To get some basic knowledge on how to build a product startup I did some research on the internet I came across some awesome blog posts on medium com Here are the steps you need to follow when building a product based on what I learned from the blog posts Market Research →look at what people need Collect ideas for product →analyze the problems and find a solvable problem Validate idea →ask people what they think of it look at the competition etc Build a beta version →build a beta version and invite people to test give feedback️ Improve by feedback →improve your tool by hearing the beta testers feedback Make a hype →try to build a hype about your product best case Launch →on ProductHunt Twitter Once I had a basic knowledge of building a product I got into the design part of a product The design is an essential part of a product It determines whether you win or lose a customer Although I want to create a great pixel perfect design I have to keep an eye on myself Perfectionism is my enemy I learned this in the book “RefactoringUI by Adam Wathan amp Steve Schoger The book helps me to get a basic understanding of the design process and design principles I read about three or four pages of it every day Week I learned the basics of design last week and now I am applying them to my project I used dribbble com and behance com for design inspiration I copied any image that caught my eye into Eagle Eagle is an awesome tool for organizing reference images and working with them I may write a separate article about it since it has so many features Then I gave each design I liked a tag such as sidebar or header and I wrote a short description of what I liked about it After I gathered all my inspiration I made folders for each tag All images with the same tag are sorted and collected in the appropriate folder My “sidebar folder collection in EagleThe next step is to draw the wireframes First I attempted to draw a wireframe in Microsoft Whiteboard but that didn t work well The Microsoft Whiteboard does not allow you to draw shapes and does not have a font selection I found an open source alternative called tldraw com Completely free of charge no need to sign up and it s privacy oriented Made by steveruizok a fellow Indie Hacker tldraw com worked like a charm It made my life a bit easier and the wireframes turned out really well In my opinion Week As part of my weekly routine I tried to tweet something every day I failed this week On Tuesday I suddenly saw blurry in one eye I went to the doctor for treatment Due to the amount of time I spend in front of the computer one of my eyes was really dry which caused the blurry vision I drastically reduced my screen time the next few days and couldn t get anything done I tried drawing wireframes on normal paper but I messed it up completely So I was writing this blog post in the remaining days of the week Statistics Twitter IndieHackers Followers Points Dev to Followers Unicorns Growth Negative Growth Learned from Mistakes Expect the unexpected →I never expected that I would see blurry in one eye Plans for next Month More engagement on TwitterFinish remaining wireframesDesign the project page in Figma Special thanks to foliofed He gave me the IH invite code amp help me with some questions marmooznet Got the inspiration for the profile picture from him amp he reviewed this article tbll Gave me feedback for this article MeetKevon He tweets about great stuff learned much from him I am so glad you stayed with me all the way to here I would love to hear your feedback on my first monthly article Check out my Twitter to see weekly work updates 2022-02-04 20:29:29
海外TECH DEV Community How To Build Simple CRUD RESTful API With NodeJS, ExpressJS And MongoDB in 2022 https://dev.to/nerdjfpb/how-to-build-simple-crud-restful-api-with-nodejs-expressjs-and-mongodb-in-2022-4756 How To Build Simple CRUD RESTful API With NodeJS ExpressJS And MongoDB in IntroductionNode js is a popular backend nowadays It s fast and easy to write code If you already know javascript it can be easy to write node js So we re going to explore express js today with MongoDB for the database We ll create the rest API endpoints and implement CRUD operation for the to do list The example is quite basic but we re going to make a good project structure so that you can follow it for your other projects too Let s dive in Things I m usingVscode I ve used the vscode for the whole development Node js I ve used node js v MongoDB compass I ve used MongoDB v to see all changes in MongoDB graphicallyPostman We ll use this one to test all our api sPackages babel For transpile the javascript into an older versioncors For the CORS settingdotenv For reading the environment variableseslint For enforcing a coding styleexpress js The node frameworkexpress rate limit For limiting the API endpoint callshusky For git pre commit to hook for implementing eslint amp prettier before committingjoi Used to validate the user inputsmongoose MongoDB ORM for working with MongoDBmorgan For showing API endpoint detailsnodemon For running the server when we change a fileprettier For formatting the code Project Setup Basic Project SetupWe ll start with npm init y on the folder to initialize the node and create the package json file You can edit the package json file as you want Now create an src folder to write all our code in the folder We ll also make an index js file as a starter Setup the Express JS with babelIf we usually set up the nodejs with npm init y then we can t use the latest features of javascript To solve this problem we are going to use babel Babel is a compiler for javascript it complies with the new versions of javascript to older javascript If we active babel we can use async await which will transfer into earlier javascript To set up the babel we need to install npm i babel cli babel core babel node babel preset env Dand also we need to add a file called babelrc presets babel preset env We need to adjust the package json file to work correctly start node dist index js dev nodemon exec babel node src index js build babel src d dist This will complete the babel set up and you can run it by using npm run dev if you want a production version then use npm run build first and then try npm start that will start the application Improving coding styles amp formattingThis part is only needed if you are interested in maintaining good structure and rules throughout the codebase This will require the eslint and prettier Eslint will enforce a coding style so every developer follows specific rules Prettier will follow the code format automatically Eslint comes with vscode So you don t need to install eslint on your vscode But you need to install the prettier on your codebase because it is necessary for code styles So how to install them Let s do it together by installing npm install eslint eslint config prettier prettier DLet s set up the prettier first which is pretty straightforward We ve to create a file called prettierrc and we need to put trailingComma es tabWidth semi false singleQuote true This is all needed for the prettier now let s set up the Eslint For Eslint setup starts with node modules bin eslint initIt will pop up some questions Now select the one based on your interest For this project we chooseTo check syntax find problems and enforce code styleCommonJS require exports None of theseNoNodeUse a popular style guideJSONYesNow it ll install some new packages and create eslintrc json file Now we have to edit a little bit here extends airbnb base prettier We ll add the prettier here and we are pretty done If your vscode has all the extensions already if you write any wrong code then you ll see the errors If someone doesn t want to use the vscode extensions they can check the error by running npm run lint But it ll fail because we didn t add any script like this So go to the package json file and add lint eslint fix Improving git experience with huskyOur codebase has some rules and formatting ways But still it s not going to happen if someone doesn t have those extensions or doesn t care about the errors Also many devs work from different IDE you can t force them to use the same one So we will play with the git hook a little bit to solve the problem So whenever anyone tries to commit we will check the eslint and then we will format the file with prettier So how to do it We can do it using husky amp lint staged and we will work on that right now Let s install husky and lint stagednpm i husky lint staged DWe need to improve the package json file Add some extra lines on the last part lint staged js jsx npm run lint prettier write Now we need to enable the git hook npx husky installlet s add a git hook which is going to help us to do the lint staged before committing the changesnpx husky add husky pre commit npm test Now you ll see a husky folder on the root level with a file inside pre commit and let s modify it a little bit bin sh dirname husky sh npm testnpx lint stagedNow it ll work like magic Try to commit your changes and see it s doing something before committing and this way you can easily enforce something before committing Improving securityNow our server is quite ready Let s jump into the index js file to start our work But before that let s improve the security a little bit We will use environment variables because we re not going to expose it directly out on our repo For this we will use the dotenv npm package It s super easy import dotenv config The upper line will give us the power to access any value from the env file from root Check env example to get an idea of what I ve inside the env file It s your credential secret data so never upload it to the public git repo To access any variable use process env VARIBALE NAMENow let s do some basic stuff import Express from express const app Express const port process env PORT app listen port gt console log listening on port port Now let s add some middlewares here The first one will be cors because it enables you to do the CORS settings Also add helmet middleware It helps you secure your Express apps by setting various HTTP headers The code will look likeimport Cors from cors import Helmet from helmet app use Cors app use Helmet As we are building the API there can be some DDoS attack or potential hacker attack or maybe something is broken and it keeps calling the API like thousand times in a min We don t want that So let s add a limit import RateLimit from express rate limit const limiter RateLimit windowMs max standardHeaders true legacyHeaders false app use limiter Are we done Sadly no We are going to make a slight improvement on the server We ll check details on every API call in our console log so we re going to add a logging package called morganimport Morgan from morgan app use Morgan tiny The upper two lines will help us see the API endpoints details on our console Finally for the JSON inputs from user add the last middleware app use Express json It parses incoming requests with JSON payloads and is based on body parser Connect to MongoDBConnecting to MongoDB is pretty straightforward First we are going to install the mongoose package Because it s better than just using MongoDB it s an ORM and comes with lots of benefits already So how to connect a DB with it import Mongoose from mongoose Mongoose connect mongodb localhost demotodo then gt console log Connected to MongoDB catch err gt console log Could not connect to MongoDB err See this is so easy right Now let s start writing the API endpoints Let s create a post API endpoint first so that we can add some values inside the database demotodo REST API endpointsWe re going to create five endpoints Let s look at the URLs first app v gt Post gt add a data to database api v gt Get gt get all the data from database app v id gt Get gt get a single item data by id from database app v gt Delete gt delete a data from database app v gt Put gt update a data from databaseWe ll start with the POST method But before that let s make our code a little better We ll create a folder called routes and model In the model folder we ll put the MongoDB database model In the routes folder we ll post different routes You can also create a controller folder to write the controller called from routes But for simplicity I ll go with one single file in routes amp model Let s create a todo js file in the model amp route both folders Now lets a go to model first to create the model We ll call the mongoose package and make the data structure here We re going simple We ll create a title text amp completed bool for the schema and when we add data from here it ll always add a unique id by mongo Let s do this import Mongoose from mongoose const todoSchema new Mongoose Schema title type String required true trim true minlength maxlength completed type Boolean default false export default TodoModelUpper lines will create the model But we also need to do validation when someone sends us data We ll put the validation function here because it ll be closer and easier to maintain Let s add the joi package to write the validation function import Joi from joi const TodoModel Mongoose model Todo todoSchema const JoiSchema Joi object title Joi string min max required completed Joi boolean export const validateTodo todo gt JoiSchema validate todo We ll use this both export from our routes file Let s do the POST method right now POSTAs a starter of routes todo js we ll call the libraries and model with validations import express from express import Mongoose from mongoose import Todo validateTodo from model todo Now write the router const router express Router It s time to write the post route to add data from the postman We ll follow some steps to write this part of the code is there an error with the validate function from the model todo js file If error then send a response with an errorIf there is no error then create data using the mongoose modelSave it amp send a reply to the user insert a new data in todorouter post async req res gt validate using Joi with factoring function const error validateTodo req body if have any error then return bad request with error else just add the new one if error return res status json success false data message error details message let todo new Todo title req body title completed false todo await todo save return res json success true data todo message New todo adding successful Now let s test it from the postman Start the app with npm run dev and go to URL localhost api v GETLet s find out the steps we need to get all the data from mongodbFind out all the data using find Send as response Get request for getting all todo datarouter get async req res gt sending all data to response const todos await Todo find return res json success true data todos message Request successful It s pretty easy Right Start the app with npm run dev and go to URL localhost api v GET A SINGLELet s find out the steps we need to get a single data from mongodbCheck if the given id is a mongodb valid id If not send a error response to userOtherwise try to get the data using findById givenID Send response based on the data we got Get the data about a single todorouter get id async req res gt if Mongoose Types ObjectId isValid req params id return res status json success false data message It is not a valid mongodb id search using id In mongodb with mongoose const todo await Todo findById req params id checking if todo not found then request if todo return res status json res json success false data message There is no data found related to this id if found then send the response return res json success true data todo message Finding successful It s pretty easy Right Start the app with npm run dev and go to URL localhost api v id PUTLet s find out the steps we need to update the data in MongoDBFirst validate the data user is sending to API if there is inaccurate data just send an error response to the user Otherwise try to update data by finding id first Use findByIdAnUpdate method to do it with giving the new dataIf there is data then it ll be blank and the response will error otherwise send the success response update an existing todorouter put id async req res gt Validating the user input const error validateTodo req body if error return res status json success false data message error details message find Id and updated it by mongoose const todo await Todo findByIdAndUpdate req params id title req body title completed req body completed new true if todo is not available then error or else new updated data send to user if todo return res status json success false data message There is no data found related to this id return res json success true data todo message Update successful It s pretty easy Right Start the app with npm run dev and go to URL localhost api v id DELETELet s find out the steps we need to delete data from MongoDBWe ll try to delete once we get the id by findByIdAndRemove Send response based on the result delete a todorouter delete id async req res gt find an delete the data using moongoose amp mongodb const deletedTodo await Todo findByIdAndRemove req params id checking if todo not found then request amp if found then send the response if deletedTodo return res status json success false data message There is no data found related to this id finally response send with deleted data return res json success true data deletedTodo message Delete successful It s pretty easy Right Start the app with npm run dev and go to URL localhost api v id Let s try to delete the same id again Let s see what happens Final wordsI ve tried to explain everything as I think But there is a lot of improvement we can make I didn t add a try catch block because this blog will be long after that But you should add that If you want to see the code Please check out I ve started a programming community on discord Click to join Discord ChannelOriginally it published on nerdjfpbblog You can connect with me in twitter or linkedin or instagram 2022-02-04 20:08:06
海外TECH DEV Community A Beginner's Guide to HTTP - Part 1: Definitions https://dev.to/abbeyperini/a-beginners-guide-to-http-part-1-definitions-38m7 A Beginner x s Guide to HTTP Part DefinitionsAs a web developer I sometimes describe my job as making things talk to each other over the internet HTTP which stands for Hypertext Transfer Protocol makes this possible In other words HTTP is a method of sending messages from one program to another using the internet In this article I ll cover HTTP terms tools and the structure of HTTP messages I use analogies and metaphors and explain things in multiple ways to try and provide helpful mental models I m currently working on A Beginner s Guide to HTTP Part an App and a Server in which I ll dig into how to write the code to generate HTTP messages After that in A Beginner s Guide to HTTP Part APIs we ll have a little fun with our app and some free to use APIs that other people have built for us Introduction and Table of ContentsThis article assumes familiarity with basic JavaScript I briefly explain asynchronous JavaScript and basic web development concepts and provide more learning resources at the end of the article I will not be explaining TCP the many definitions of the word protocol or how the internet works This is a general overview and guide to using HTTP messages in your web application Web Development TermsHTTP Terms Asynchronous JavaScript and HTTP ToolsStructure of a RequestMethodsRequest HeadersRequest BodyStructure of a ResponseStatus Codes and MessagesCORSMore Resources Web Development TermsFirst let s define a few terms I will be using a lot An application or application program is software that runs on a computer The basic set up of most web applications is a client application that runs in a browser like Chrome Firefox or Safari and a server application that provides services and resources for the client In this way the browser is functioning as a runtime environment for client or client side code In JavaScript the most common runtime environment used for server or server side code is Node js Put another way the client is the part of the code that the user interacts with clicking buttons or reading information on a page in their browser To get the information the user wants to read or to get or update information after a user clicks something my client will talk to my server using HTTP I often use app to refer to my client because not every web application needs a server It is possible to have a web app with only a client like a calculator that can perform all of its math without getting any more information from another resource It is possible to only build a client and use server side resources built by other people You may have seen the term serverless which refers to ways to create server like services and resources without building a server yourself In reality serverless apps involve building a client and then using tools like AWS or Netlify to write server side code inside the client When needed your client will then use the tool to execute the server side code on a server built and hosted by other people For the purpose of learning HTTP in this guide we will be focusing on the classic client server model I described above I won t be using front end and back end because client and server are more specific For example the back end of a web app would include not only a server but also a database and any other services and tools used by the server API stands for Application Programming Interface It allows two applications like a client and a server to talk to each other If the server is the whole restaurant the API is the waiter the menu is the list of methods the API provides and the hungry customer is the client I ll cover standardized formats for APIs and more in part A library is a package collection module of files and functions that a developer can use in the program they re writing Because API is a broad term and APIs aren t only used for the client server model the methods provided by a library for the developer to use can also be referred to as an API HTTP Terms Asynchronous JavaScript and HTTP ToolsThere are different versions of HTTP HTTP is more optimized and secure than HTTP and about half of websites use it There s even an HTTP developed by Google You may already be familiar with seeing http and https in your URLs and browser warnings about security HTTP messages are encrypted when sent using HTTPS and are not encrypted when sent using HTTP There are several libraries you can use to send HTTP messages For example curl can be used from the command line They all use HTTP so the information they need is the same What differs is where you can use them the syntax to create HTTP messages the options they provide and the protocol they use e g HTTP vs HTTPS HTTP vs HTTP More robust libraries will do extra things When looking at JavaScript HTTP libraries you may come across the term AJAX or Ajax It stands for Asynchronous JavaScript and XML Put very simply asynchronous code runs out of order Sending a message over the internet and getting a message back takes time Asynchronous code can essentially pause execution until the data is received and then pick up where it left off XML stands for Extensible Markup Language It s like HTML but without predefined tags It is one format used to structure data you might send within an HTTP message Ajax can refer to using HTTP with JavaScript even if the message doesn t contain data or the data is not structured with XML When you write JavaScript and it is running in a browser you have access to a lot of built in tools It s hard to imagine building a website without Web APIs like the HTML DOM and URLs For a long time the only HTTP Web API available was XMLHttpRequest or XHR Because it was an Ajax library it finally allowed web pages to pull data from a database without having to refresh the whole page The more modern version supported by all browsers except IE is Fetch Support for Fetch was just included in the latest version of Node js in January It builds on XHR by providing interfaces expected formats for both halves of the HTTP conversation and where XHR uses Callbacks Fetch uses Promises Callbacks and Promises are pretty big topics Essentially a Callback function is passed as an argument to an asynchronous async function After the async function gets what it needs then the Callback function is executed Promises on the other hand are objects returned by async functions They have three states pending fulfilled and rejected Async functions that return Promises can be chained with then and catch This way the developer can pass the returned fulfilled Promise to a function in then or pass the returned rejected Promise to catch and handle the error Javascript also has async await syntax that uses Promises without having to explicitly create Promise objects or pass them to a chain You can still chain them if you want though Other functions can call await asyncFunction and wait for the result before continuing execution Often the result of the function call is set to a variable to be used later I ll have code examples in part and more resources for learning about these topics at the end of this article Finally there are packages like Axios Not only does Axios provide interfaces and use Promises but it also allows the developer to make both client side HTTP requests in the browser using XHR and server side HTTP requests in Node js It also provides more options and formats your messages for you Before we get into how to write the code that sends the HTTP messages across the internet in part let s dive into how the messages themselves are structured Structure of a RequestIf we say a client and a server are having a conversation the two halves of the conversation are a request and a response Using an HTTP request a client is requesting something from a server Every request requires some information to work Method The method tells the server what the client wants it to do URL The URL tells the HTTP tool where to send the request Protocol Set by the HTTP tool used Headers Headers give the server more information about the request itself The URL in the HTTP request message works just like when you type in a URL to go to a webpage in your browser The URL can also be used to send additional information I ll explain more about URLs and how to use them in part There is also an optional part Body If a request uses a method that sends data to the server the data is included in the body right after the headers So an HTTP request message would look something like this The first line shown here in red has the method URL and protocol The second yellow portion has all the headers There s a blank line and then if there s a body it goes at the end shown here in blue MethodsThe easiest way to explain methods is to map them to the persistent storage acronym CRUD CRUD stands for Create Read Update and Delete You can think about it in terms of database that uses SQL Create INSERTRead SELECTUpdate UPDATEDelete DELETEYou can think about it in terms of an app s UI Create users making a new postRead users looking at their newsfeedUpdate users editing a postDelete users deleting a postFor HTTP requests Create POSTRead GETUpdate PUT or PATCHDelete DELETENote There are more methods I didn t cover because I have yet to use them POST sends data to the server and results in a change It requires a body GET requests data from the server be sent back via response It does not have a body PUT sends data to the server to create a new resource or replace an existing resource It requires a body PATCH sends data to the server to update part of an existing resource It requires a body DELETE requests a resource be deleted It may have a body if the information required to identify the resource to be deleted is not contained in the URL Request HeadersThere are a lot of HTTP request headers If the server is a concert and the HTTP request is an attendee the headers are like the attendee s ticket and ID An Origin header would tell the server where the request came from An Accept header would tell the server what kind of format the server should use for its response A Content Type header tells the server what kind of format the request body is using Some of them are automatically made by the HTTP library Some like Authentication headers are dictated by the server I ll cover Authentication in part when I request data from an API that requires a key Many headers you ll find on both the request and the response If the HTTP specification refers to a header as a request header it only gives information about the context of a request Developers will refer to headers included in a request as request headers in conversation even if they could also be used as a response header and vice versa Request BodyHTTP message bodies can be packaged in several standardized data transfer formats The formats are referred to as media types or MIME types and there are many of them XML and JSON are the two you are going to see most often They both create single resource bodies which means they are one file in the HTTP message body JSON stands for JavaScript Object Notation It has a standard syntax that creates smaller files JavaScript built in methods easily turn the JSON string into valid JavaScript objects JSON can only be encoded in UTF and has types XML is typeless can keep the original data s structure supports multiple types of encoding is more secure and can be displayed in a browser without any changes XML requires work to parse into JavaScript and is more difficult for humans to read but easier for machines to read XML vs JSON how JSON came to be the most widely used HTTP data transfer format and what other formats still exist is a huge topic Twobithistory s synopsis will start you down the rabbit hole I ll be using JSON and covering its syntax and the built in JavaScript methods in part The MIME type and character encoding used in a request body are declared in the Content Type request header so the server knows how to decode and handle the data in the body of the request XML content would have application xml in the header JSON content would have application json The best example of a multiple resource body is data sent from an HTML form on a webpage It would have multipart form data in the Content Type header Instead of one body there are multiple bodies one for each part of the form each with its own Content Type header Thus data the user entered can be sent to the server along with the properties of the HTML element they used to enter it As a result if you have an lt input gt with a property like name first name the request body will include name first name with the name the user typed into the lt input gt Structure of a ResponseAfter a client sends an HTTP request the server sends back an HTTP response Every response sends back some information Protocol Set by the HTTP tool being used Status Code A set of numbers that will tell you how the process from request to response went Status Message A human readable description that will tell you how the process from request to response went Headers Gives the client more information about the response itself There is also an optional part Body If the response contains data from the server it will be included here Request and response bodies use the same formats So an HTTP response message would look something like this The first line shown here in red has the protocol status code and status message Next the yellow section has the headers The headers are followed by a single blank line Finally if there is data to send back there is a body shown here in blue Status Codes and MessagesYou ve encountered status codes before while using the internet Everyone s seen Not Found and you may have seen Forbidden The one you ll be hoping for when writing HTTP requests is a successful OK The ones you don t want to see when writing client side code are in the s like Bad Request and Method Not Allowed Problems with the server will be in the s like Internal Service Error or Service Unavailable Technically these are standardized The problem is people are writing what response to send back and they can choose whatever status code and message they want Ideally responses from a resource you didn t build will use the standardized codes and messages You ll often find you have to read the documentation or interact with the resource to find out how to handle their response format If you d prefer to learn your status codes and messages accompanied by animal pictures check out HTTP Cats and HTTP Status Dogs CORSSince the majority but not all of the CORS headers are request headers let s dive into CORS here CORS stands for Cross Origin Resource Sharing By default browsers and servers running JavaScript use CORS to block requests from a client with a different origin than the server for security The goal of CORS is to protect the client and server from executing malicious code contained in an HTTP request and to prevent data being stolen from the server For most browsers origin refers to the host the protocol and the port if the port is specified The host is the part of the URL after www and before a So for www google com the host is google com The protocol is HTTP vs HTTPS and HTTP vs HTTP The port would be in http localhost Before your original request is sent HTTP will send a preflight request with some headers like the origin and the method to check if the request you want to make is safe The server then sends back a preflight response with CORS headers like Access Control Allow Origin and Access Control Allow Methods that tell the browser whether the original request is allowed This is when a request will be blocked by CORS if it s going to be You can only dictate if a server allows CORS requests if you are writing the server code For example a server s response will include the Access Control Allow Origin header to list the origins that can receive the request If your origin isn t in the list in the Access Control Allow Origin header in the response your request will be blocked and you can t change that unless you are writing the code that sends the responses If a server relaxes CORS restrictions they will typically replace it with required authentication or use the Access Control Allow Methods header to restrict request methods to GET only Authentication can be sent in the headers or the URL more on that in part However even if the server allows CORS requests your browser will block a CORS request in your client side code You can get around this by requesting data from the server using your own server and then passing what you needed from the response to your client More ResourcesIf you re just dipping your toe into asynchronous Javascript I highly recommend dropping everything and watching two videos right now Philip Roberts What the heck is the event loop anyway and Jake Archibald s In The Loop Callbacks and Promises are difficult concepts and I explained them very quickly I only truly understood them after writing code with them every day for months It is in your best interests to learn about Callbacks before moving on to Promises as Promise objects and chaining provide their own challenges Here are a few more resources that should help you wrap your mind around them ConclusionThat was a lot of definitions before we get to any code HTTP messages are complex but they re also the bread and butter of web applications If you are left confused or wanting more resources about a topic I touched on don t hesitate to leave a comment below Coming soon A Beginner s Guide to HTTP Part an App and a ServerA Beginner s Guide to HTTP Part APIs 2022-02-04 20:05:53
海外TECH DEV Community Type Annotations and Inference in Typescript https://dev.to/hima_khaitan/type-annotations-and-inference-in-typescript-5f21 Type Annotations and Inference in Typescript Let s first see what Types are in Typescript Types are the easy way to refer the different properties and functions available to a value in the Typescript Code For eg A vehicle of type Bike had certain properties such as two wheels whereas a vehicle of type Car has four wheels in general Type AnnotationsIt is the code we add to the Typescript to make the compiler aware of the type of values variable will refer to let age number let name string Himanshu let isAdult boolean true In the example above we explicitly tell the typescript compiler that the variable age will be of type number name will be of type string and isAdult would be of type boolean Type Annotations for Variableslet likes number let title string Type Annotations and Inference let isPublished boolean true In the above case we as a developer have explicitly told the types of TypeScript Compiler It s not recommended to do this as Type Inference is capable to infer they types of variables which are declared and intialized in same expression Type Annotations for Arrayslet skills string DSA Graphic Design Web Dev Here we let TypeScript Compiler know that skills will be an Array consisting of strings Type Annotations for Functionsconst add a number b number string gt return a b For the function add we have defined a and b as parameters of type number and the return type as string Syntax is a bit confusing but easy to get hands on it Custom Type Annotationsinterface Book name string copies number publishedOn Date let book Book name Do or Die copies publishedOn Date now let author name string likes number author name Naval likes In the above written snippet there are two cases gt Using InterfaceIn this we defined a custom data type Book which has name publishedOn and copies as it s properties and assigned it to book variable gt Inline DefinitionIn this we defined the type of variable author inline using the syntax shown above Both of the methods can be used to define the custom types depending on the used cases Multiple typesIn some of the used cases we are not sure of the type of variable or we can have a variable which may contain two types of values let variableOne any let variableTwo number string In case of variableOne we are not sure of it s type so we assigned the type any to it Defining type any is not preferred as TypeScript will infer it if not explicitly told In case of variableTwo it can contain values which are either string or number so we used the operator to explicitly tell the TypeScript Compiler Type InferenceType Inference happens when TypeScript tries to infer what type of values a variable refers to In the above example TypeScript Compiler infers that num will be of type number Type Inference in FunctionsTypeScript is only capable of inferring the return type of a function Parameters need to be annotated by the developer const add a number b number gt return a b In the above example TypeScript will infer the return type of function as number based on the type of parameters used and operations performed When to use Type AnnotationsFixing type anyWhere Inference doesn t workDelayed InitializationNote Whenever TypeScript can t infer the type of a variable or a function it simply declares its type to be any Thanks for reading the Blog Hope you found it Helpful himakhaitan himakhaitan Happily Turning Coffee into Code The repository is a quick overview of my current skills and commits I write code build communities and love to interact with people around             An avid and passionate coder specializing in different languages I love to build and design websites which the end user would enjoy using while keeping the website performant and the code clean Up for freelance web development work social media managment and collaborating on exciting Open Source amp Personal projects Currently I am learning advanced concepts of Typescript and getting hands dirty in Competitive Programming Stuff I Know                                              Profile Visits Happily turning coffee into code View on GitHubMy self Himanshu Khaitan a Freelance Web Developer You can connect with me here You can follow me on Twitter or connect with me on LinkedIn You can ping me for help on my Discord Server here 2022-02-04 20:04:46
Apple AppleInsider - Frontpage News Apple targeting date near March 8 for iPhone SE, iPad Air spring keynote https://appleinsider.com/articles/22/02/04/apple-targeting-date-near-march-8-for-iphone-se-ipad-air-spring-keynote?utm_medium=rss Apple targeting date near March for iPhone SE iPad Air spring keynoteApple is reportedly considering a date on or near March to hold a spring event for a new iPhone SE an updated iPad and potentially a new Mac Tim Cook at Apple ParkThe potential spring event date is not set in stone but sources told Bloomberg that Apple is targeting a day around March for its next virtual event Read more 2022-02-04 20:13:15
海外TECH Engadget Traders are selling themselves their own NFTs to drive up prices https://www.engadget.com/nft-wash-trading-scams-chainanalysis-report-202537095.html?src=rss Traders are selling themselves their own NFTs to drive up pricesThe NFT marketplace is rife with people buying their own NFTs in order to drive up prices according to a report released this week by blockchain data firm Chainalysis Known as “wash trading the act of buying and selling a security in order to fool the market was once commonplace on Wall Street and has been illegal for nearly a century But the vast unregulated NFT marketplace has shown to be a golden opportunity for scammers The report tracked instances of the same traders selling the same NFTs back and forth at least times a likely incident of wash trading It identified a group of alleged NFT wash traders who have made roughly million in profit from this practice Researchers also discovered significant evidence of money laundering in the NFT marketplace in the last half of The value sent to NFT marketplaces by addresses associated with scams spiked significantly in the third quarter of worth more than million worth of cryptocurrency according to the report Roughly million dollars of sales in the fourth quarter of came from such illicit addresses “NFT wash trading exists in a murky legal area While wash trading is prohibited in conventional securities and futures wash trading involving NFTs has yet to be the subject of an enforcement action wrote the authors of the report NFTs or non fungible tokens are a new asset class of digital tokens that exist on the blockchain and are primarily purchased with Ethereum a form of cryptocurrency The crypto collectibles can consist of anything from a two dimensional image to a GIF to a song The NFT marketplace is estimated to be worth anywhere from billion to billion The digital assets skyrocketed in popularity in and have been embraced by celebrities like Mark Cuban Tom Brady and Reese Witherspoon Skeptics have questioned the legitimacy and necessity of NFTs as the still relatively new space has spiked in popularity High profile NFT sales such as last year s record breaking million purchase of the artist Beeple s collection have been increasingly frequent But since the digital tokens are not a security they re not subject to the same US laws and regulations governing stocks for example Numerous scams have cropped up in the NFT space in recent months including counterfeit NFTs and money laundering 2022-02-04 20:28:06
ニュース BBC News - Home Jacob Rees-Mogg urged to correct morning after pill remark https://www.bbc.co.uk/news/uk-politics-60267025?at_medium=RSS&at_campaign=KARANGA clinical 2022-02-04 20:12:58
ビジネス ダイヤモンド・オンライン - 新着記事 東証プライム猶予296社の「9割は上場廃止」!?市場のプロが未来を一刀両断【覆面座談会・後編】 - 東証再編が誘発!上場廃止ラッシュ https://diamond.jp/articles/-/294497 一刀両断 2022-02-05 05:25:00
ビジネス ダイヤモンド・オンライン - 新着記事 「祇園精舎」ってどこ?意外と知らない『平家物語』を解説 - 新説・新発見!今こそ学ぶ「歴史・地理」 https://diamond.jp/articles/-/295205 平家物語 2022-02-05 05:20:00
ビジネス ダイヤモンド・オンライン - 新着記事 一流経営者の「去り際」の習慣、なぜ一瞬でまた会いたいと思わせるのか - DOL特別レポート https://diamond.jp/articles/-/295208 2022-02-05 05:15:00
ビジネス ダイヤモンド・オンライン - 新着記事 「東証再編はとことん骨抜きにされた」市場のプロが嘆くお粗末な実態【覆面座談会・前編】 - 東証再編が誘発!上場廃止ラッシュ https://diamond.jp/articles/-/294496 上場廃止 2022-02-05 05:10:00
ビジネス ダイヤモンド・オンライン - 新着記事 花王の値上げにオーケーが「売り場追放」で対抗、インフレでメーカーvs小売りの攻防激化 - Diamond Premium News https://diamond.jp/articles/-/295473 diamondpremiumnews 2022-02-05 05:07:00
ビジネス ダイヤモンド・オンライン - 新着記事 優れた顧問やアドバイザーと巡り会うために必要な「3つの力」 - 小宮一慶の週末経営塾 https://diamond.jp/articles/-/295385 小宮一慶 2022-02-05 05:05:00
ビジネス ダイヤモンド・オンライン - 新着記事 ユーロ圏にも忍び寄る利上げの足音、利回り上昇に弾み - WSJ発 https://diamond.jp/articles/-/295496 足音 2022-02-05 05:02:00
ビジネス ダイヤモンド・オンライン - 新着記事 石原慎太郎氏の経済政策を回顧、ディーゼル規制・リニア等で賛否も成否も分かれる - DOL特別レポート https://diamond.jp/articles/-/295471 差別発言 2022-02-05 05:02:00
北海道 北海道新聞 入植者暴力に植樹で抗議 パレスチナ、兵士の妨害も https://www.hokkaido-np.co.jp/article/642146/ 西岸 2022-02-05 05:12:00
北海道 北海道新聞 <社説>並行在来線廃止 新幹線だけでいいのか https://www.hokkaido-np.co.jp/article/642105/ 並行在来線 2022-02-05 05:05:00
ビジネス 東洋経済オンライン テレ朝「ローカル局再編」の規制緩和を求めた真意 費用軽減でネットワーク維持狙うも課題は山積 | メディア業界 | 東洋経済オンライン https://toyokeizai.net/articles/-/508055?utm_source=rss&utm_medium=http&utm_campaign=link_back 東洋経済オンライン 2022-02-05 05:40:00
ビジネス 東洋経済オンライン 全米を席巻!「日本のお菓子サブスク」成功の秘訣 K-POPが巻き起こしたアジア人気の波に乗る | 食品 | 東洋経済オンライン https://toyokeizai.net/articles/-/508673?utm_source=rss&utm_medium=http&utm_campaign=link_back 定期購入 2022-02-05 05:20:00

コメント

このブログの人気の投稿

投稿時間:2021-06-17 05:05:34 RSSフィード2021-06-17 05:00 分まとめ(1274件)

投稿時間:2021-06-20 02:06:12 RSSフィード2021-06-20 02:00 分まとめ(3871件)

投稿時間:2020-12-01 09:41:49 RSSフィード2020-12-01 09:00 分まとめ(69件)