投稿時間:2023-05-01 16:18:19 RSSフィード2023-05-01 16:00 分まとめ(23件)

カテゴリー等 サイト名等 記事タイトル・トレンドワード等 リンクURL 頻出ワード・要約等/検索ボリューム 登録日
IT 気になる、記になる… PayPay、8月から利用可能なクレジットカードは「PayPayカード」のみに − 新規登録も7月より受付停止へ https://taisy0.com/2023/05/01/171368.html paypay 2023-05-01 06:51:09
IT ITmedia 総合記事一覧 [ITmedia Mobile] マイクロポンプ+冷却パイプ内蔵の水冷式スマホ「OnePlus 11 Concept」誕生 耳を当てると…… https://www.itmedia.co.jp/mobile/articles/2305/01/news122.html itmediamobile 2023-05-01 15:48:00
IT ITmedia 総合記事一覧 [ITmedia News] PayPayチャージ、携帯料金合算は手数料2.5%に 月2回目以降 「まとめて支払い」ユーザーに影響 https://www.itmedia.co.jp/news/articles/2305/01/news115.html itmedianewspaypay 2023-05-01 15:08:00
Docker dockerタグが付けられた新着投稿 - Qiita WSL2上のDockerでCakePHP4の開発環境を構築する https://qiita.com/yoyoyo4/items/8a778eb7e352965ec77b phpphalconmysqlnginx 2023-05-01 15:49:20
Ruby Railsタグが付けられた新着投稿 - Qiita Rails「A server is already running. Check /Users/me/environment/XXX/tmp/pids/server.pid.」の解決方法 https://qiita.com/amatouyamahodo/items/4ad3ecb37681807bcf84 rvergtbootingpumagtrails 2023-05-01 15:02:18
海外TECH DEV Community The Ultimate Guide to Mastering Full-Stack Development in 2023 https://dev.to/imsampro/the-ultimate-guide-to-mastering-full-stack-development-in-2023-15kp The Ultimate Guide to Mastering Full Stack Development in Full stack development is like the hottest thing in tech right now You can do both front end and back end stuff which makes you a total boss on any development team Apparently in everyone is gonna be looking for full stack peeps so we got you covered with this guide Whether you re just starting out or you re a pro trying to level up this guide has all the info you need to become a full stack superstar Understanding the Full Stack Development Landscape in What is Full Stack Development The technique of designing and creating all levels of a web application including the frontend backend and database is referred to as full stack development A full stack developer is knowledgeable in both frontend and backend technologies and is capable of creating a comprehensive web application from the ground up Why Full Stack Development is Important in Full stack development is now required for producing high performance responsive and scalable online apps in Companies want developers that can work across many technology stacks and produce end to end solutions Full stack developers can assist shorten a project s development cycle while preserving code quality The Latest Trends and Developments in Full Stack Development in Full stack development will migrate to microservices serverless architecture and containerization by In addition developers are experimenting with new frontend frameworks and libraries like as React Vue js and Angular as well as complex backend technologies such as GraphQL and Kubernetes The emphasis is on developing quicker more efficient and scalable applications utilizing cutting edge technology Essential Full Stack Development Tools Technologies and Frameworks to LearnBack End Development Technologies and FrameworksBackend technologies such as Node js Python Ruby Java and PHP are required for full stack developers They should also be familiar with popular frameworks like Express js Django Flask Rails and Laravel Front End Development Technologies and FrameworksFrontend developers must be knowledgeable with HTML CSS and JavaScript as well as current frontend frameworks like React Vue js and Angular They should also grasp the fundamentals of web design and user experience Full Stack Development Tools and PlatformsFull stack engineers must be familiar with development technologies like Git npm and Webpack They should also be comfortable implementing and scaling web applications on cloud platforms such as AWS Azure and Google Cloud Platform Building and Deploying Full Stack Applications Best Practices and StrategiesArchitecting a Full Stack ApplicationA well designed full stack application adheres to a microservices or serverless architecture with a clear separation of responsibilities between the frontend backend and database layers To ensure maintainability and extensibility it employs architectural patterns such as MVC or MVVM Managing and Versioning CodeFull stack engineers maintain source code and interact with other team members using version control systems such as Git To maintain code quality and uniformity they also employ code review systems like GitHub or GitLab Testing and Debugging Full Stack ApplicationsTo guarantee that the application is functional dependable and performs effectively under stress full stack developers employ automated testing tools such as Jest Mocha or Selenium To resolve any difficulties they also employ debugging tools such as Chrome DevTools or VSCode Debugger Deploying Full Stack Applications to the CloudFull stack developers should feel at ease delivering and growing web apps on cloud platforms like AWS Azure and Google Cloud Platform To make the deployment process more effective and simplified they should be conversant with containerization solutions such as Docker and Kubernetes Back End Development Fundamentals Databases APIs and Server Side FrameworksUnderstanding Databases for Full Stack DevelopmentFull stack engineers must grasp database fundamentals including SQL and NoSQL databases as well as how to connect with them using ORM frameworks like Sequelize or Mongoose Building APIs for Full Stack ApplicationsFull stack engineers must be capable of creating RESTful APIs in Node js or Python as well as leveraging popular API development frameworks like Express js or Flask Exploring Server Side Frameworks for Full Stack DevelopmentServer side frameworks like Django Rails and Laravel give a collection of tools and libraries to make development easier and code more manageable Full stack engineers should be familiar with and understand how to use these frameworks Front End Development Fundamentals HTML CSS JavaScript and Client Side FrameworksHTML and CSS Fundamentals for Full Stack DevelopmentOne of the first things you should learn to grasp full stack programming is the foundations of HTML and CSS HTML is in charge of the structure of web pages whereas CSS is in charge of style and appearance Learn about tags properties and how to format material on a web page with HTML CSS on the other hand teaches you how to style and arrange your HTML information Understanding these concepts is critical for producing functioning and visually attractive web pages JavaScript Fundamentals for Full Stack DevelopmentIf HTML and CSS serve as the foundation for front end development JavaScript serves as the framework for full stack development JavaScript is a computer language used to build interactive and dynamic web pages making it an important aspect of full stack development Variables data types functions and control structures are all important concepts to understand in JavaScript You could also look at frameworks for building client side apps such as React Angular and Vue Client Side Frameworks for Full Stack DevelopmentClient side frameworks are an important component of today s full stack development They are employed in the development of dynamic interactive and responsive online applications Client side frameworks that are popular include React Angular and Vue You ll need to learn how to work with these frameworks and how to leverage them to construct complicated apps if you want to master full stack programming You ll also want to learn about front end tools like Bootstrap and Foundation which may help you design beautiful and functional web pages Mastering Full Stack Development Tips Tricks and Resources to Help You SucceedBest Practices for Learning Full Stack DevelopmentLearning full stack development might be difficult but with the appropriate strategy you can achieve success Here are some best practices to remember Begin by studying the fundamentals of HTML CSS and JavaScript Concentrate on learning a single technology at a time Create projects to hone your talents Seek mentoring and advice from more experienced developers Keep up with the newest web development trends and technology Resources for Improving Full Stack Development SkillsThere are several resources available to assist you in honing your full stack development abilities Here are a few examples Online learning platforms such as Codecademy Udemy and Pluralsight Books such as JavaScript and jQuery Interactive Front End Web Development and Full Stack Development for Beginners YouTube tutorials from experts in the field such as Traversy Media and The Net Ninja Networking and learning opportunities at meetups and conferences Tips and Tricks for Mastering Full Stack Development in To stay ahead of the curve in full stack development keep the following tips and strategies in mind Keep your skills and knowledge up to date Concentrate on developing sophisticated apps to demonstrate your competence To remain inventive experiment with new technology and techniques Discover how to use databases and server side programming languages Connect with other developers to stay involved in the community Expert Advice and Insights from Full Stack Developers in Interview with Full Stack Developers on the State of Full Stack Development in I spoke with a panel of professional developers to gather insight into the situation of full stack development in Here are some of their observations Full stack development will remain in high demand with more firms seeking developers with a diverse set of abilities JavaScript will continue to be the dominating technology but other technologies like as WebAssembly and GraphQL will gain traction Artificial intelligence and machine learning will be implemented into online apps in the future As users become increasingly worried about data privacy and web page speed developers will need to focus on security and efficiency Insights and Perspectives from Full Stack Development ExpertsI asked individual developers for their ideas and perspectives on full stack development in addition to the expert panel Here are some of their opinions Full stack programming necessitates a thorough knowledge of both front end and back end technologies Because full stack engineers frequently collaborate with designers UX specialists and other developers collaboration and communication are vital Full stack development is difficult but it is also rewarding since it allows engineers to create complicated programs from start to end ConclusionSo to sum up if you want to be a full stack developer in you gotta have some technical skills best practices and experience under your belt Just follow the tips and resources in this guide and you ll be on your way to success And don t forget to keep up with the latest trends and keep learning With some hard work you can be a full stack development master in and beyond Frequently Asked Questions FAQ What is Full Stack Development The process of building both the front end and back end of an application or website is known as full stack development It entails collaborating with a variety of programming languages frameworks and technologies to develop a fully functional and dynamic online application What are the Benefits of Learning Full Stack Development Learning full stack development has various benefits including the ability to work on both the front end and back end of an application or website enhanced adaptability and marketability as a developer and a more in depth grasp of the whole development process What Tools and Technologies are Used in Full Stack Development Full stack development necessitates knowledge of several technologies including back end frameworks like Node js Python and Ruby on Rails front end languages like HTML CSS and JavaScript and client side frameworks like React and Angular What is the Job Outlook for Full Stack Developers in The job market for full stack engineers is predicted to be strong in As more businesses embrace a digital first strategy and demand for web and mobile apps grows the need for full stack developers is expected to rise The Bureau of Labor Statistics predicts that employment of web developers including full stack developers will rise substantially faster than the average for all occupations during the next decade Thank you for reading Soumyadeep Mandal imsampro 2023-05-01 06:51:48
海外TECH DEV Community 5 Tips to Optimize Your Ruby on Rails App's Performance https://dev.to/ahmadraza/5-tips-to-optimize-your-ruby-on-rails-apps-performance-248a Tips to Optimize Your Ruby on Rails App x s PerformancePerformance is a critical factor for any application and Ruby on Rails is no exception Slow performance can cause user frustration and even lead to decreased revenue Fortunately there are several ways to optimize the performance of your Ruby on Rails application Use CachingCaching is a simple and effective way to improve the performance of your application It stores frequently accessed data in memory so it can be quickly retrieved when needed In Ruby on Rails you can use the built in caching mechanisms such as Fragment Caching Action Caching and Page Caching Fragment Caching allows you to cache only specific parts of a page while Action Caching caches the entire action response and Page Caching caches the entire HTML page Optimize Database QueriesDatabase queries are often the biggest bottleneck in a Ruby on Rails application You can optimize your queries in several ways including Use includes method to eager load associated objectsUse select to retrieve only the necessary columnsUse joins to join tables and avoid N queriesUse pluck to retrieve only specific fields of a table Use Background JobsBackground jobs allow long running tasks to be performed asynchronously freeing up server resources and improving performance You can use tools like Sidekiq or Resque to handle background jobs in your Ruby on Rails application However I d recommend using Sidekiq Use a Content Delivery Network CDN A Content Delivery Network CDN can improve the performance of your application by caching and delivering content from servers located closer to the user This reduces latency and improves the user experience There are several CDN providers available such as Cloudflare Akamai and Amazon CloudFront Optimize Asset ManagementAssets such as images CSS and JavaScript files can significantly impact the performance of your application You can optimize asset management by compressing and minifying files using a Content Delivery Network CDN to serve static assets and using a tool like Asset Pipeline to compile and bundle your assets ConclusionOptimizing the performance of a Ruby on Rails application requires a combination of techniques and tools Caching optimizing database queries using background jobs using a Content Delivery Network and optimizing asset management can all help improve the performance of your application By implementing these techniques you can provide a faster and smoother experience for your users leading to increased engagement and revenue 2023-05-01 06:25:10
海外TECH DEV Community Authentication system using rust (actix-web) and sveltekit - File upload to AWS S3, Profile Update https://dev.to/sirneij/authentication-system-using-rust-actix-web-and-sveltekit-file-upload-to-aws-s3-profile-update-3b2a Authentication system using rust actix web and sveltekit File upload to AWS S Profile Update IntroductionWe have explored quite a handful of the technologies we set up to learn From extracting JSON data and session tokens from request objects in actix web to working with forms interactive UI elements and server side rendering with SvelteKit We still have some missing pieces however What about handling Multipart FormData in actix web How can we integrate the popular AWS S to our application to scalably manage its files images in this context These questions and many more will be addressed in this post Apologies if it s lengthy Source codeThe source code for this series is hosted on GitHub via Sirneij rust auth A fullstack authentication system using rust sveltekit and Typescript rust authA full stack secure and performant authentication system using rust s Actix web and JavaScript s SvelteKit This application resulted from this series of articles and it s currently live here Run locallyYou can run the application locally by first cloning it git clone After that change directory into each subdirectory backend and frontend in different terminals Then following the instructions in each subdirectory to run them View on GitHub ImplementationYou can get the overview of the code for this article on github Some changes were also made directly to the repo s main branch We will cover them Step Install and configure AWS S dependenciesAmazon Simple Storage Service Amazon S is a popular storage service provided by the cloud giant Amazon to provide dependable reliable scalable and performant object storage We ll be using this service to store our users thumbnails In rust working with AWS S has been made seamless by Amazon s official SDK for rust though still in Developer Preview mode Let s install the package and it s mandatory aws config aws config is important to properly configure the credentials necessary for interacting with AWS services To work with multipart forms and data in actix web actix multipart is needed rust auth backend cargo add aws config rust auth backend cargo add aws sdk s rust auth backend cargo add actix multipartNOTE Before proceeding ensure you have prepared an S bucket with their crdentials viz AWS ACCESS KEY ID AWS SECRET ACCESS KEY AWS REGION and AWS S BUCKET NAME Set the configurations in your env or env development file and ensure you do not push them to GitHub If you haven t created a credential kindly follow the S Bucket section of this guide After the installation create an uploads module in the backend and populate backend src uploads client rs with backend src uploads client rsuse tokio io AsyncReadExt as S client wrapper to expose semantic upload operations derive Debug Clone pub struct Client s aws sdk s Client bucket name String impl Client Construct S client wrapper pub fn new config aws sdk s Config gt Client Client s aws sdk s Client from conf config bucket name std env var AWS S BUCKET NAME unwrap pub fn url amp self key amp str gt String format https s amazonaws com key std env var AWS S BUCKET NAME unwrap std env var AWS REGION unwrap Facilitate the upload of file to s pub async fn upload amp self file amp actix multipart form tempfile TempFile key prefix amp str gt crate types UploadedFile let filename file file name as deref expect TODO let key format key prefix filename let s url self put object from file file file path to str unwrap amp key await crate types UploadedFile new filename key s url Real upload of file to S async fn put object from file amp self local path amp str key amp str gt String let mut file tokio fs File open local path await unwrap let size estimate file metadata await map md md len unwrap or try into expect file too big let mut contents Vec with capacity size estimate file read to end amp mut contents await unwrap let res self s put object bucket amp self bucket name key key body aws sdk s primitives ByteStream from contents send await expect Failed to put object self url key Attempts to delete object from S Returns true if successful pub async fn delete file amp self key amp str gt bool self s delete object bucket amp self bucket name key key send await is ok Using aws sdk s requires that tokio is installed The above code was drafted from actix forms with multipart and s example with few modifications There is a Client wrapper with two main endpoints upload and delete file upload uses put object from file to upload files to S and returns the uploaded files URLs while delete file deletes a file We also created some type in backend src types upload rs backend src types upload rs derive Debug serde Serialize Clone pub struct UploadedFile filename String s key String pub s url String impl UploadedFile Construct new uploaded file info container pub fn new filename impl Into lt String gt s key impl Into lt String gt s url impl Into lt String gt gt Self Self filename filename into s key s key into s url s url into This type makes the uploaded file s URL available for public consumption Now let s configure our credentials Open up backend src startup rs and add this function backend src startup rs async fn configure and return s client gt crate uploads Client S configuration and client Get id and secret key from the environment let aws key std env var AWS ACCESS KEY ID expect Failed to get AWS key let aws key secret std env var AWS SECRET ACCESS KEY expect Failed to get AWS secret key build the aws cred let aws cred aws sdk s config Credentials new aws key aws key secret None None loaded from custom env build the aws client let aws region aws sdk s config Region new std env var AWS REGION unwrap or eu west to string let aws config builder aws sdk s config Builder new region aws region credentials provider aws cred let aws config aws config builder build crate uploads Client new aws config We got our credentials from environment variables and used the S configuration builder to build them and thereafter return the Client wrapper previously discussed After that we can opt to create an app data for it so that every handler can access it backend src startup rs async fn run listener std net TcpListener db pool sqlx postgres PgPool settings crate settings Settings gt Result lt actix web dev Server std io Error gt For S client create singleton S client let s client actix web web Data new configure and return s client await S client app data s client clone That s it for the configuration We will utilize it in the next subsection NOTE Ensure you make all the modules connect That will help you to understand how to move things around If you get stuck check out the repo Step Write the user s profile update handler logicIn backend src routes users update user rs backend src routes users update user rsuse sqlx Row derive actix multipart form MultipartForm pub struct UserForm first name Option lt actix multipart form text Text lt String gt gt last name Option lt actix multipart form text Text lt String gt gt multipart limit MiB thumbnail Option lt actix multipart form tempfile TempFile gt phone number Option lt actix multipart form text Text lt String gt gt birth date Option lt actix multipart form text Text lt chrono NaiveDate gt gt github link Option lt actix multipart form text Text lt String gt gt derive serde Deserialize Debug pub struct UpdateUser first name Option lt String gt thumbnail Option lt String gt last name Option lt String gt derive serde Deserialize Debug pub struct UpdateUserProfile phone number Option lt String gt birth date Option lt chrono NaiveDate gt github link Option lt String gt derive serde Deserialize pub struct Thumbnail pub thumbnail Option lt String gt tracing instrument name Updating an user skip pool form session actix web patch update user pub async fn update users details pool actix web web Data lt sqlx postgres PgPool gt form actix multipart form MultipartForm lt UserForm gt session actix session Session s client actix web web Data lt crate uploads Client gt gt actix web HttpResponse let session uuid match crate routes users logout session user id amp session await Ok id gt id Err e gt tracing event target session tracing Level ERROR Failed to get user from session User unauthorized e return actix web HttpResponse Unauthorized json crate types ErrorResponse error You are not logged in Kindly ensure you are logged in and try again to string Create a transaction object let mut transaction match pool begin await Ok transaction gt transaction Err e gt tracing event target backend tracing Level ERROR Unable to begin DB transaction e return actix web HttpResponse InternalServerError json crate types ErrorResponse error Something unexpected happend Kindly try again to string At first set all fields to update to None except user id let mut updated user UpdateUser first name None last name None thumbnail None let mut user profile UpdateUserProfile phone number None birth date None github link None If thumbnail was included for update if let Some thumbnail amp form thumbnail Get user s current thumbnail from the DB let user current thumbnail match sqlx query SELECT thumbnail FROM users WHERE id bind session uuid map row sqlx postgres PgRow Thumbnail thumbnail row get thumbnail fetch one amp mut transaction await Ok image url gt image url thumbnail Err e gt tracing event target sqlx tracing Level ERROR Failed to get user thumbnail from the DB e None If there is a current image delete it if let Some url user current thumbnail let s image key amp url url find media unwrap or url len if s client delete file s image key await tracing event target backend tracing Level INFO We could not delete the current thumbnail of user with ID session uuid make key prefix make sure it ends with a forward slash let s key prefix format media rust auth session uuid upload temp files to s and then remove them let uploaded file s client upload thumbnail amp s key prefix await updated user thumbnail Some uploaded file s url If first name is updated if let Some f name form first name updated user first name Some f name If last name is updated if let Some l name form last name updated user last name Some l name If phone number is updated if let Some phone form phone number user profile phone number Some phone If birth date is updated if let Some bd form birth date user profile birth date Some bd If github link is updated if let Some gl form github link user profile github link Some gl Update a user in the DB match update user in db amp mut transaction amp updated user amp user profile session uuid await Ok u gt u Err e gt tracing event target sqlx tracing Level ERROR Failed to update user in DB e let error message crate types ErrorResponse error format User could not be updated e return actix web HttpResponse InternalServerError json error message let updated user match crate utils get active user from db None Some amp mut transaction Some session uuid None await Ok user gt tracing event target backend tracing Level INFO User retrieved from the DB crate types UserVisible id user id email user email first name user first name last name user last name is active user is active is staff user is staff is superuser user is superuser date joined user date joined thumbnail user thumbnail profile crate types UserProfile id user profile id user id user profile user id phone number user profile phone number birth date user profile birth date github link user profile github link Err e gt tracing event target backend tracing Level ERROR User cannot be retrieved from the DB e let error message crate types ErrorResponse error User was not found to string return actix web HttpResponse NotFound json error message if transaction commit await is err return actix web HttpResponse InternalServerError finish tracing event target backend tracing Level INFO User updated successfully actix web HttpResponse Ok json updated user tracing instrument name Updating user in DB skip transaction async fn update user in db transaction amp mut sqlx Transaction lt sqlx Postgres gt user to update amp UpdateUser user profile amp UpdateUserProfile user id uuid Uuid gt Result lt sqlx Error gt match sqlx query UPDATE users SET first name COALESCE first name last name COALESCE last name thumbnail COALESCE thumbnail WHERE id AND is active true AND IS NOT NULL AND IS DISTINCT FROM first name OR IS NOT NULL AND IS DISTINCT FROM last name OR IS NOT NULL AND IS DISTINCT FROM thumbnail bind amp user to update first name bind amp user to update last name bind amp user to update thumbnail bind user id execute amp mut transaction await Ok r gt tracing event target sqlx tracing Level INFO User has been updated successfully r Err e gt tracing event target sqlx tracing Level ERROR Failed to update user into DB e return Err e match sqlx query UPDATE user profile SET phone number COALESCE phone number birth date github link COALESCE github link WHERE user id AND IS NOT NULL AND IS DISTINCT FROM phone number OR IS NOT NULL AND IS DISTINCT FROM birth date OR IS NOT NULL AND IS DISTINCT FROM github link bind amp user profile phone number bind user profile birth date bind amp user profile github link bind user id execute amp mut transaction await Ok r gt tracing event target sqlx tracing Level INFO User profile has been updated successfully r Err e gt tracing event target sqlx tracing Level ERROR Failed to update user profile into DB e return Err e Ok Waoh What a long piece of code Let s go through it First we defined a UserForm struct which derives the actix multipart MultipartForm This is mandatory Since thumbnail is the file field we used TempFile and limited its size to MiB KiB ーthis was also the default size allowed in the put object from file method Other fields were either type String or chrono NaiveDate Notice that all the fields were made optional This is to ensure that only provided fields will be updated ーhence the use of the PATCH HTTP verb Moving on we used s client actix web web Data lt crate uploads Client gt as one of the parameters of the update users details handler definition This makes this handler access the methods embedded in it We also have form actix multipart form MultipartForm lt UserForm as against the actix web web Json lt gt we were used to This is because we are expecting multipart form data and not JSON data Inside the handler we first checked whether or not the requesting user is logged in From such a user s session we retrieve user id incepted a transaction block and initialized the data that will be saved in the database Next we checked whether a profile image was included in the request If it was we retrieve the current user s image delete it and then upload a new one such that the uploaded image s path will be media rust auth user id Then we checked whether other fields were included and each data was updated accordingly Next was the actual update in the DB This update used a separate abstraction update user in db We have two relatively optimised queries ーone updates the users table while the other user profile In the SQL queries we only opted to update either table only if a distinct value was supplied After the data were updated we then retrieved the updated user data using the get active user from db function located in backend src utils users rs backend src utils users rsuse sqlx Row tracing instrument name Getting an active user from the DB skip pool pub async fn get active user from db pool Option lt amp sqlx postgres PgPool gt transaction Option lt amp mut sqlx Transaction lt sqlx Postgres gt gt id Option lt uuid Uuid gt email Option lt amp String gt gt Result lt crate types User sqlx Error gt let mut query builder sqlx query builder QueryBuilder new crate queries USER AND USER PROFILE QUERY if let Some id id query builder push u id query builder push bind id if let Some e email query builder push u email query builder push bind e let sqlx query query builder build map row sqlx postgres PgRow crate types User id row get u id email row get u email first name row get u first name password row get u password last name row get u last name is active row get u is active is staff row get u is staff is superuser row get u is superuser thumbnail row get u thumbnail date joined row get u date joined profile crate types UserProfile id row get p id user id row get p user id phone number row get p phone number birth date row get p birth date github link row get p github link let fetched query if pool is some let p pool unwrap sqlx query fetch one p await else let t transaction unwrap sqlx query fetch one amp mut t await match fetched query Ok user gt Ok user Err e gt tracing event target sqlx tracing Level ERROR User not found in DB e Err e In this function we used yet another concept in SQLx called QueryBuilder It is very useful to dynamically construct queries at runtime In this case we used a prepared SQL query in backend src queries users rs backend src queries users rsSELECT u id AS u id u email AS u email u password AS u password u first name AS u first name u last name AS u last name u is active AS u is active u is staff AS u is staff u is superuser AS u is superuser u thumbnail AS u thumbnail u date joined AS u date joined p id AS p id p user id AS p user id p phone number AS p phone number p birth date AS p birth date p github link AS p github link FROM users u LEFT JOIN user profile p ON p user id u id WHERE u is active true AND to get user s entire data by LEFT JOINING the user profile table to the users table This ensures that all the data are retrieved once Then depending on whether an ID or e mail address was supplied we made some filtering and then built the builder Since either sqlx postgres Pool or sqlx Transaction lt sqlx Postgres gt instance is expected we dynamically set that also and finally execute the query which returns the user data Back to the main handler if everything goes well we commit all the changes and returned the user s data as a response That s it Long but easy to reason with After that we added the handler to our auth routes config in backend src routes users mod rs and voila our endpoint is up NOTE We created a new user type UserProfile and expanded the previous ones to accommodate that You can check out backend src types users rs for the updated types Step Current user handler logicApart from updating the users we may need to also get the current user using their session token and that was done in backend src routes users current user rs backend src routes users current user rs tracing instrument name Accessing retrieving current user endpoint skip pool session actix web get current user pub async fn get current user pool actix web web Data lt sqlx postgres PgPool gt session actix session Session gt actix web HttpResponse match crate routes users logout session user id amp session await Ok id gt match crate utils get active user from db Some amp pool None Some id None await Ok user gt tracing event target backend tracing Level INFO User retrieved from the DB actix web HttpResponse Ok json crate types UserVisible id user id email user email first name user first name last name user last name is active user is active is staff user is staff is superuser user is superuser date joined user date joined thumbnail user thumbnail profile crate types UserProfile id user profile id user id user profile user id phone number user profile phone number birth date user profile birth date github link user profile github link Err e gt tracing event target backend tracing Level ERROR User cannot be retrieved from the DB e let error message crate types ErrorResponse error User was not found to string actix web HttpResponse NotFound json error message Err e gt tracing event target session tracing Level ERROR Failed to get user from session User unauthorized e actix web HttpResponse Unauthorized json crate types ErrorResponse error You are not logged in Kindly ensure you are logged in and try again to string As usual we retrieved the user s ID from the session and used it to retrieve the user s data using the get active user from db function discussed previously Pretty basic We also added it to auth routes config to make it accessible Step Deploy changes to fly ioHaving made these changes it s time to deploy them We had already laid a solid foundation for that What we only need to do is set our secret credentials for AWS S to fly io rust auth backend flyctl secrets set AWS REGION lt your bucket region gt rust auth backend flyctl secrets set AWS S BUCKET NAME lt your bucket name gt rust auth backend flyctl secrets set AWS SECRET ACCESS KEY lt your access key gt rust auth backend flyctl secrets set AWS ACCESS KEY ID lt your access id gt After that you can then deploy rust auth backend fly deployThat s it Your changes are live and ready to be consumed In the next article we will build our front end to do just that See ya OutroEnjoyed this article Consider contacting me for a job something worthwhile or buying a coffee You can also connect with follow me on LinkedIn and Twitter It isn t bad if you help share this article for wider coverage I will appreciate it 2023-05-01 06:24:43
医療系 医療介護 CBnews 財務省、地域医療構想の早急な実現求める-「進捗みられない」と指摘 https://www.cbnews.jp/news/entry/20230501143038 地域医療 2023-05-01 15:40:00
医療系 医療介護 CBnews XBB系統の割合が3週連続で上昇、7割超に-東京都ゲノム解析結果 https://www.cbnews.jp/news/entry/20230501143053 新型コロナウイルス 2023-05-01 15:10:00
金融 JPX マーケットニュース [TOCOM]最終決済価格(2023年4月限):原油、電力 https://www.jpx.co.jp/markets/derivatives/special-quotation/index.html tocom 2023-05-01 15:15:00
金融 日本銀行:RSS 気候変動対応を支援するための資金供給オペレーションの対象先公募について http://www.boj.or.jp/mopo/measures/select/s_release/srel230501a.htm 気候変動 2023-05-01 16:00:00
海外ニュース Japan Times latest articles A new journey: Reviving Japan’s hospitality industry https://www.japantimes.co.jp/news/2023/05/01/business/hospitality-industry-revival/ waves 2023-05-01 15:30:35
海外ニュース Japan Times latest articles Alibaba founder Jack Ma joins University of Tokyo as professor https://www.japantimes.co.jp/news/2023/05/01/national/jack-ma-tokyo-visiting-professorship/ Alibaba founder Jack Ma joins University of Tokyo as professorAs a visiting professor he will provide advice on research topics and conduct research especially in sustainable agriculture as well as give seminars about entrepreneurship 2023-05-01 15:28:13
ニュース BBC News - Home Ukraine war: Russia launches second pre-dawn missile attack in three days https://www.bbc.co.uk/news/world-europe-65446525?at_medium=RSS&at_campaign=KARANGA attack 2023-05-01 06:21:11
ニュース BBC News - Home Nurses across England strike in biggest walkout so far https://www.bbc.co.uk/news/health-65443943?at_medium=RSS&at_campaign=KARANGA cancer 2023-05-01 06:36:40
ニュース BBC News - Home Capita: Watchdog warns pension funds over data after hack https://www.bbc.co.uk/news/business-65443841?at_medium=RSS&at_campaign=KARANGA capita 2023-05-01 06:29:11
ニュース BBC News - Home UK chip giant Arm files for blockbuster US share listing https://www.bbc.co.uk/news/business-65445428?at_medium=RSS&at_campaign=KARANGA blockbuster 2023-05-01 06:12:54
ニュース BBC News - Home Jock Zonfrillo: MasterChef Australia host dies suddenly, aged 46 https://www.bbc.co.uk/news/world-australia-65446351?at_medium=RSS&at_campaign=KARANGA australia 2023-05-01 06:34:42
ニュース BBC News - Home Aberystwyth uni told student was suicidal before his death https://www.bbc.co.uk/news/uk-wales-65423997?at_medium=RSS&at_campaign=KARANGA laney 2023-05-01 06:20:33
ビジネス ダイヤモンド・オンライン - 新着記事 中国、外国企業への圧力強化 歓迎ムードどこへ - WSJ発 https://diamond.jp/articles/-/322483 外国企業 2023-05-01 15:27:00
IT 週刊アスキー 高田馬場にて本格eスポーツ施設「ASH WINDER Esports ARENA高田馬場店」2023年夏開業 https://weekly.ascii.jp/elem/000/004/135/4135294/ ashwinder 2023-05-01 15:30:00
IT 週刊アスキー ペッパーフードサービス、5月8日よりPayPayポイントが最大5%還元されるキャンペーンを実施 https://weekly.ascii.jp/elem/000/004/135/4135293/ paypay 2023-05-01 15:15: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件)