
Join the Conversation!
Subscribing gives you access to the comments so you can share your ideas, ask questions, and connect with others.
"Please login to view comments"
Subscribing gives you access to the comments so you can share your ideas, ask questions, and connect with others.
How did you manage to remove the blur property and reach here?
Upgrading gives you access to quizzes so you can test your knowledge, track progress, and improve your skills.
By logging in, you'll unlock full access to this and other free tutorials on JSM Pro.
Why? Logging in lets us personalize your learning experience, track your progress, and keep you in the loop with new workshops, coding tips, and platform updates.
You'll also be the first to know about upcoming launches, events, and exclusive discounts.
No spam—just helpful content to level up your skills.
If that sounds fair, go ahead and log in to continue →
Enter your name and email to get instant access
##Looks like we found a thief monkey By the way, I liked the trick how you reached till here. You have a good sense of humor. You will improve a lot if you join our course with this passion.
var
(function-scoped, outdated)let
(block-scoped, modern and recommended)const
(block-scoped, cannot be reassigned)_
, or $
let let = 5;
is invalid)myVar
and myvar
are different)string
, number
, boolean
, null
, undefined
, bigint
, symbol
Objects
, Arrays
, Functions
Subscribing gives you access to a brief, insightful summary of each lecture to stay on track.
00:00:02 we'll use an HTTP client called HTTPy to test our API endpoints.
00:00:07 It's a tool I recently discovered as an alternative to Postman, and I've been really enjoying it.
00:00:11 We have three main endpoints, one for users and one for subscriptions.
00:00:17 And for each one of them, you'll create dedicated controllers, or in other words, logic that makes them work.
00:00:24 So, starting off, we have a regular route route endpoint.
00:00:28 If you just make a GET request to localhost 5500, you can see welcome to the subscription tracker API.
00:00:34 But now, let's say that someone wants to spam our API and bring our server down.
00:00:38 Well, I'll teach you how to stop them.
00:00:40 Let's keep spamming our API, and if you do that for a couple of times, very soon you'll be hit with a rate limit exceeded.
00:00:48 This means that you'll stop bad users from making additional requests and crashing your server.
00:00:52 On top of that, we'll also implement a bot protection system that'll block them from accessing your API.
00:00:59 all of that using ArcJet.
00:01:00 Now, let's test another API endpoint so I can show you some of the functionalities.
00:01:04 I'll make a POST request to api v1 auth signup, and I'll send some user info as the request body.
00:01:12 Now, if I click send, you can see that a new user has been created successfully.
00:01:17 And the first thing we get back in the data is a JSON web token.
00:01:21 So yeah, we'll implement that as well.
00:01:23 Now, if you want to see your profile, you can make a GET request to API v1 users, and then you have to enter the user ID,
00:01:32 which we got from here.
00:01:33 So let me just do that and remove the body.
00:01:37 And if I click Send and if you make a request, you'll get a 401, unauthorized, which means that we have a complete authorization system implemented.
00:01:45 But now, if you copy the JWT that you got when creating your account and paste it right here as the bearer token and retry the request,
00:01:53 we get back all the user info.
00:01:55 You can also get a list of all the users just by going to API V1 users.
00:02:00 But what matters most is creating new subscriptions.
00:02:04 We can do that by targeting our API V1 subscriptions and then making a POST request to it.
00:02:11 And of course, we have to send the right request body where we specify the name of the subscription, the price, the currency,
00:02:18 frequency, start date, and the payment method.
00:02:21 and let's create it.
00:02:23 And in just a second, a new subscription has been created.
00:02:27 And before we create this new subscription, we also have this special logic to auto-calculate the renewal date if it's missing.
00:02:33 So what's happening behind the scenes is we take the start date, and then based on the frequency, we automatically calculate the renewal date.
00:02:41 And don't get fooled here.
00:02:43 If you pass any random values, let's say a random currency which doesn't exist, and try to create it, you'll immediately see a validation error,
00:02:52 which means that you'll learn how to do full validation of your APIs.
00:02:56 But maybe the most important thing is that as soon as you create your subscription, an automated workflow kicks in, sending you multiple email reminders
00:03:05 a week before your renewal date.
00:03:06 That way, you have plenty of time to decide whether you want to keep the subscription or cancel it.
00:03:12 No surprises.
00:03:13 Check this out.
00:03:14 I just got an email that tells me exactly when my subscription renews, along with all of my details and the payment method.
00:03:20 Pretty cool, right?
00:03:21 And just like that, you'll receive the rest of the emails automatically for every subscription you create.
00:03:27 It's a real-world solution to a common problem No more stressing about remembering when to unsubscribe or manually setting your calendar reminders.
00:03:35 Just enter your subscription details, sit back, and relax.
00:03:39 By the time you finish building this amazing production-ready API, you'll have learned how to deploy, scale, and show it off to potential employers.
00:03:47 So let's stop talking and start building.
00:03:50 We'll first need to set up a couple of things to make all of this work.
00:03:54 This will allow us to focus on coding without any distractions.
00:03:58 First, let's set up UpStash, a serverless platform that allows us to implement Redis, scheduling, and workflows.
00:04:05 For example, apps like Duolingo send automated emails to onboard new users and remind them to keep learning.
00:04:12 That's an onboarding workflow.
00:04:13 Subscription services like Netflix send reminders about payment renewals before the charge happens.
00:04:19 That's a subscription workflow.
00:04:21 And today, I'll teach you how to build something similar.
00:04:24 a workflow that sends reminders about upcoming subscription payments.
00:04:28 That way, you can cancel subscriptions early and save money instead of waiting until the last minute of the last hour of the last day,
00:04:35 and you may end up paying eventually.
00:04:36 This is just one of the use cases of what Upstash allows us to do, so let's quickly set it up.
00:04:42 Click the link in the description to follow along and see exactly what I'm seeing, and then create a new account.
00:04:48 Once you do that, we'll be able to grab all of the environment variables we need to make this work.
00:04:53 We'll store them somewhere securely very soon.
00:04:55 It's super simple to set up and the implementation won't be any different.
00:04:59 Now, the second thing we'll set up is called ArcJet.
00:05:01 Once again, the link is in the description, so just click it to follow along.
00:05:05 as it'll allow you to secure your whole application within a few lines of code in a few minutes.
00:05:11 Remember that rate limiting or bot protection I was telling you about?
00:05:14 We'll do it using ArcGed.
00:05:15 So just sign up for free and create a new project.
00:05:18 I called mine Subscription Tracker.
00:05:21 And the last thing to set up is the hosting.
00:05:24 For the first time ever, I'm going to go against easy hosting services and I'll teach you how to deploy your app on a hostinger VPS.
00:05:32 A virtual private server is like having your own computer on the cloud or some other physical location in the world, but without the high cost of a physical machine.
00:05:42 You'll get dedicated resources, full control, and complete customization, allowing you to run applications just the way you want.
00:05:50 And it's not just for hosting APIs.
00:05:52 You can deploy full stack applications, run databases, train AI models, or set up game servers, automate tasks, or even experiment with new technologies
00:06:02 without worrying it'll break your device.
00:06:04 But why should you care?
00:06:06 You might think, I can just use Versel, Render, or even Heroku.
00:06:10 And yeah, they're great when you're just starting out.
00:06:13 They handle setup, maintenance, and scaling for you.
00:06:16 But that's not always how things work in the real world.
00:06:20 Hosting on a VPS might sound like an overkill, but it'll actually teach you real-world skills that companies expect of you.
00:06:28 You'll get hands-on experience with server management, database backup, and real-world deployments.
00:06:34 Skills that most tutorials skip because they're super hard, but also super needed.
00:06:39 Also, unlike regular shared hosting, where millions of people host their apps on the same server, A VPS will give you much better performance because it's
00:06:49 only made for you.
00:06:50 So, let's set it up.
00:06:51 You know very well that I use Hostinger for all of my hosting needs.
00:06:55 They recently launched VPS hosting for Node.js applications.
00:06:59 So, click the link in the description to be able to follow along and see exactly what I'm seeing.
00:07:05 you'll get your own dedicated server with lots of RAM, SSD storage, worldwide data centers, and a Linux operating system,
00:07:13 which we'll use to set up our server.
00:07:15 And the best part?
00:07:16 It costs less than a Udemy course.
00:07:18 But having the knowledge of deploying your apps on there?
00:07:22 Priceless for potential employers.
00:07:24 In our case, the one-core plan is going to be more than enough.
00:07:27 So click the link down in the description and select it.
00:07:30 Choose the period of your hosting.
00:07:32 and enter a coupon code.
00:07:35 Since you're a part of JSM, Hostinger is offering you an even bigger discount.
00:07:39 Continue with the payment and I'll see you on the inside.
00:07:42 In your dashboard, you'll see some kind of an onboarding and at the end of the day, you'll have your own machine running somewhere in the world.
00:07:50 Don't go through the onboarding now because we'll go through it together later on once we develop our app and once we're ready to host it.
00:07:57 Okay, wasn't too difficult, right?
00:07:59 Let me know in the comments if you'd like to set up things before getting started, like what we have done right now, or you prefer the usual process of
00:08:07 setting up things in between.
00:08:08 But for now, we have everything we need, so let's dive right into the code.