投稿時間:2022-02-18 01:33:21 RSSフィード2022-02-18 01:00 分まとめ(38件)

カテゴリー等 サイト名等 記事タイトル・トレンドワード等 リンクURL 頻出ワード・要約等/検索ボリューム 登録日
AWS AWS Government, Education, and Nonprofits Blog Brazilian Space Agency and AWS sign Statement of Strategic Intent to support long-term growth in regional space sector https://aws.amazon.com/blogs/publicsector/brazilian-space-agency-and-aws-sign-statement-of-strategic-intent-to-support-long-term-growth-in-regional-space-sector/ Brazilian Space Agency and AWS sign Statement of Strategic Intent to support long term growth in regional space sectorThe Brazilian Space Agency and Amazon Web Services AWS signed a Statement of Strategic Intent and Cooperation The initiative on which the Brazilian Embassy in Washington also collaborated is the first of its kind for AWS in Latin America and will support innovation and the continued growth of the country s space industry 2022-02-17 15:00:51
python Pythonタグが付けられた新着投稿 - Qiita レコメンド指標でよく見るMAP@kとは https://qiita.com/tetsuro731/items/718bef2a667e0994eddd sumkKPkMAPkさて、全部でN個のデータがあるとする上で計算したPやAPはそのうち一個のデータと考えることができるこれをN個のデータで平均してあげたのがMAPkになるfracNsumiNfracminmiKsumkKPikこの数式を見るとminmkで割っている箇所はなんだと思うだろう上記の例だとkとしていたが、kの数をどんどん増やしていけばMAPの値はどんどん大きくなってしまうなので、この効果を抑えるためにminmkで割っているここでmは正解の個数なぜminなのか例えばmだとする。 2022-02-18 00:06:05
python Pythonタグが付けられた新着投稿 - Qiita MLflow Projects と Tracking を同時に使う https://qiita.com/pn11/items/1a0dd09c96132c4d2591 tldrmlflowrunで起動したrunIDをTrackingでも使用するようにします。 2022-02-18 00:02:54
python Pythonタグが付けられた新着投稿 - Qiita 「新・明解Pythonで学ぶアルゴリズムとデータ構造」で勉強日記#11 https://qiita.com/kato_squalldeka/items/6c3b8f5c67f459318673 ノードはデータと後続のデータを示すポインタで構成できます。 2022-02-18 00:02:18
js JavaScriptタグが付けられた新着投稿 - Qiita react hook formで快適フォーム実装 https://qiita.com/takahashi-mcd/items/7e953cbd4677e15ec511 reacthookformで快適フォーム実装Reactでのフォーム実装にはreacthookformが便利でしたルールに合わない場合のreturn処理やエラーメッセージを表示するなどの処理が簡潔に書けるuseStateの量が減るのでコードがスッキリするなどなど、メリットがたくさんですインストールnpminstallreacthookformoryarnaddreacthookform実装inputの入力内容をalertで表示させる機能を実装します。 2022-02-18 00:07:15
Linux CentOSタグが付けられた新着投稿 - Qiita AlmaLinux8(CentOS)でZabbix6.0LTSを試してみる https://qiita.com/dashi_no_moto/items/8966e20ec4c2dd4c694b osdistributioncentosamposversionampdbmysqlampwsapacheただ、オンプレで実施していることもありDB周りのインストールも必要となるので、インストール完了しWebのUIが利用可能になるところまでの一連の手順を記載する。 2022-02-18 00:01:14
海外TECH MakeUseOf The 7 Best Free Marvel Games for Your Smartphone https://www.makeuseof.com/best-free-marvel-games-for-your-smartphone/ marvel 2022-02-17 15:45:12
海外TECH MakeUseOf The 4 Best Logo Design Courses https://www.makeuseof.com/best-logo-design-courses/ necessary 2022-02-17 15:30:12
海外TECH MakeUseOf How to Organize Your Password Manager in 7 Steps https://www.makeuseof.com/tag/organize-password-manager/ manager 2022-02-17 15:16:14
海外TECH MakeUseOf 5 Ways to Fix Your Backlit Keyboard When It’s Not Working on Windows https://www.makeuseof.com/windows-fix-backlit-keyboard/ Ways to Fix Your Backlit Keyboard When It s Not Working on WindowsThe whole point of backlit keyboards is their illuminated keys so what should you do when they go away on a Windows machine Here are some fixes 2022-02-17 15:16:13
海外TECH DEV Community Privacy friendly website analytics with Umami and NextJS https://dev.to/anishde12020/privacy-friendly-website-analytics-with-umami-and-nextjs-13lo Privacy friendly website analytics with Umami and NextJSWebsite analytics is truly a very important thing We can understand our audience well and can tailor our content to our audience for higher engagement Google Analytics had always been the go to solution as it is popular easy to set up and gives a lot of data However Google Analytics has got its own set of issues One must ask for a cookie consent to use Google Analytics as Google Analytics uses cookies The Google Analytics script is also quite big and is known to slow down websites There have been recent allegations against Google Analytics for not being privacy friendly and many European authorities have also found it breaching GDPR So what is the solution Over the years many privacy friendly analytics solutions have emerged including Fathom Analytics Plausible Analytics and Umami Analytics The last are open source and all of them are cookie less and have a lightweight script that should not affect website load times We are going to be focusing on Umami in this article A little bit about UmamiUmami is an open source self hosted analytics service This means the source code can be accessed by anyone and one must host it themselves Now you might say that this costs money and it is not free but today we are going to look at how we can host it for free Also Umami uses NextJS API routes for the backend and hence it can run on any serverless architecture We are going to be looking at setting it up on Railway today however it can also be hosted on Vercel or Netlify We are also going to look at adding analytics to a NextJS application You can see a live demo of the platform hereFun fact Hashnode also uses Umami and is rolling out an Umami dashboard as advanced analytics You can see the public analytics for my blog here Hosting Umami for free on RailwayRailway is an awesome hosting platform that lets you host applications quickly and easily The free plan allows usage of up to month which should be good enough for a few small to medium sized websites In fact I have been using it for the past months and it has been an amazing experience My usage costs are usually lower than month and hence I have never paid anything You don t even need to link your credit card My usage this month websites You can also link a credit card to get of usage per month for free you will be charged for anything above that You can sign up here Setting up the project on RailwayWe are going to follow the official guide on hosting it on RailwayFirst of all we must fork the repository This will help us make changes to the source code to fit our own needs and more importantly receive updates in the future as we will see later in the tutorial Head over to the Umami GitHub repository and click on fork on the top right corner You may be asked to select your personal account or an organization if you are in any I would recommend going for personal account unless it is for an organization Once you have signed up for an account click on New Project note that I already have an existing project and hence the layout looks like this It may be different for you Now select Deploy from Repo on the new project screen Do note that if you didn t sign up with GitHub you will be prompted to connect your GitHub account Search and select Umami there Make sure that the master branch has been selected Now click on deploy This might take some time minutes This is how it should look like after deploying do note that I am currently using the Metro UI and the layout might look a little different Now we need to add a database We are going to be using PostgreSQL for this example Now Railway has built in support for databases and hence we can spin up a PostgreSQL instance within Railway itself for free Click on this New button Select Databases and then select PostgreSQL This might take some time as well Do note that if you are using the old UI you have to select the Add Plugin button Now we need to add two environment variables PORT and HASH SALT Click on the card that says umami and go to the Variables tab In the old UI there will be a button called Variables in the sidebar Click that and then add the following variables under custom We need to put a random string for the HASH SALT environment variable Use any random string generator like this one Let us go with characters including uppercase and lowercase letters numbers and symbols Now paste that into Railway and click Add Also add an environment variable called PORT and set it to Note that Railway will redeploy our application every time we add an environment variable Setting up our database schemaNow we need to make tables in our database For this we need to locally clone the project Go ahead and clone it with git and open a terminal in that repository I am using the GitHub CLI to clone here but you can use git as well Now we need to install the Railway CLI You can install it with NPM with the following command npm i g railway CLIYou can also install it with Homebrew with the following command brew install railwayapp railway railwayNow run the following command to authenticate the CLI with your Railway account railway loginNote that if you face any issues while doing this you can also try logging in with the following command railway login browserlessNow run the following command to link the local directory with your Railway project railway linkNow head over to Railway and click the PostgreSQL card and go to the Variables tab Now run the following command in the terminal railway run psql h PGHOST U PGUSER d PGDATABASE f sql schema postgresql sqlReplace the values caps with their corresponding values from the Railway dashboard from the environment variables tab for PostgreSQL from the previous step Now press enter to run the command Do note that you need the PostgreSQL CLI for this If you don t have it you can follow this guide to install it Now run the following command to deploy it railway upHooray we have successfully deployed Umami Using UmamiAfter deploying you will get an URL to deployment logged on to your CLI You can also retrieve this URL from the Railway web app You can also set up a custom subdomain or even a custom domain from the Umami dashboard You will see a login screen now The username is admin and the default password is umami we will change this Our dashboard should look like this now Now there is a banner saying there is a new version out While writing this tutorial Mikecao the creator of Umami pushed a new version Now that is a good thing because now I get to show you how to update Umami Before that let us just quickly change our password as umami isn t a secure password Head over to Settings gt Profile and click on Change Password Enter umami in the Current Password field and then set a new secure password and click Save Updating UmamiHead over to the forked Umami repository on GitHub You should see that our branch is behind by a few commits Click on Fetch Upstream and then Fetch and merge That is it A new deployment will be initiated on Railway and in a few minutes you should be up and running the latest version Adding Umami to a NextJS websiteNow let us look at adding Umami to a NextJS website For this let us first create a new NextJS application note that it will work with existing NextJS applications as well npx create next app umami tutorialLet us now move into that directory cd umami tutorialNow open it in your favorite text editor We will be using VSCode for this tutorial code Now open the pages app js file It should look like this import styles globals css function MyApp Component pageProps return lt Component pageProps gt export default MyAppNow let us add the script tag for Umami This is how our app js should look like now import Script from next script import styles globals css function MyApp Component pageProps return lt gt process env NEXT PUBLIC UMAMI SCRIPT URL amp amp process env NEXT PUBLIC UMAMI WEBSITE ID amp amp lt Script src process env NEXT PUBLIC UMAMI SCRIPT URL data website id process env NEXT PUBLIC UMAMI WEBSITE ID strategy lazyOnload gt lt Component pageProps gt lt gt export default MyApp Here we are using the NextJS Script component and lazy loading the script so that it doesn t block our website from loading We will also need to add the environment variables but before that we need to add the website to Umami Head over to Umami and then to Settings gt Websites Now click on Add website I am naming this Umami Tutorial but you can name it whatever you want to In the next field make sure to enter the domain and NOT THE URL to the website Note that I have quickly created a GitHub repository and deployed this NextJS app to Vercel I have also checked Enable Share URL so that I can share the analytics for this website with you guys Here it is Now click on Save and then Get tracking code From the modal that appears just copy the values of data website id and src Now create a new file in your NextJS app called env local and add the following environment variables NEXT PUBLIC UMAMI SCRIPT URL Your script URL the value under src NEXT PUBLIC UMAMI WEBSITE ID The website s id the value under data website id Now visit the website on your browser and take a look at the Umami dashboard it should record a view and a visit under the Realtime tab We can see more detailed analytics under the details page of the website More data will pile up as you start getting visitors on your siteNote Some browsers like brave have in built ad blockers which blocks such scripts from loading in many cases Even third party ad blockers can be responsible for this If no data is showing up in your Umami dashboard try a browser without ad blockers or private mode try restarting your development server and make sure that the values of the environment variables are right Woohoo that was a lot ConclusionWe got Umami set up and running and added analytics to a NextJS application Umami does a lot more like recording events Take a look at their documentation for more informationI hope everything worked out for you Do feel free to comment on this article or reach out to me Twitter and I will help you out Important LinksUmamiUmami DocsOfficial guide on setting up Umami on RailwayRailwayRepository for this tutorialDemo website for this tutorialPublic analytics for the demo website 2022-02-17 15:46:18
海外TECH DEV Community Thoughts on NFTs? https://dev.to/devdotjp/thoughts-on-nfts-55ih Thoughts on NFTs I ve been following the NFT scene loosely since September and I have a basic understanding of what it has to offer the advantages and of course the disadvantages that the mainstream internet user base always talk about they are very passionate I ll tell you that I m not a NFT maximalist by any means I m just someone who is very intrigued by the technology and its current and future uses Curious what my fellow developers think about the it Let s have an educated back and forth 2022-02-17 15:35:20
海外TECH DEV Community Resumable JavaScript with Qwik https://dev.to/this-is-learning/resumable-javascript-with-qwik-2i29 Resumable JavaScript with QwikWhen Misko Hevery creator of AngularJS approaches you to look at his new framework well you stop and listen I was already aware of Qwik and saw the potential but this was as good as any to stop and take a closer look Qwik is a unique JavaScript framework in that it is the only one that exists today that can hydrate out of order at a component level It goes beyond that though Qwik introduces a new concept to the vernacular of JavaScript The Resumable Framework Resumable Framework These days it is common for our JavaScript Frameworks to be isomorphic That is to be able to render on the server and in the browser But for most frameworks this ability was tacked on afterwards A natural extension to their client side paradigms But what if the framework was built on SSR in the first place Well before Qwik we ve seen surprisingly few Meteor Marko maybe a couple others However the modern isomorphic landscape is built on the back of libraries like React Vue and Svelte that weren t initially created for server rendering So unsurprisingly their core mechanics weren t designed in a way to leverage this information If you knew that your app was always going to be rendered on the server first what sort of concessions could you make The most powerful one might be not redo any of the work in the browser that was already done on the server A JavaScript framework designed to do less work in the browser Not the first framework to do so But perhaps the first to realize the idealized hydration execution Hydration is the process of adding interactivity to server rendered HTML It involves attaching event handlers and initializing application state For most JavaScript libraries this is a top down process very similar to re rendering the whole app again in the browser even if it doesn t actually create any new DOM nodes For a more complete guide on Hydration see Why Efficient Hydration in JavaScript Frameworks is so Challenging The Journey to ResumabilityCreating a hydration approach that does not redo work in the browser is not an easy path You don t simply pick up your existing Single Page App framework of choice and get here We ve been working on the same problem in Marko the last couple years and although the approach different it does really come down to a few key things Ability to break apart the code needed for hydration events effects from code needed to render the view and manage stateful updates Understanding what data is stateful can update and what depends on it To resume work it must be done at a more granular level than the components as re running components during hydration would be unnecessary work Serializing sufficient data so that unrelated changes don t require re calculation and so that that parts of the app can be hydrated independently and out of order Some frameworks do maybe one of these but almost no frameworks do all three Qwik accomplishes this through following rules on Component authoring reactive primitives similar to React Hooks and the use of a compiler leverages markers in the JSX to indicate how code should be broken apart Notice the indicators to separate component code from view and from event handler in this header section of TodoMVC What about Lazy loading Beyond being resumable one the most standout features of Qwik is its lazy loading It can start with kb of bundled JavaScript component code and scale up to what needs to be on the page no matter how interactive it is Qwik does this very differently than others that seek to solve this problem have used knowledge of what is server versus client to make choices Those solutions rely on islands special file extensions or even advanced compiler analysis From where I m sitting this is the of the problem to solve Most pages are mostly static But what if the page is incredibly interactive What if most of the page could and would be loaded in the browser Well in that case lazy loading may be the only way to get a responsive page during initial load And it isn t as simple just delaying the inevitable That just pushes the full cost to when the user first interacts with the page No What makes Qwik interesting is those same qualities that allow it to be resumable also allow any part of the page to hydrate independently Yes That button half way down the page can load the necessary code to add an item to your cart before any JavaScript higher up in the hierarchy is loaded This isn t how typical frameworks work If you have components that contain other components and pass props throughout things need to run top down So Problem Solved Well maybe But probably not in the way you are picturing Understanding what I explained above I thought it would be fun to come up with a demo really showcase these unique features of Qwik I mean picture it Writing your typical single page application SPA with JSX and reactive data like you ve grown accustom to except when the page loads barely any JS loads And when you scroll down a bit you find something that interests you and the JavaScript just for that section loads and works Content with that you click a link suddenly the client side router loads and client navigation takes over Seamless SPA experience with perfect on demand hydration Until you realize that when you navigate to that new page you are suddenly loading dozens of new mini JS files to render the whole page in the browser At first you go maybe this isn t great But then you think well we can do something smarter here with bundling And Qwik is looking into some smart approaches with bundling but this goes beyond that For a framework that optimizes everything to reduce JavaScript in the browser why would you even want to render the whole next page in the browser Well you wouldn t And that s when everything starts to really make sense Evaluating Qwik on the merits of existing frameworks is pointless It seems like Qwik is the panacea for React s bundle size but really it is entirely something else It s a Brave New WorldSo what is Qwik It s everything I ve mentioned in this article It s a framework that is optimized to do the least initial work in the browser regardless of app composition More importantly it suggests the potential of a new paradigm in how we build apps in the frontend Not one that just transitions from SPA but is built entirely with getting the most from the server in mind It s still relatively new A lot of features are undocumented And there are problems that still need solving It clearly benefits from classic server multi page app routing to persist its experience even as we move to new pages When going to new locations server rendering allows Qwik to continue to send no JavaScript by default I anticipate that we will see more developments in this space in general to bring server rendered pages and partials without full page reloads Lazy loading is still a tricky problem to solve because it does have a cost Critical interactions shouldn t be lazy loaded and things should be loaded together in logical ways to prevent code split waterfalls Qwik has an optimizer that gives you control over how things are bundled In the future you will be able to feed your site analytics how your users interact with your page to inform bundling Wild I know But part of the consideration of such an approach You can play with the optimizer today in their online playground Data loading and serialization is still a consideration Some other partial hydration solutions use the fact they know what is server only to only serialize the required data Leveraging the fact they d need to be passed in as props to top level browser components can significantly reduce the double data problem representing it both as JSON and the rendered HTML Qwik doesn t innately have this knowledge but its approach to hydration isn t a limitation here So it will be interesting to see what approach they take ConclusionHaving had the pleasure of making a couple demos now Hackernews JS Framework Benchmark in Qwik I see the beginnings of a very promising framework But it is also one a bit difficult to evaluate in the current environment because I feel we are yet to see the full picture Not just because Qwik is still under development but because the wider ecosystem and tooling hasn t really caught up to this shift But that is only a matter of time In the meanwhile Qwik provides one of the most unique takes on how to solve the problem of too much JavaScript Handling Lighthouse scores without breaking a sweat If you are in the market for minimizing your Time to Interactive and wanting to try something new you could hardly make a better a choice Interest more in how Qwik works Misko Hevery has written a great article series on the topic A first look at Qwik the HTML first framework Miško Hevery for Builder io・Jun ・ min read javascript frameworks webdev performance 2022-02-17 15:27:13
海外TECH DEV Community Should I quit my career? https://dev.to/gauravsoni97/should-i-quit-my-career-24kp Should I quit my career I need some suggestion regarding my career as a front end developer SHOULD I QUIT MY CAREER AS A FRONTEND DEVELOPER Read please and give your valuable feed back In frontend development i know HTML CSS Bootstrap sass WordPress and i know little bit of javascript and currently learning react js I think i can t able to do logical thinking as other s doing in react as reactjs developer or js devloper like my other friends do So thinking to quit my current job Any suggestions 2022-02-17 15:18:06
海外TECH DEV Community Services and Ingresses in Kubernetes https://dev.to/okteto/services-and-ingresses-in-kubernetes-1pjp Services and Ingresses in KubernetesBefore starting this post I want to congratulate you all for making it till here Kubernetes is intimidating especially if you come from a developer background The fact that you were able to understand the concepts we talked about in the previous articles is a huge feat Wrapping your head around so many Kubernetes objects is no easy deal In the last post we looked at configuration and storage in Kubernetes We saw how Secrets help provide sensitive configuration data to our app and how Persistent Volumes can be used to make sure we don t lose our data in case some Pods crash In the final post of this series we re going to take a look at how networking works in Kubernetes We will see how we can expose Pods running our application using the Service object This would help us ensure that different parts of our application backend frontend etc are able to communicate with each other within the cluster Then we will see how we can ease external access to our application by setting up routing using the Ingress object Lots to cover in this one so let s begin ServicesTo understand Services let s look at what problem they solve If you recall our discussion of Deployments you ll remember that deployments create and manage multiple pods for us So we would have a deployment for the frontend of our application which would manage multiple pods running our containerized frontend code Now this code would need to interact with the backend pods But how does it do that What IP address should it ping It clearly can t be the IP address of a particular backend pod because we know pods are ephemeral so we can t rely on their IP addresses This is where Services come into the picture Services allow us to send traffic to Pods that match the labels we specify when creating the Service Let us look at the YAML for a simple service to understand things better ​​apiVersion vkind Servicemetadata name database servicespec selector app database ports protocol TCP port targetPort The above YAML should be pretty easy to understand it creates a Service that will route all traffic to Pods that have the label app database on them Coming to the ports section which might not be so obvious we specify a port and a targetPort targetPort is the port on which the selected pods will be listening The Service will send requests to the Pods on this particular port port on the other hand is simply the port within the cluster on which we want the Service to be exposed This is needed because we might have different services in our cluster which we would then expose on different ports Another thing worth mentioning is that while TCP is the default network protocol for services in Kubernetes you can use any of the following instead too So far so good right Looking at the movies app we deployed on Okteto Cloud we have a service created which is exposing the database for our backend pods to talk to You can confirm that this Service exists by running kubectl get servicesTo see what the YAML for this Service looks like you can run kubectl get service mongodb o yamlYou ll see that we have specified as the value of the port which is arbitrarily chosen For the targetPort we specify because that is the default port a MongoDB database listens on Now if you look at the backend code you ll see that we use the name of this Service which is mongodb to connect to the database The url used to connect to the database is const url mongodb process env MONGODB USERNAME encodeURIComponent process env MONGODB PASSWORD process env MONGODB HOST process env MONGODB DATABASE It is using the MONGODB HOST environment variable which is set to the name of the Service that is mongodb After that we also specify the port which we arbitrarily chose when creating our Service And voila This is all the Ks magic we need in order to make different microservices in our application talk to each other Let s now take our discussion further and see how we can route incoming traffic to various services IngressesSo you ve containerized your application you ve set up your Deployments and configured Services to enable communication between parts of your application but what s next If your application is deployed on a cloud provider you would set up a load balancer pointing to your services The load balancer would provide you with a static IP address accessible from outside the cluster But is it cost effective and manageable to set up different load balancers for each of your services This is where Ingresses come to the rescue Think of an Ingress object as a sort of signboard for vehicles at a cross section of roads The roads in this metaphor are different services in our cluster and the vehicles are the requests coming to our cluster An Ingress object we create will tell the incoming requests to the cluster which Service they should go to Ingresses don t enable external access to our app by themselves but they make it easy You would now just need one load balancer from your cloud provider which would point to the Ingress and then the Ingress will take care of handling the routing of all incoming traffic Let s see what the Ingress object for our movies app looks like by running kubectl get ingress movies o yamlThe output you get should look something like this spec rules host movies rinkiyakedad cloud okteto net http paths backend service name frontend port number path pathType Prefix backend service name api port number path api pathType PrefixYou ll see that under the spec section we set up two paths for different services in our application which we wanted to expose the frontend service and the backend service So requests sent to our cluster at api will be redirected to the backend service which further directs them to the backend pods serving our application All other requests will be redirected to the frontend pods via the frontend service This simplifies the management of different routes significantly when compared to the traditional way of doing this setting up an NGINX proxy per application Very convenient right To sum our discussion up Ingress isn t something complicated it s just a Kubernetes object which allows us to specify routing rules However there is another part to Ingresses that we didn t touch in this article The Ks objects we ve seen so far Pods Deployments etc come with their controllers preinstalled in the cluster This is not true for Ingresses To create an Ingress object you will need your cluster admin to install an ingress controller in your cluster I won t be covering how to do that since as developers we rarely have to do it ourselves If you re using Okteto Cloud the cluster provided to you would already have an Ingress controller installed Well that wraps up our discussion for this article We learned that different microservices in our application can talk to each other with the help of the Service Ks object Then we went ahead and looked at Ingresses which allow us to route incoming traffic to our cluster to the different Services which we ve created I hope this discussion not only enables you to learn more about this topic but also sparks your curiosity enough so you go give things a try yourself A very easy way to tinker with all this could be to fork the movies app edit the YAMLs and deploy on Okteto Cloud using a single click This post also concludes our Kubernetes for Developer series There will however be one final brief post to wrap things up and point you to resources that would be helpful for you on your Kubernetes journey ahead Until then happy hacking The Kubernetes for Developers blog series has now concluded and you can find all the posts in this series here 2022-02-17 15:05:26
海外TECH DEV Community How to Build a GraphQL server with NodeJS and Express https://dev.to/codesphere/how-to-build-a-graphql-server-with-nodejs-and-express-2g8j How to Build a GraphQL server with NodeJS and ExpressBeing able to work with APIs and write queries is crucial to any developer s skill set While working with REST APIs may be the standard more and more teams opt to setup their API s using GraphQL In this article we ll set up our own GraphQL server with Node JS ES and write a few queries to gain insight into how GraphQL works Let s take a quick overview of the pros of using GraphQL before we begin to build our demo Advantages of using GraphQLGraphQL is a query language used by developers to create flexible and fast APIs which ensure that the clients receive only the data they requested Other advantages of using GraphQL include The ability to describe data offered by APIs on the server side as well as to send queries to the GraphQL server from the client side A declarative format with the query responses decided by the server which helps give better results Queries that are composed of a hierarchical set of fields It s shaped just like the data that it returns making it intuitive to work with GraphQL is a strongly typed query language The type of data is defined at the server side while describing data and validated inside a GraphQL type system Using GraphQLWe ll be using GraphQL along with Express and NodeJS to create a simple server that returns data for an image or set of images depending on the query To build a server with GraphQL we need the following The GraphQL schema which describes the type and hierarchy of a database It also defines the query endpoints to which a client can send a request The Resolver to help attach a function to each query from the schema that executes when a client request contains that query The Data This will be the data that our server returns when it receives a query For our demo purposes we will create an array of image objects and return data as per the query Creating our ServerWithout further ado let s build our GraphQL server using Express and NodeJS First we ll create our node project withnpm initIn our package json we then need to add the following field Since we ll be creating an ES Module Next we re going to install Graphql and Express with npm i graphql express express graphql saveFinally we ll add the following javascript file to setup our server Note that we used the buildSchema method provided by graphql to define our schema The root method then is our resolver function It attaches functions to the various queries available to the user We need to define those functions in our file as well Using express we created an app variable that uses the graphql endpoint and the graphqlHTTP middleware This middleware takes the resolver function and schema as parameters We also set the graphiql option to true which enables the GraphiQL in browser tool which is used to test our endpoint by giving it queries Sending queries using GraphiQLInside our terminal we can run the following command to start our server node graphql server demo jsIf you have named your file something else obviously use that instead of the name above You can then go to http localhost graphql to access GraphiQL which will let us easily test queriesThis should launch a GraphiQL interface that looks like this In our demo code we have two endpointsimage gets a single image by idimages gets images by a categoryFor the image endpoint we can write a query like this The imageId is a variable that we can pass using the “Query Variables sectionThe result for the above query will beBy removing or adding properties inside our query we can also modify what data is returned Similarly for our images endpoint we can create a new query that will take the image category as a variable and return a list of images that match the category With the following parameterYields And there we have it We ve set up our own GraphQL server using Express and NodeJS Of course we ve only scratched the surface of what GraphQL is capable of and as the data we re working with gets more complex GraphQL is going to become more and more useful When you re reading to deploy your server check out Codesphere the most intuitive cloud platform you ve ever used Let us know what you re going to build down below 2022-02-17 15:01:29
Apple AppleInsider - Frontpage News Amazon issues record-breaking $250 discount on Apple's 14-inch MacBook Pro https://appleinsider.com/articles/22/02/17/amazon-issues-record-breaking-250-discount-on-apples-14-inch-macbook-pro?utm_medium=rss Amazon issues record breaking discount on Apple x s inch MacBook ProAmazon has issued a discount on Apple s upgraded inch MacBook Pro with a core CPU core GPU and TB of storage delivering the lowest price on record New inch MacBook Pro price dropThe cash discount is in the form of a instant rebate stacked with in bonus savings at checkout on the retail M Pro configuration with a core CPU core GPU and GB of RAM in Apple s silver finish The upgraded model also has TB of storage double that of the standard inch MacBook Pro Read more 2022-02-17 15:28:45
Apple AppleInsider - Frontpage News Password cracking tool can slowly hack T2 Mac passwords https://appleinsider.com/articles/22/02/17/password-cracking-tool-can-slowly-brute-force-t2-mac-passwords?utm_medium=rss Password cracking tool can slowly hack T Mac passwordsA company that makes a password cracking tool says that a new vulnerability found in the Mac T chip allows it to brute force passwords and decrypt a device MacBook ProApple s T chip among other features allows a Mac user to encrypt and decrypt data on their SSD That encryption is bolstered by other security features like a limit on the number of password attempts to mitigate brute force attacks Read more 2022-02-17 15:14:50
Apple AppleInsider - Frontpage News New 'iPhone 14 Pro' said to have 8GB RAM https://appleinsider.com/articles/22/02/17/new-iphone-14-pro-said-to-have-8gb-ram?utm_medium=rss New x iPhone Pro x said to have GB RAMAccording to a new report citing sources within the iPhone supply chain a leaker says the iPhone Pro range will include GB RAM Apple does not generally announce how much RAM is included in the iPhone but the iPhone Pro and iPhone Pro did increase it to GB Leaker yeux on the Korean blogging site Naver claims the GB figure is confirmed Mass production is also claimed to be underway Read more 2022-02-17 15:00:52
海外TECH Engadget Formula 1 will use a VAR-style virtual control room to avoid controversy https://www.engadget.com/formula-1-var-virtual-race-control-room-155313188.html?src=rss Formula will use a VAR style virtual control room to avoid controversyThe Formula season ended messily to put it lightly and the FIA is hoping technology will prevent a repeat As part of a string of changes Formula is implementing a quot Virtual Race Control Room quot akin to the Video Assistance Referee VAR you see in soccer The quot backup quot will sit outside the circuit and use a real time link with the race director to enforce rules using the quot most modern technological tools quot The race director will also be cut off from direct radio communications to reduce pressure It will still be possible to ask questions but there will be a strict procedure for this The move comes after a controversial end to the Abu Dhabi Grand Prix in December Lewis Hamilton was leading the race with five lapped drivers sitting behind the safety car and preventing rival Max Verstappen from realistically contesting Hamilton s position However race director Michael Masi made the controversial decision to let those trailing drivers quot unlap quot themselves by passing the safety car giving Verstappen a much easier time of challenging Hamilton s lead With the help of fresh tires Verstappen passed Hamilton who was using worn tires to win the race and in turn the Driver s Championship nbsp Hamilton s Mercedes team appealed Masi s call by pointing to rules requiring all cars to unlap themselves and for racing to resume the following lap rather than immediately The team also claimed Verstappen s front wing briefly passed Hamilton while behind the safety car Race stewards rejected the appeal There are no guarantees the virtual control room will improve F rule enforcement This and VAR represent a shift in officiating techniques however Sports leagues appear less and less content to rely solely on human judgment ーtechnology isn t replacing race directors or referees but it might ensure their calls hold up under scrutiny 2022-02-17 15:53:13
海外TECH Engadget Snapchat will let you change your username starting February 23rd https://www.engadget.com/snapchat-name-change-151743912.html?src=rss Snapchat will let you change your username starting February rdSnap says it will soon roll out a much requested and long awaited feature to all users a way to change their Snapchat username The company started testing the option recently and it will be available for everyone on iOS and Android as of February rd You ll be able to switch your handle without setting up a new account and having to start over with your friends list memories Snap score and so on However users will only be able to change their name once per year To do so go to your profile and open the settings Tap Username and then select the Change Username option Snap acknowledged that people grow and change over time Many of them won t want to be stuck with a bad Snapchat username they came up with a decade ago perhaps when they were a young teen So this feature might come as music to the ears of those whose usernames include a quot Gangnam Style quot reference 2022-02-17 15:17:43
金融 ◇◇ 保険デイリーニュース ◇◇(損保担当者必携!) 保険デイリーニュース(02/18) http://www.yanaharu.com/ins/?p=4839 損保ジャパン 2022-02-17 15:32:27
金融 RSS FILE - 日本証券業協会 株券等貸借取引状況(週間) https://www.jsda.or.jp/shiryoshitsu/toukei/kabu-taiw/index.html 貸借 2022-02-17 15:30:00
金融 金融庁ホームページ 「ESG評価・データ提供機関等に係る専門分科会」(第1回)議事次第について公表しました。 https://www.fsa.go.jp/singi/esg_hyouka/siryou/20220207.html 評価 2022-02-17 17:00:00
金融 金融庁ホームページ 金融審議会「ディスクロージャーワーキング・グループ」(第6回)議事次第について公表しました。 https://www.fsa.go.jp/singi/singi_kinyu/disclose_wg/siryou/20220218.html 金融審議会 2022-02-17 17:00:00
金融 金融庁ホームページ 金融安定理事会による「暗号資産の金融安定に対するリスクの評価」について掲載しました。 https://www.fsa.go.jp/inter/fsf/20220217/20220217.html 金融安定理事会 2022-02-17 17:00:00
金融 金融庁ホームページ 審判期日の予定を更新しました。 https://www.fsa.go.jp/policy/kachoukin/06.html 期日 2022-02-17 16:00:00
ニュース @日本経済新聞 電子版 NYダウ、続落で始まる ウクライナ情勢を警戒 https://t.co/Iuj6KpXox5 https://twitter.com/nikkei/statuses/1494328975900160004 続落 2022-02-17 15:12:45
ニュース BBC News - Home Storm Eunice: Rare red weather warning issued for parts of the UK https://www.bbc.co.uk/news/uk-60417263?at_medium=RSS&at_campaign=KARANGA power 2022-02-17 15:19:59
ニュース BBC News - Home British man, 35, killed in Sydney shark attack https://www.bbc.co.uk/news/world-australia-60398033?at_medium=RSS&at_campaign=KARANGA attack 2022-02-17 15:18:14
ニュース BBC News - Home GB men's curlers guaranteed silver after win https://www.bbc.co.uk/sport/winter-olympics/60413055?at_medium=RSS&at_campaign=KARANGA GB men x s curlers guaranteed silver after winGreat Britain are guaranteed their first medal of the Winter Olympics after the men s curling team beat the United States in a nail biting semi final 2022-02-17 15:42:11
ニュース BBC News - Home Valieva misses out on podium in figure skating final https://www.bbc.co.uk/sport/winter-olympics/60399342?at_medium=RSS&at_campaign=KARANGA skate 2022-02-17 15:25:49
ニュース BBC News - Home 'This is our home': The Americans who refuse to leave Ukraine https://www.bbc.co.uk/news/world-us-canada-60419006?at_medium=RSS&at_campaign=KARANGA ukraine 2022-02-17 15:43:01
ニュース BBC News - Home Masi removed as F1 race director in wake of Abu Dhabi Grand Prix controversy https://www.bbc.co.uk/sport/formula1/60418716?at_medium=RSS&at_campaign=KARANGA Masi removed as F race director in wake of Abu Dhabi Grand Prix controversyMichael Masi is removed as F race director as part of a restructure at governing body the FIA in the wake of last year s Abu Dhabi Grand Prix 2022-02-17 15:42:19
ニュース BBC News - Home Khan calls Brook his 'fanboy' at tense media conference https://www.bbc.co.uk/sport/boxing/60405715?at_medium=RSS&at_campaign=KARANGA manchester 2022-02-17 15:03:58
ニュース BBC News - Home Winter Olympics: Great Britain men beat United States to reach curling final https://www.bbc.co.uk/sport/av/winter-olympics/60414930?at_medium=RSS&at_campaign=KARANGA Winter Olympics Great Britain men beat United States to reach curling finalMen s curlers secure Great Britain s first medal of the Winter Olympics as they beat United States to set up a final against Sweden in Beijing 2022-02-17 15:04:59
北海道 北海道新聞 疑惑のワリエワ、まさかの乱調 暫定4位に泣き崩れる https://www.hokkaido-np.co.jp/article/647093/ 北京冬季五輪 2022-02-18 00:13:00
仮想通貨 BITPRESS(ビットプレス) GMOコイン、2/16より販売所とつみたて暗号資産にて「メイカー(MKR)・ダイ(DAI)」の取扱開始 https://bitpress.jp/count2/3_10_13070 資産 2022-02-18 00:56:52

コメント

このブログの人気の投稿

投稿時間:2021-06-17 22:08:45 RSSフィード2021-06-17 22:00 分まとめ(2089件)

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

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