投稿時間:2021-09-11 01:31:22 RSSフィード2021-09-11 01:00 分まとめ(34件)

カテゴリー等 サイト名等 記事タイトル・トレンドワード等 リンクURL 頻出ワード・要約等/検索ボリューム 登録日
python Pythonタグが付けられた新着投稿 - Qiita isort で ignore_blobs を設定する https://qiita.com/tktcorporation/items/166c5c3681a243bbf75c isortでignoreblobsを設定するisortの実行時にファイルパスを無視させる設定をしようとして、書き方がぱっとわからなかったのでメモ環境PythonpoetryDjango設定ファイルpyprojecttomlisortignoreblobsファイルを無視させるにはignoreblobsというオプションを設定すれば良いらしく、これをpyprojecttomlに記述する。 2021-09-11 00:31:17
Program [全てのタグ]の新着質問一覧|teratail(テラテイル) VBA:指定のファイルから別ファイルへデータのコピーを行いたい https://teratail.com/questions/358864?rss=all VBA指定のファイルから別ファイルへデータのコピーを行いたいVBAで指定の参照元ファイルから指定の別ファイルへデータのコピーが行いたいです。 2021-09-11 00:53:19
Program [全てのタグ]の新着質問一覧|teratail(テラテイル) 初回読み込み時にコンテンツスクリプトが起動しない。 https://teratail.com/questions/358863?rss=all コンテンツスクリプトを走らせることで翻訳をしているのですが、なぜかそもそもコンテンツスクリプトが走らないことがあります。 2021-09-11 00:47:13
Program [全てのタグ]の新着質問一覧|teratail(テラテイル) サンプルサイトのhtml,css,javascript https://teratail.com/questions/358862?rss=all サンプルサイトのhtmlcssjavascript質問したいことサンプルサイトのhtmlcssjavascript画像一式ダウンロードできるサイトはありませんか。 2021-09-11 00:47:06
Program [全てのタグ]の新着質問一覧|teratail(テラテイル) djangoの全プロジェクトテスト時のエラーについて https://teratail.com/questions/358861?rss=all djangoの全プロジェクトテスト時のエラーについて前提・実現したいことdjango初学者です。 2021-09-11 00:37:34
Program [全てのタグ]の新着質問一覧|teratail(テラテイル) GoogleChrome フォーム 正規表現について https://teratail.com/questions/358860?rss=all googlechrome 2021-09-11 00:11:09
技術ブログ Developers.IO 他アカウントのEventBridgeのイベントバスに対してイベントを発行する https://dev.classmethod.jp/articles/issue-an-event-to-the-event-bus-of-eventbridge-of-anotheraccount/ event 2021-09-10 15:40:22
海外TECH Ars Technica Google.com dark mode is rolling out to everyone https://arstechnica.com/?p=1793510 results 2021-09-10 15:21:59
海外TECH DEV Community Kessel Run: Smuggling DevOps into the Department of Defense https://dev.to/linearb/kessel-run-smuggling-devops-into-the-department-of-defense-16a1 Kessel Run Smuggling DevOps into the Department of DefenseTo fight the wars of the future the US Air Force tasked a small group of software engineers with a simple job ーrevolutionize the way the military thinks about software development The group tasked with this not so tiny problem came to call themselves “Kessel Run after the famed smuggling route used by Han Solo in Star Wars Since starting in the team at Kessel Run has expanded to include over people across multiple locations helping build test deliver operate and maintain cloud based infrastructure and warfighting software These applications are used by airmen worldwide and represent the future of warfare That s because the wars of the future will be fought with software and system architecture as much as any other weapon What is Kessel Run “ Kessel Run was kicked off about four years ago as a way to prove that the Department of Defense didn t have to be terrible at building and delivering software regardless of being within the world s largest bureaucracy ーAdam Furtado on the Dev Interrupted podcast at As an Airforce organization Kessel Run delivers a wide variety of mission capabilities to warfighters around the world utilizing industry best practices around DevOps and Agile At the time of its inception it represented such a radical departure from the normal way of thinking within the Department of Defense DoD that people joked it would have to be “smuggled into the DoD That s how Kessel Run came to earn its name ーa scruffy team outfitted with a mission to upend a stodgy and cumbersome bureaucracy A shift in thinking needed to start with culture The team at Kessel Run decided to bring a startup like mentality to the behemoth that is the federal government with a goal of introducing modern software methodologies at scale Pockets within the DoD were practings things like continuous delivery but prior to Kessel Run previous attempts to adopt modern software principles had largely failed Warfighters weren t getting the capabilities or tools they needed Problem SolversOne of the biggest institutional problems that Kessel Run was tasked with trying to improve were the Air Force s Air Operations Centers Spread around the world across twenty two locations these organizations manage all the details that involve fighting an air war Everything from strategy to planning to tasking aircraft to perform certain actions to providing real time intelligence data and feedback are handled at Air Operations Centers The challenge was modernizing these centers while maintaining operational readiness and current hardware ーmuch of which was to years old All of the hardware across these locations came with its own integrated software built from various third party sources over decades To tackle this challenge the team at Kessel Run applied the principles of Gall s Law which states that all complex systems that work evolved from simpler systems that worked By starting small and focusing on rapidly achievable solutions they began to see the network effects of their actions Small precise fixes can have tremendous impacts on an organization and are less prone to failure than attempting systematic change overnight “So we knew that using Gall s Law in history that we needed to start small in order to make this work We couldn t just have a big bang approach to replace this entire system Right You did that by chipping away at some core parts of the system from a user functionality perspective ーAdam Furtado on the Dev Interrupted podcast at Practical SuccessOne of the first small changes achieved by Kessel Run was with the Air Force s air refueling program A remarkable acrobatic feat performed at more than feet above ground at speeds close to miles per hour replenishing the fuel of an aircraft is dangerous but necessary work Everyday fighter jets and bombers rendezvous with fuel air tankers to perform air to air refueling before continuing on with their mission Optimizing the details of such a delicate dance would be difficult but the folks at Kessel Run believed they could do it First they needed software engineers One of the problems of developing software at the federal government is a lack of engineers Or rather a lack of native engineers that can be found in house Historically speaking the government outsources everything to contractors Scrounging the Air Force for active duty software engineers scattered across separate programs Kessel Run was able to stitch together it s own homegrown software engineering team With their mission in hand they set to work building an initial application nicknamed “Jigsaw to improve the air refueling process By optimizing every aspect of the process from the timing to the altitude Jigsaw became an enormous success Within a year of implementation the Air Force was saving million a month on fuel Tiny targeted successes like these continued But Kessel Run was up against more than just inefficient programs A New Way of ThinkingChanging company culture is notoriously difficult Changing culture inside the world s largest bureaucracy is as hard as it gets The most difficult problem that Kessel Run had to tackle wasn t the lack of software developers or the difficulty of integrating third party software applications or figuring out how to optimize and build combat applications it was how to communicate with their peers in the DoD Part of the difficulty was due to the security implications of such work The production environments are all on classified systems making things like cloud implementation and tooling availability difficult However navigating the business side of the DoD was always the most challenging In the past years the government has spent over a billion dollars trying to update their systems to provide the best capabilities possible to warfighters in order to prepare for a war that may never happen Until Kessel Run the government didn t have much to show for their efforts A perception existed that new software methodologies and practices were just the next iteration of technologies that overpromised and underdelivered It took a lot of trust to explain that doing something in a more agile way or using DevOps would actually reduce risk and increase success for the organization “The problem we have is we go and talk about how deployment frequency is going to buy down risk for us That sounds counterintuitive to everybody in the world particularly in a military environment where they re like What do you mean Change is scary I don t change stuff So we re having these kind of counterintuitive conversations around why moving to this way of working is less risky and increases our chances of success ーAdam Furtado on the Dev Interrupted podcast at Solving that problem came down to nothing more than old fashioned relationship building It took years of evangelism and continued success but eventually Kessel Run started to win the approval of the right people in the right places Proof is in the PuddingFrom starting as an organization with only software engineers to expanding into a program that currently has over people Kessel Run has proven itself to be an ingenious concept bring startup culture to an old organization in need of modern ways of thinking Government has never been the place that attracted the top talent in technology but with Kessel Run it s become that They provide access to the newest technologies competing with some of the best companies in the industry They do have one ace up their sleeve when it comes to hiring fighter jets And those are pretty cool If you want to learn more about the history and story of Kessel Run consider listening to the Dev Interrupted podcast featuring Adam Furtado Kessel Run s Chief of Platform Dev Interruptedis a weekly podcast featuring a wide array of software engineering leaders and experts exploring topics from dev team metrics to accelerating delivery If you haven t already heard Dev Interrupted is partnering with Dzone to host INTERACT An interactive community driven digital conference on September th by engineering leaders for engineering leaders day speakers s of engineers and engineering leaders all free Register Now Join the Dev Interrupted CommunityIf you haven t already joined the best developer discord out there WYD Look I know we talk about it a lot but we love our developer discord community With over members the Dev Interrupted Discord Community is the best place for Engineering Leaders to engage in daily conversation No salespeople allowed Join the community gt gt Originally published at on September 2021-09-10 15:33:55
海外TECH DEV Community How Every Web Developer Can Become FullStack With Node.js https://dev.to/dastasoft/how-every-web-developer-can-become-fullstack-with-node-js-11fc How Every Web Developer Can Become FullStack With Node jsI m sure you ve heard of Node js but maybe you haven t delved into it or you only have a general idea of what it is and what it s for I want to explain what Node is and why you should use it especially if you are in web development and want to expand your tool belt or your job opportunities We are also going to see why to use some libraries and frameworks that are built on top of Node to make our life easier and our code cleaner Through this guide we will see what Node and Express is and how it works build a REST API to store and retrieve data test endpoints and upload our application By the end of this series you will have a complete overview of the MERN stack MongoDB Express React and Node and testing skills RoadmapI want to give you also a roadmap of this series the idea is that starting from a basic knowledge of Node and Express we will see how to store and retrieve data from the server but for now using only the file system In future guides we will see how to transform this into a real database data retrieval storage and even how to deploy to the cloud In this series we will also create a React application that will use this back end we are creating now If you use or have just started using Next js you may have noticed that Next js comes with a Node inside the api js I think it is important to experiment with flat Node before you first encounter it inside Next js but we will see how much of the code we are building today is reused in a project built with Next js too TypeScriptIn the sample project I will be using TypeScript instead of plain JavaScript you can follow it without worries because the syntax is quite similar but if you wonder why you should bother dealing with TS instead of JS I recommend you read my last post My last post was for TypeScript on the front end but everything explained there is applicable here If in the front end TS is useful in the back end it is even more useful because back end development usually has more logic and let s say more critical than front end development but take this statement with a grain of salt ResourcesNode jsExpressProject Sample Project SampleIn this guide we are going to work on a simple REST API that stores and retrieves data from JSON files stored on the server This REST API is intended to build a job posting application where users can enter a company and different job postings What is Node js As you know we are divided into front end and back end until Node js was released if we think of JavaScript it was directly targeted at front end development With Node js we can run JavaScript on the server side or even directly on a computer Well technically a server is a computer but you get the point But JavaScript only runs inside the browser so how can it now run directly on a computer Node js is mainly built in C Node inside has Google s V engine this engine converts the JavaScript directly into native machine code So basically you write your normal JavaScript which Node passes to V which generates machine code and the computer is able to read that code But Node is much more than a bridge between your JS and V through different modules Node allows us to give some examples to communicate with the computer s file system or to set up a server that reacts to requests and serves content from to a database That s great but I m a web developer who doesn t intend to write applications for Windows or any other OS how do you put Node js on the server and replace my fancy Java Spring Boot Hibernate dynamised with Lombok annotations You ll send a request to the server from your React or whatever front end you have on the server we have a Node js running that will listen to the request and make a response back to the client That response it can be a file because we have access to the file system like a full HTML and image or any other binary data It can also communicate with a database retrieve some data do some calculations and give us back a beautiful JSON ready to use in our front end Why to use Node js It s all JavaScript →Even if you look at this from the perspective of your own or the point of view of a company it is still true just one language and you can make a complete application both sides For you it s interesting reusing your current skills with a language in another field but for companies this is a good point too they can reuse the current expertise of their workers It s all JavaScript x →Because both sides are JavaScript it s very possible to reuse code between both sides do you already have a function that validates ID cards Use exactly the same on the front end and back end Community →There are a lot of utilities packages and even frameworks built on top of Node js you will get a lot of support and there are tons of ready to use tools available It s highly used →Take a look at this screenshot from State of JS Express which is built on top of Node js is in a terrible shape But yes the everyone uses it argument should be taken very carefully SetupThe easiest way to install Node js on your system is to go to the official website especially where all the platforms and options are listed You can choose between the Long Term Support or the latest version choose what you want for the case of this guide both options are good personally I am using the current version which is For Windows and Mac there is no mystery with the installation so if you are Linux user like me you will find this resource more useful For example for Ubuntu users curl fsSL sudo E bash sudo apt get install y nodejsInstalling Node js also installs npm which stands for Node Package Manager if you come from web development you are more than used to using it To check that everything is OK run the following commands in your terminalnode versionnpm versionIf you type node in your terminal you will be able to execute JavaScript code in the same way as you do in a Developer Tools inside the browser If you want to exit type exit or use Ctrl C Open your favourite IDE and create a server js file the name is totally up to you in this JS file you can write your normal JavaScript and run it by typing node server on your terminal Congratulations you are now running JavaScript code outside the browser Differences running JS on Front and BackAs we have already seen Node js allows us to execute JavaScript in the back end of our project but as that JavaScript is executed outside the browser there are some minor differences Global ObjectIn the front end our global object is the window object if you inspect that object you will find a number of utilities and variables such as the fancy window document getElementById In Node js the window object is replaced by the global object Use your server js file created earlier to make console log global and check what s inside You ll find some familiar functions like setTimeout or setInterval console log global lt ref gt Object global global Circular clearInterval Function clearInterval clearTimeout Function clearTimeout setInterval Function setInterval setTimeout Function setTimeout Symbol nodejs util promisify custom Getter queueMicrotask Function queueMicrotask performance Getter Setter clearImmediate Function clearImmediate setImmediate Function setImmediate Symbol nodejs util promisify custom Getter If you look closely you ll miss a few things such as the fact that Node doesn t have a document object or any of the other objects related to DOM manipulation As in the front end you don t need to type global every time you need to access something inside this object you can use setTimeout directly instead of going to global setTimeout dirname and filenameThere are two new utilities available in global that you will use a lot dirname will tell you the path to the directory in which the current script is running filename returns the name and absolute path of the currently running script console log dirname workspace my new projectconsole log filename workspace my new project server js Splitting CodeIf you want to split your code into different files you might be used to import and export from ES JavaScript in Node it s also possible but a lot of the code you ll find on the internet will be with commonJS modules so I think it s important to know that too To export members from your current module to others you can use these options module jsconst name dastasoft const ultimate instant sleep module exports name ultimate module jsconst animes Death Note Jujutsu Kaisen module exports animes module jsmodule exports today gt new Date getDay The difference is not only the number of parameters you want to export but how you use the values module jsconst name ultimate require module const animes require module const aFunction require module console log name dastasoftconsole log ultimate instant sleepconsole log animes Death Note Jujutsu Kaisen console log aFunction today As you can see instead of importing we use require as a keyword to include other modules The module is just a simple JavaScript variable that is included in all Node modules If you try to use ES modules you will most likely get the following error node Warning To load an ES module set type module in the package json or use the mjs extension node Warning To load an ES module set type module in the package json or use the mjs extension There are different ways to solve this Using the mjs extension for files you want to use and consume as a module Setting the type to module in your package json Using TypeScript and in the tsconfig json set the module to commonjs so the TS you write will be transformed into JS using commonjs and Node will be happy with that Built in modulesAlong with Node there are some utility modules that you can use without any additional installation let s see some examples OSThe operating system module provides a lot of information about the system it is running on const os require os console log os arch xconsole log os version Ubuntu SMP Thu Jun UTC console log os platform linux FSThe filesystem module is one of Node s game changers you can access the filesystem and perform a lot of actions Let s create a filesystem js to do some testing with the filesystem module filesystem jsconst fs require fs fs readFile assets test txt error data gt if error console log error else console log data toString If you do node filesystem you will get the following error message Error ENOENT no such file or directory open assets test txt Create a folder called assets and a test txt file with some content in it try again Let s add a writeFile function filesystem jsconst fs require fs fs readFile assets test txt error data gt if error console log error else console log data toString fs writeFile assets test txt I m soooo fast gt console log Done sir If you try this code you will see that before you can read the file it is already written with the new text and when readFile does its job it prints the new content This happens because these two methods are asynchronous and do not block the execution of the code the code continues to execute line by line and writeFile terminates first This is one of the key points of Node js and the reason why many large companies are looking for Node its asynchronous nature and non blocking I O With this your server can receive a lot of requests without blocking the application Node has a library called libuv which is multithreaded it will handle all the asynchronous processes that Node s single thread cannot and return the response Try this code instead console log fs readFileSync assets test txt toString I m soooo fastfs writeFileSync assets test txt I m actually faster Now you are using the synchronous methods and the code is enclosed in those statements FS allows a lot more actions but you have the basic idea with this module we can for example read a file do some calculations modify it and return its content to the front end http httpWith these modules we can configure our Node as a HTTP HTTPS server this will be the module we will use to create the REST API server jsconst http require http const HOSTNAME localhost const PORT const server http createServer req res gt console log req console log res server listen PORT HOSTNAME gt console log Server started on http HOSTNAME PORT If you use node server and open a browser with localhost you will see in the server console those console log which contain two useful parameters the request and response objects These objects contain some useful information that we ll look at in detail later but for now you can take a look at what is printed We use the built in http module The hostname from which the server will respond will be our localhost As a convention port is used for local development but you can use any port you like if it is available We use the createServer function We start the server with listen As you can see the console log is not printed to the browser console it is only printed to the server console this is because we are running server code here in the next section we will see how to send data to the front end which will be the core of our REST API Creating a Server server jsconst http require http const HOSTNAME localhost const PORT const server http createServer req res gt res writeHead Content Type text plain res write Hello from the Server res end server listen PORT HOSTNAME gt console log Server started on http HOSTNAME PORT Now try accessing localhost in your browser and check the results We set up the server to respond using the response object to incoming requests with plain text indicating a status code and terminating the communication If you look closely at the example in the previous section once you access localhost the browser never resolves the request that was because we were not using end to notify the end of the communication Status CodesIf you do not know what status codes are see this list in short the status code serves to notify whether the communication has been successful or what kind of problem has occurred Content TypeThis header is used to tell the client what is the type of content returned If you want to check the different types see this list Useful external packagesWe already saw some useful built in modules but the community has developed tons of well done packages worth mentioning and you will find many when you check the internet If you don t already you can initialize your project with npm in your project folder npm init yThis will generate a simple package json which will be useful in the next sections and is necessary to install external packages nodemonIf you try to modify the code above with the server running you will probably have noticed that the changes require a restart of the node process The nodemon external package watches for changes to our files and applies them automatically without the need for a restart See the official nodemon page but in shortnpm install D nodemonInstall as a development dependency and configure your start script as follows start nodemon server js And execute it npm startYour server will automatically react to changes ExpressWe will see this package in detail in the next section for now let s say that Express is a web framework for Node it simplifies the process of developing a web application and aims to build efficient and fast web applications Express is also the E of the MEAN MERN MEVN stack You can achieve that result without Express or even with other packages but let s look at the advantages of this particular package To add Express to your project npm install express MorganMorgan is an external package that is part of Express this package allows us to log events in an easy and simple way it is very convenient for these first steps to check what is happening in our server In the next section we will see how to use it for now let s add it to our project npm install D morganOne tip when using an external package even if you have seen it in a tutorial make sure that it really solves a problem for example body parser is a package that is present in almost all such guides but Express really has its own solution nowadays ExpressAs we saw in the last section we will use Express in our project but I think the most important thing when you add a new package to your project is to know why and what problem it actually solves We are going to build a simple REST API as an example You can achieve this behavior without installing Express and just using Node First let s create a database folder and a companies json inside it this file will act as a simple database companies json id name Capsule Corp about Like WinRAR but we accept more file extensions industries automobile house engineering numberEmployees yearFounded id name Red Ribbon about We deliver the best Android you can ever had industries militar artificial intelligence engineering numberEmployees yearFounded server jsconst fs require fs const http require http const HOSTNAME localhost const PORT const DB PATH dirname database companies json const getCompanies res gt fs readFile DB PATH error data gt if error console error error res statusCode res end else res setHeader Content Type application json res statusCode res end data const deleteCompany res id gt fs readFile DB PATH error data gt if error console error error res statusCode res end else const companies JSON parse data const filteredData JSON stringify companies filter company gt company id id null fs writeFileSync DB PATH filteredData res setHeader Content Type application json res statusCode res end filteredData const server http createServer req res gt const baseURL http req headers host const url new URL req url baseURL if url pathname companies amp amp req method GET getCompanies res else if url pathname companies amp amp req method DELETE deleteCompany res url searchParams get id else res statusCode res end server listen PORT HOSTNAME gt console log Server started on http HOSTNAME PORT Starting with the createServer as before we set up a server that listens for requests and depending on the URL and method used executes one logic or another Within the two different methods we read the JSON file and return the content in deleteCompany we look for a specific Company and filter the array and write to the file while returning the resulting array If you want to try the previous example I recommend you to use Postman an application that we will see in detail later with which you can execute different requests to a specific endpoint using different methods As you can see the REST API above is incomplete we only have the get delete and not found endpoints but it s enough to see some advantages of using Express so let s compare it with an Express version of the same application Create a new file app js app jsconst express require express const fs require fs const HOSTNAME localhost const PORT const DB PATH dirname database companies json const app express const getCompanies req res gt fs readFile DB PATH error data gt if error console error error res status end else res status send JSON parse data const deleteCompany req res gt const id req params fs readFile DB PATH error data gt if error console error error res status end else const companies JSON parse data const filteredData JSON stringify companies filter company gt company id id null fs writeFileSync DB PATH filteredData res status send JSON parse filteredData app get companies getCompanies app delete companies id deleteCompany app use req res gt res status send Not found app listen PORT HOSTNAME gt console log Server running Let s check the differences between the two versions Server listeningThe server does not need to specify the default value of localhost You can also use an extended version app listen PORT HOSTNAME gt console log Server running RoutesAs you can see the routes section is simplified cleaner and more readable Each route is declared with a function that uses the same name as the method being used e g the endpoint to list all companies is a get method and the endpoint to delete a particular company is a delete method All routes accept a function that receives the request and response objects app get companies req res gt Do something With this in mind we can isolate that logic within a function and pass the function directly app get companies req res gt getCompanies req res app get companies getCompanies For the deletion endpoint we need to know the id of the Company for that we can use identifiers with those identifiers will travel under req params identifierName where identifierName is id in this case Finally in case someone tries to access a route we don t have defined we define Not Found The app use method is a special method that we will cover in the next section ResponseIn the Node version we send back and end the communication with end method which still it s available but Express allows us to do in a simpler way res send data send will automatically set the Content Type for us Status codesSetting status codes is also easier with Express most of them will be handled automatically by Express but if you need to define something explicitly res status send data MiddlewaresRemember the app use we saved for later Now is the time Try pasting the app use lines at the beginning of the file put them before the other routes and see what happens when you make a request app jsapp use req res gt res status send Not found app get companies getCompanies app delete companies id deleteCompany app listen PORT HOSTNAME gt console log Server running As you can see now every request is responding with Not found because use is catching all requests and doing an action Now remove that and try these statements at the top of the file app jsapp use req res next gt console log I m watching you next app get companies getCompanies app delete companies id deleteCompany app use req res gt res status send Not found app listen PORT HOSTNAME gt console log Server running Now every request prints I m watching you first but executes correctly To understand why this happens you first have to learn about middlewares Middleware functions have access to the request and response object and are executed on every execution between a request and a response If you think about the definition you come to the conclusion that the whole Express is made up of middleware functions not just app use The difference with other functions like app get or app delete is that those functions are limited to those methods but app use is executed with any request Middleware functions have two possible exits continue to the next middleware function using next or make a response and terminate the chain In the diagram above you can see the following A request arrives at the server The first app use is executed and performs next The second app use is executed and performs next The request was a get method that asked for the path so the app get executes and sends a response Sending a response is what breaks the middleware chain so it is important to note the order Built in middlewaresIt is likely that if you are building a front end that submits data to a REST API to submit a form for example you will need to read those values In the past to do this we used an external middleware called body parser to read these values from the req body Nowadays this is already integrated in Express and is one of the built in middlewares app use express urlencoded extended true External middlewaresThere are lots of external packages for Express but earlier I mentioned morgan this package is just an external middleware that if I show you now how to use it you will understand the idea perfectly import morgan from morgan app use morgan dev Extending the capabilities of Express with external middleware as you can see is simple and clean Best practices MVCMVC stands for Model View Controller and is a well established software design pattern in different systems that can be useful here as well A graphical summary of what MVC is At this stage of the tutorial we will only use the Controller the Model we will add later when we define a model for the database and the View in this case is not applicable because we are not serving HTML from the server the view will be our React application in any case Even the lack of certain parts splitting our code following the MVC pattern is useful for readability and maintainability purposes so let s isolate all the different functions for manipulating data that we have seen before in the controller Under the controller folder we ll place the company js and joboffer js files with code similar to the following check out the example project for the full code controller company jsimport path from path import fs from fs const DB PATH path resolve database companies json const list req res gt fs readFile DB PATH error data gt if error console error error res status end else res status send JSON parse data const delete req res gt const id req params fs readFile DB PATH error data gt if error console error error res status end else const companies JSON parse data const filteredData JSON stringify companies filter company gt company id id null fs writeFileSync DB PATH filteredData res status send JSON parse filteredData export list delete The other methods can be found in the example project By doing so we have isolated the code relating to working with the data in a single file which we can then reuse as needed as in the next section Routes using routerThere is a better way to organise the routes especially now that we want to add another context so far we only talked about routes about company but now we want to add routes for job offer Let s use the router to organise the routes in a better way Inside the routes folder we ll place two files company js and joboffer js which will contain something similar to this code check the example project for the full code routes company jsimport express from express import list create details update remove from controller company const router express Router router get list router post create router get find id details router put id update router delete id remove export default router Let s check what happens there We use the Router function of Express With the router we can add routes in the same way as we did with app Finally we export the router Later we can use this router to define all routes import express from express import companyRoutes jobOfferRoutes from routes const app express routesapp use company companyRoutes app use job offer jobOfferRoutes With app use we define a context for that path this is entirely optional and add the paths we defined earlier The advantage of using the context is that the routes in the example above are simpler and easier to move between contexts So instead of declaring all your routes in your app js or whatever main file you have isolate them in their own files it will be easier and less error prone for other developers to modify in the future TypeScriptAs I said at the beginning of this guide TS can be useful in this project and if you check the example project is entery in TS in later stages of the guide it will be even more useful because of the type checking of the model but for now here are some benefits Clear data structure types tstype Company id string about string industries string name string numberEmployees string yearFounded number type JobOffer id string availablePositions number companyId string description string function string industry string location string numberApplicants number postDate Date published boolean requirements string salary number workType string export Company JobOffer Declaring the types of our objects gives us and other developers a snapshot of what we are talking about Looking at a single file you now have a clear picture of the form of the data which parameters are mandatory and which are optional This will be even more useful later but for now we can use these types in the controller to implement less error prone functions use IntelliSense efficiently and include these types in our tests Readable codeLet s check for an updated version of the remove function in the company s controller controller company tsimport Request Response from express import path from path import fs from fs import Company from types const DB PATH path resolve database companies json const remove req Request res Response gt const id req params const companies Company JSON parse fs readFileSync DB PATH toString const company Company undefined companies find company gt company id id const newCompanies Company companies filter company gt company id id if company fs writeFile DB PATH JSON stringify newCompanies null error gt if error console error error res status end else res status send message Company with id id removed else res status send message Company with id id not found Most of the types are inferred and it is not necessary to write it explicitly but I added it here so that it is better understood that we now know at each step what type of data we are handling and more importantly the IDE is checking that it follows that form Better understand of external toolsDo you see this in the previous example import Request Response from express const remove req Request res Response gt Good luck finding out what is inside the req and res params you will need to check the documentation or debug with TS you will automatically have access to the object form and documentation directly from the IDE this is one of the main reasons why I am currently using TS in my projects PublishLet s review what the different options are for publishing our backend so that it is accessible to others due to the current size of the guide I will keep this section as a summary but will consider making a more focused guide on this point if I feel it is necessary LocalOn a basic scale you already have a local environment for your node server but it is not available outside your current local network with this you may be able to test the server as we saw in the Postman section Nowadays it is less common to want to use your local machine as a server and if you prefer not to do that check the next sections but if you want to expose your local node server to the world you can use ngrock the introduction video on the landing page is self explanatory to be honest AWSYou can use Amazon Web Services to host your Node js application I will list the steps but I won t go into the details because using AWS requires some prior knowledge about AWS and is beyond the scope of this guide Request an Elastic Compute Cloud EC instance with Ubuntu for example Update the system Install Node js on the system as we did in the the Setup section for Ubuntu Clone your back end project or the example project from git Perform npm install amp amp npm start which will make the Node js server available This is a simple step by step for this guide there are actually better ways to deal with disconnects restarts and so on check out pm if you are more interested in this part Be careful with this option because AWS has a free tier but may have additional charges for usage HerokuOne of the easiest options and the one I will cover here in more detail is to use Heroku Heroku is a Platform as a Service PaaS that will simplify the process of having to configure your system to be visible from the outside and act as a server One of the cool things about Heroku is that we can do this kind of testing without any kind of credit card or fee so it s perfect for a guide like this and your first tests developing backends with Node js With the example project I needed to add a postinstall script for TypeScript so that Heroku compiles down to JS code before starting the server There are two ways to upload a back end project like the example project in this guide Heroku CLIHeroku provides a command line interface that we can use to deploy the project in a few steps First install the cli directly from npm npm install g herokuOnce installed we need to log in heroku login iIf you want to verify that everything works before uploading to Heroku you can check it with heroku local webweb will check your package json and look for the start script Once everything is verified let s create the project in Heroku and push it heroku creategit push heroku mainAfter create you will get the URL where it is stored and you are ready to go if you are using the example project you can try with your new url company for example In my case Directly on the web Once logged into Heroku in your dashboard select New and Create new app you can choose a name and a region Then you can select your project from github and deploy a specific branch Once deployed in Settings you can check the Domains section to see the url of your project if you are using the example project you can try your new url company for example In my case For a successful deployment you must have a start script in your package json in this case it will be the script to start the node server RailwayI found Railway during the process of this guide and I m quite surprised I try uploading the example project here and within seconds I have an instance ready to go even with a provisioned MongoDB available but that s for the next iteration of this guide I haven t tested this option in depth but I will try it with future iterations of this series because it seems convenient BONUS PostmanThroughout this guide you can test the different api rest endpoints directly in the browser or using curl but one tool that will make life easier for you and your co workers is Postman One of the main benefits of using Postman with your co workers or even on side projects for yourself is to easily define how to interact with your API provide examples and collaborate in the same workspace to maintain that collection There are also plenty of APIs available so you can test how things work and plan how to code anything before you start writing for example the Twitter API workspace Testing endpointsWith the example project I also provide a Postman collection you can use it as an example for your collection or to test the example project If you want to create a bunch of endpoints and test your own application it s as easy as selecting the request method and url For endpoints that have to carry data to the server they can be sent via params or the Body Postman provides a lot of information about the request and the response so you won t miss anything from the Developer Tools Network tab Creating examplesProviding examples in the Postman collection is a fantastic way to ensure that your colleagues or collaborators can see the shape of the data without actually running anything in a regular scenario this may not be necessary but when a service is behind a proxy authentications or even the service is not yet avialable it can be a good resource for developers to start coding their part To create a new example click on the three dots at the endpoint you want to add an example and select Add example Environment variablesAs in programming you can isolate your constants in environment variables to share different configurations and make it easier to modify the collection or test endpoints with different environments In the sample project collection you can find variables to run the endpoints on your local or directly to the published version on Heroku To use the environemnt provided to the Postman collection you must import the two jsons provided in the same folder which are environment json 2021-09-10 15:05:09
Apple AppleInsider - Frontpage News Apple not a monopoly but must allow alternate payment methods for apps, judge rules https://appleinsider.com/articles/21/09/10/apple-must-allow-developers-to-offering-alternate-payments-for-apps-judge-rules?utm_medium=rss Apple not a monopoly but must allow alternate payment methods for apps judge rulesAs a result of a ruling in the Epic versus Apple legal battle Apple must allow developers to include alternate purchase links in apps on the App Store ーbut Apple prevailed in most other counts A still from Epic s parody of Apple s Super Bowl commercialWhile the injunction did not demand that Apple make alternative App Stores mandatory the ruling is not what one would call a win for Apple Read more 2021-09-10 15:51:30
Apple AppleInsider - Frontpage News Best Deals Sept. 10 - Free Disney+ with Amazon Music, $5 Amazon credit with $50 Apple gift card, more! https://appleinsider.com/articles/21/09/10/best-deals-sept-10---free-disney-with-amazon-music-5-amazon-credit-with-50-apple-gift-card-more?utm_medium=rss Best Deals Sept Free Disney with Amazon Music Amazon credit with Apple gift card more Friday s best deals include off Roborock Vacuum and Mop Free Disney with Amazon Music off Uno Premium Anniversary Edition and more Deals Friday September Shopping online for the best discounts and deals can be an annoying and challenging task So rather than sifting through miles of advertisements check out this list of sales we ve hand picked just for the AppleInsider audience Read more 2021-09-10 15:25:35
海外TECH Engadget Judge issues permanent injunction on App Store model in Epic v. Apple case https://www.engadget.com/apple-epic-games-lawsuit-ruling-app-store-153113436.html?src=rss Judge issues permanent injunction on App Store model in Epic v Apple caseThe judge in the case between Apple and Epic Games has issued a permanent injunction against Apple The company must allow developers to direct users to other payment systems which would let them bypass the percent cut of in app payments Apple takes Engadget has contacted Apple and Epic Games for comment Judge Gonzales Rogers ruled in Epic s favor on one count She determined that Apple violated California s Unfair Competition law leading to the injunction which is set to take effect in days Under the injunction Apple is quot permanently restrained and enjoined quot from preventing developers to include in their apps and metadata quot buttons external links or other calls to action that direct customers to purchasing mechanisms in addition to In App Purchasing quot Apple also may not stop developers from quot communicating with customers through points of contact obtained voluntarily from customers through account registration within the app quot On every other count Judge Gonzales Rogers ruled in Apple s favor She also ruled against Epic in Apple s counterclaim for breach of contract As such Epic must pay Apple million That s equivalent to percent of the Epic earned from Fortnite iOS players between August and October through the Epic Direct Payment System Epic also has to pay Apple percent of the revenue it received via that system between November st and today Offering an alternative payment system was at the heart of Epic s case against Apple The former kicked off the legal fight in August when it informed Fortnite players on iOS and Android that they would receive a discount on in game goods if they bypassed Apple and Google s payment systems Both OS makers removed Fortnite from their app stores and Epic sued them both The Apple case went to trial in May Developing 2021-09-10 15:31:13
海外TECH Engadget WhatsApp rolls out end-to-end encryption for chat backups https://www.engadget.com/whats-app-end-to-end-encryption-for-backups-150954934.html?src=rss WhatsApp rolls out end to end encryption for chat backupsWhatsApp began quietly testing end to end encryption for chat history backups earlier this summer Now the company is making the feature official WhatsApp announced today that all users will be able to encrypt backups of their chat history While WhatsApp messages have been encrypted since the app hasn t offered end to end encryption of backups which rely on iCloud or Google Drive But with the latest update users will be able to opt in to end to end encryption for their backups before those backups hit their cloud storage service Users can expect the update “in the coming weeks according to the company Once end to end encryption is enabled “neither WhatsApp nor the backup service provider will be able to access the backup WhatsApp writes in a blog post Backups are encrypted with a “unique randomly generated encryption key Users will then be able to choose between two options manually storing the digit key or setting a password which can be used to access the key While the feature certainly makes backups more secure there are a few factors to keep in mind The first is that opting in means there will be no way to recover your backup should you lose the digit encryption key you are able to reset the password if you forget it Next is that even though WhatsApp recently announced support for multiple devices you ll only be able to use encrypted backups on your primary device It s also worth pointing out that end to end encryption doesn t guarantee your chats will never be used in a way you might not like This week ProPublica published a lengthy story on WhatsApp s use of human moderators who review chats that are reported by WhatsApp users And earlier this year The Information reported that Facebook may be researching AI that could one day allow it to serve users ads based on encrypted messages While neither of these “break the security offered by encryption ーand there are many very good reasons why people should be able to report abusive messages ーit s a good reminder that privacy is about much more than just the presence of end to end encryption 2021-09-10 15:09:54
海外TECH Engadget Apple TV+ acquires 'Yo Gabba Gabba' and is making new episodes https://www.engadget.com/apple-tv-yo-gabba-gabba-new-episodes-150839085.html?src=rss Apple TV acquires x Yo Gabba Gabba x and is making new episodesApple isn t just bringing brand new shows and movies to TV It s picking up some existing series to build out the library but it s selective about which ones to add After it became the home of Peanuts specials in Apple has acquired another notable kids show Yo Gabba Gabba All existing Yo Gabba Gabba episodes and specials are coming to Apple TV There are new half hour episodes being made for the service too as toMac notes Apple is working on the episodes with WildBrain and Yo Gabba Gabba LLC which co own the Yo Gabba Gabba IP Apple previously picked up Fraggle Rock and is rebooting the show with a new season It was a similar case with Ewan McGregor and Charley Boorman s travel docuseries Long Way Down and Long Way Round ーLong Way Up another show featuring the actors traveling across South and Central America on electric motorbikes debuted on Apple TV last year Meanwhile reports suggest Apple is ramping up its output for the streaming service According to The Information Apple plans to add at least one movie or TV show a week in which would more than double its pace of releases in The publication s sources also said the company is planning to spend north of million on Apple TV marketing this year 2021-09-10 15:08:39
海外科学 NYT > Science How California's Recall Vote Could Affect the State's Climate Policies https://www.nytimes.com/2021/09/08/climate/california-recall-newsom-climate.html How California x s Recall Vote Could Affect the State x s Climate PoliciesMany Republicans vying to replace Newsom as governor want to roll back the state s ambitious plans to cut planet warming emissions a change with nationwide implications 2021-09-10 15:40:11
海外TECH WIRED Twitch Sues Users Over Alleged ‘Hate Raids’ Against Streamers https://www.wired.com/story/twitch-sues-users-over-alleged-hate-raids Twitch Sues Users Over Alleged Hate Raids Against StreamersThe lawsuit accuses two anonymous users of “targeting black and LGBTQIA streamers with racist homophobic sexist and other harassing content in violation of its terms of service 2021-09-10 15:19:24
海外TECH WIRED WhatsApp Fixes Its Biggest Encryption Loophole https://www.wired.com/story/whatsapp-end-to-end-encrypted-backups biggest 2021-09-10 15:05:15
金融 RSS FILE - 日本証券業協会 特定口座の普及状況調査について https://www.jsda.or.jp/shiryoshitsu/toukei/tokuteikouzafukyu/index.html 状況 2021-09-10 17:00:00
金融 金融庁ホームページ 「2021年 保険モニタリングレポート」について公表しました。 https://www.fsa.go.jp/news/r3/hoken/20210910/20210910.html 保険 2021-09-10 17:00:00
金融 金融庁ホームページ 事業者の実情に応じた資金繰り支援等の徹底について金融機関に要請しました。 https://www.fsa.go.jp/news/r3/ginkou/20210910.html 資金繰り 2021-09-10 17:00:00
金融 金融庁ホームページ 第47回金融審議会総会・第35回金融分科会合同会合議事次第について公表しました。 https://www.fsa.go.jp/singi/singi_kinyu/soukai/siryou/2021_0913.html 金融審議会 2021-09-10 17:00:00
金融 金融庁ホームページ 審判期日の予定を更新しました。 https://www.fsa.go.jp/policy/kachoukin/06.html 期日 2021-09-10 16:00:00
金融 金融庁ホームページ 第一商品(株)における有価証券報告書の虚偽記載に対する課徴金納付命令の決定について公表しました。 https://www.fsa.go.jp/news/r3/shouken/20210910.html 有価証券報告書 2021-09-10 16:00:00
ニュース BBC News - Home Lucy-Anne Rushton murder detective jailed for witness signature forgery https://www.bbc.co.uk/news/uk-england-hampshire-58516654?at_medium=RSS&at_campaign=KARANGA woman 2021-09-10 15:21:13
ニュース BBC News - Home Clarkson's Farm: 'Swamped' village has seen more trade https://www.bbc.co.uk/news/uk-england-oxfordshire-58519620?at_medium=RSS&at_campaign=KARANGA chadlington 2021-09-10 15:19:45
ニュース BBC News - Home Cressida Dick: Met commissioner given two-year contract extension https://www.bbc.co.uk/news/uk-england-london-58518146?at_medium=RSS&at_campaign=KARANGA injustice 2021-09-10 15:00:55
ニュース BBC News - Home Local Hero phone box in Pennan to be kept in service https://www.bbc.co.uk/news/uk-scotland-north-east-orkney-shetland-58516327?at_medium=RSS&at_campaign=KARANGA boxes 2021-09-10 15:24:34
ニュース BBC News - Home 'Rafiq was victim of racial harassment & bullying' - Yorkshire release summary of report findings https://www.bbc.co.uk/sport/cricket/58514665?at_medium=RSS&at_campaign=KARANGA x Rafiq was victim of racial harassment amp bullying x Yorkshire release summary of report findingsAzeem Rafiq was the victim of racial harassment and bullying according to the findings of a report released by his former club Yorkshire 2021-09-10 15:17:31
サブカルネタ ラーブロ 21/243 AKEBI:つけめん、味玉、ちゃーしゅー http://feedproxy.google.com/~r/rablo/~3/G9w-r_7xUNc/single_feed.php akebi 2021-09-10 16:45:05
北海道 北海道新聞 日4―4ソ(10日) 日本ハム、今季16度目引き分け https://www.hokkaido-np.co.jp/article/588005/ 引き分け 2021-09-11 00:18:08
北海道 北海道新聞 紀子さま「長女の気持ちを尊重」 55歳誕生日、文書回答 https://www.hokkaido-np.co.jp/article/588049/ 紀子さま 2021-09-11 00:17:00
北海道 北海道新聞 タリバン、政権発足式中止 米同時テロ20年で計画か https://www.hokkaido-np.co.jp/article/588042/ 計画 2021-09-11 00:10:00
北海道 北海道新聞 自民若手「党におごり」 総裁選、信頼回復提言 https://www.hokkaido-np.co.jp/article/588041/ 信頼回復 2021-09-11 00:10: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件)