0:00 So in this lecture, we're gonna start creating our underlying 0:03 jobs in the jobs 0:04 microservice. Now, to do this, we're gonna create a new type of class 0:07 that's gonna 0:08 represent a given job, and these classes are gonna be 0:12 decorated with a custom decorator that we're gonna apply. 0:15 And then we're gonna utilize a custom service to actually retrieve all 0:19 of these decorated jobs later on, so that we can trigger the appropriate 0:23 job with a given HTTP request. 0:26 So let's go ahead and get started with this by firstly 0:29 creating 0:30 this custom decorator that we're gonna be applying to our 0:33 underlying 0:34 jobs. 0:35 So in our jobs directory, I'll create a new folder 0:39 inside of app. We'll call this Decorators. 0:46 So in here, we'll create this new 0:48 jobdecorator.ts, 0:51 and now let's go ahead and create this new custom decorator. 0:55 Now, NestJS makes custom decorators extremely 0:58 easy with some helper 0:59 functions. We go ahead and export the decorator here, 1:03 so export const job is equal to a function. 1:07 So this function is going to accept a parameter, and that is going to be any 1:11 argument supplied to the decorator when we actually declare the 1:15 decorator later on. Now, I want to go ahead and define 1:19 this 1:20 decorator metadata as a separate type. 1:23 So what we can do is in the app directory, we'll also create an 1:27 interfaces folder. 1:30 And so in here, let's create this new 1:33 jobmetadata.interface 1:40 file. 1:43 So this will export an interface called Job Metadata. 1:47 And so in here, we're gonna take in two properties 1:49 that each job is going to have 1:51 as of now. Firstly, we'll declare the name for the job type 1:55 string, so what's the name gonna be, and a brief description of the 1:59 underlying job. Later on, we'll extend this definition to 2:03 accept additional parameters. For now, let's go ahead and leave this as just
The rest of the transcript is for members.
Sign in