How to Create an API with TypeScript on AWS with Serverless

Поделиться
HTML-код
  • Опубликовано: 2 дек 2024

Комментарии • 72

  • @itmeurdad
    @itmeurdad 4 года назад +3

    The quality and effort put into this video really stands out. I've learned more from this 24 minutes than the last few hours of self guided Serverless research.

    • @CompleteCoding
      @CompleteCoding  4 года назад +1

      Thanks Jake, that means a lot. Hope you get to build some really cool projects with serverless

  • @SadathIqbal
    @SadathIqbal 2 года назад +2

    Absolutely great work! Concise and touches all the key areas nicely. The way you communicate and structure things make it very easy to understand!

  • @RajeshYadav-bg6dy
    @RajeshYadav-bg6dy 4 года назад +2

    I really appreciate your serverless work.

  • @xq_nemesis
    @xq_nemesis 4 года назад

    I admire people who can tolerate working with two different type of monitors

    • @CompleteCoding
      @CompleteCoding  3 года назад

      haha thanks. You're the first person to notice/comment on this

  • @nuruddinshaik960
    @nuruddinshaik960 2 года назад

    Superb the video is in simple and more understandable. Thank you lots of love from India❤️. And wish me happy Independence day.

  • @21sebas12
    @21sebas12 3 года назад

    Thanks, thanks thanks!!, incredible video tutorial easy to interpret and easy English. Well done!

  • @z4ckfytc777
    @z4ckfytc777 2 года назад

    Thank you for this tutorial! It helped me a lot

  • @niccodev7704
    @niccodev7704 4 года назад +2

    Great tutorial, thank you! It'd be great to see more content about JS and AWS :)
    I'd have one question: when would you choose to go for the Serverless framework (with AWS) over AWS Amplify (and vice versa)?

    • @CompleteCoding
      @CompleteCoding  4 года назад +1

      I've got a whole playlist of videos that use AWS and JS to build some really powerful features. ruclips.net/p/PLmexTtcbIn_gP8bpsUsHfv-58KsKPsGEo
      Serverless vs Amplify -
      Serverless is a tool to deploy AWS features and services without having to write cloudformation. This could be APIs, Lambdas, databases, step functions.
      Amplify (using appSync) is a tool to allow you to quickly and easily add authentication, databases and storage to your app. All of your logic lives in the app.
      If you're building something where you need to add a relatively simple database table to the app - use Amplify. If you want to have lot of inter-related tables, use other AWS Services ( SES, SQS, translate, comprehend, VPCs, EC2s ) and want to build APIs to take a lot of the logic and code complexity out of your front end code then use Serverless.

    • @niccodev7704
      @niccodev7704 4 года назад

      @@CompleteCoding Wow, thank you so much for your time to answer and your thorough explanation, now it's much clearer.
      I'll definitely need to check your playlist, as I'd like to get started with AWS services :)

  • @dcabib
    @dcabib 4 года назад

    Amazing... Thanks for this class... I really enjoy it... Congratulations

  • @RakeshBitling
    @RakeshBitling 2 года назад

    Expecting more industry oriented videos

    • @CompleteCoding
      @CompleteCoding  2 года назад +1

      Like what?
      Videos describing how I'd architect certain apps?

  • @jiansu
    @jiansu 4 года назад

    this is so amazing. i thank you for your hard work~! i will be ur first student when ur course come out!

    • @CompleteCoding
      @CompleteCoding  4 года назад +2

      Thanks, hearing that you're loving the content makes it worth while.
      I've actually got a free course here - covers building a small full-stack app skl.sh/3arTBrp

  • @lauraochoa96
    @lauraochoa96 3 года назад

    This video is awesome! Thank you!!

  • @PaulliMr
    @PaulliMr 2 года назад

    Great tutorial, and I'd like to add a quick advice to make it even better. If you're making tutorial on how to create AWS API endpoint with Serverless, don't bother explaining why Typescript is good or what is interface just stick to the topic. Anyway, good work thank you!

    • @CompleteCoding
      @CompleteCoding  2 года назад

      Thanks. I already have a video on creating APIs with Serverless (and JS). This was specifically as I have been asked about using typescript. As it needs to be compiled there are some extra steps and plugins

  • @prerakhere
    @prerakhere Год назад

    Awesome. Just wanted to clarify one query of mine -
    Are AWS profiles meant to have access control over different resources? For example, say profile p1 has access to S3, p2 has access to dynamoDB, etc. Am I right?

    • @CompleteCoding
      @CompleteCoding  Год назад

      It depends on what you're using the AWS Profile for. AWS Profiles should only really be used for systems outside of AWS that need to interact with AWS. I only use AWS Profiles for deploying my CloudFormation stacks.
      If you've got a Lambda or an EC2 that needs to access S3 or Dynamo, you should be using IAM roles. You say what that IAM role can and can't do and then attach it to the lambda or EC2.

  • @TheVitkuz
    @TheVitkuz 4 года назад +1

    Why did they change yml to ts extention in serverless configuration file?

    • @CompleteCoding
      @CompleteCoding  4 года назад +2

      I think that it was just so the code and the config is all in the same style. Having type checking on the serverless file is actually really useful.

  • @himanshutariyal8782
    @himanshutariyal8782 2 года назад

    Great video, just one question, can we remove the "/dev" from our endpoints that are automatically added by the template somehow. Since I would not like all my apis to look like "/dev/user/get" and all

    • @CompleteCoding
      @CompleteCoding  2 года назад +1

      There are two ways.
      Either replace the api type with a "http" Event in the lambda definition
      Or create a custom domain name. You can set that so you don't have the "/dev" in your url

  • @darshanb.c.3441
    @darshanb.c.3441 2 года назад

    Amazing videos in your channel, can you make a video on Testing with typescript

    • @CompleteCoding
      @CompleteCoding  2 года назад

      I have a video on testing lambda and dynamo. It would be almost identical with typescript.
      ruclips.net/video/k-rOgqiGe34/видео.html

  • @igoralves1
    @igoralves1 2 года назад

    Is it necessary in a functional paradigm? One function should handle a unique process. If you overload your repository with many files you will end up with coldstart issues.

    • @CompleteCoding
      @CompleteCoding  2 года назад

      One unique process per lambda is ideal. With typescript and esbuilds, only the code required for each lambda will end up in that lambda deployment.
      If you start approaching the cloudformation 500 resource limit you can make 'multi-process' Lambdas but that's only a short term solution to creating multiple stacks

  • @CVenture
    @CVenture 4 года назад

    Great..Helpful video. Thanks.

  • @ricardogiovani8522
    @ricardogiovani8522 2 года назад

    Thanks!
    Could you indicate how you have configured the webpack.config.js file please

    • @CompleteCoding
      @CompleteCoding  2 года назад +1

      if you follow this video and use "aws-nodejs-typscript" template, it now uses "ES-Builds". This is way better than webpack.

    • @prerakhere
      @prerakhere Год назад

      @@CompleteCoding thanks for this heads up

  • @Godiio7
    @Godiio7 4 года назад

    Absolutely amazing

  • @ethanlloyd21
    @ethanlloyd21 3 года назад

    I was having some CORS issue with this code. I can access the API using multiple browser and POstman but when I actually integrate the code on my web application it is giving me this error:
    has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
    I set the cors: true on the serverless.ts

    • @CompleteCoding
      @CompleteCoding  3 года назад +1

      In the response body you also need to set the headers of
      {
      statusCode: XXX,
      body: { ... },
      headers: {
      => 'Access-Control-Allow-Origin': '*'
      }
      }

  • @kkwilson27
    @kkwilson27 4 года назад

    Sam, is the code for this video on Github? I can't seem to find it. I am getting an error with serverlessConfiguration in serverless.ts and I would like to compare yours to mine.
    Error: Property 'configValidationMode' is missing in type '{ service: { name: string; }; frameworkVersion: string; custom: { webpack: { webpackConfig: string; includeModules: boolean; }; }; plugins: string[]; provider: { name: "aws"; runtime: string; apiGateway: { ...; }; environment: { ...; }; }; functions: { ...; }; }' but required in type 'Serverless'

    • @AmirulAbu1
      @AmirulAbu1 4 года назад +1

      just add this in serverless.ts -> configValidationMode: "error",

    • @kkwilson27
      @kkwilson27 4 года назад

      @@AmirulAbu1 Thank you.

    • @CompleteCoding
      @CompleteCoding  4 года назад

      It looks like @Amirul Abu sorted this one for you. Does it now work?

  • @lordpablo1985
    @lordpablo1985 3 года назад

    We use cloud formation and nested stacks with typical javascript code. If we switched to typescript would we need to pre compile to es6 javascript or is there a way to do it automatically?

    • @CompleteCoding
      @CompleteCoding  3 года назад +1

      The way this project is set up, it compiles to es6 on deployment.
      If you're adding/updating to typescript with an existing stack then you'll need to compile before deploying.
      I add a build script of "deploy": "tsc && sls deploy" to my package.json and then just run "npm run deploy" instead of 'sls deploy'

  • @theacid1
    @theacid1 4 года назад

    Why is it creating a serverless.ts file and not a serverless.yml file ? And could you somehow go back to a serverless.yml file?

    • @CompleteCoding
      @CompleteCoding  4 года назад

      As you are creating a typescript repo, the template assumes you'd rather work with a serverless.ts file. I've not tried reverting to serverless.yml but I don't see why it shouldn't work.

  • @DaveLampton
    @DaveLampton 4 года назад

    Can you please link to your cityData in the description? Thnx.

  • @RajeshYadav-bg6dy
    @RajeshYadav-bg6dy 4 года назад

    I hope sometime in the future you will make an introductory video on AWS-Kinesis for microservices.

    • @CompleteCoding
      @CompleteCoding  4 года назад

      I'll add it to the list and look into it

    • @WhyteTunez
      @WhyteTunez 3 года назад

      @@CompleteCoding where / how did you get the serverless command?

    • @CompleteCoding
      @CompleteCoding  3 года назад

      @@WhyteTunez npm i -g serverless
      That will allow you to use the serverless CLI

    • @WhyteTunez
      @WhyteTunez 3 года назад

      Thank you ...

  • @christophersantos4833
    @christophersantos4833 3 года назад +1

    Optional chaining will return undefined if the property doesn't exist instead of null. Here's the link to it: developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Optional_chaining.
    Anyway, thank you for this great content. Keep it up!

  • @djaos-8326
    @djaos-8326 4 года назад

    is possible combinate nestjs framework with serverless typescript framework ? maybe a project with typescript as standard language

    • @CompleteCoding
      @CompleteCoding  4 года назад +1

      That's a really cool idea. I'll look into it and add it to the video idea list

  • @johnwilliams7999
    @johnwilliams7999 3 года назад

    How do you unit test that service,

    • @CompleteCoding
      @CompleteCoding  3 года назад

      You can create a unit test for the lambda code you've written. Use jest to call the handler function with an example 'event' and then check that the response is what you expect.
      If you add aws services (dynamo, SES, s3) then you can mock those so your unit tests stay as unit tests

  • @antonioguiotto3487
    @antonioguiotto3487 3 года назад

    what is your color theme?

    • @CompleteCoding
      @CompleteCoding  3 года назад

      Monokai Pro. I think it was $10 but it's just a really nice theme in my opinion and well worth it

  • @shahidabbas2932
    @shahidabbas2932 2 года назад

    sir i want to ask a question please reply me...? i really need your help

    • @CompleteCoding
      @CompleteCoding  2 года назад +1

      What's your question?

    • @shahidabbas2932
      @shahidabbas2932 2 года назад

      @@CompleteCoding aws-typescript-node template schema validation not working with local dynamodb. how to properly validate schema before saving to dynamodb (local as well as real dynamodb) the schema.ts file which we got in template (lambda function) how do we apply proper validation in this file like min max length , email pattern,required etc.