Fireship · @fireship

Nest on Cloud Functions

Uploaded August 16, 2019 · Length 4:23

Nest on Cloud Functions

Summary

Combine Nest.js with Cloud Functions for scalable server-side applications.

  • nestjs
  • cloud functions
  • firebase
  • nodejs
  • serverless

Transcript preview

The first 2 minutes of the transcript. Select a timestamp to watch that moment on YouTube.

  1. 0:00

    Nest j/s and firebase cloud functions

  2. 0:02

    both are awesome tools for node

  3. 0:03

    developers and today you'll learn how to

  4. 0:05

    combine the two together but first I'd

  5. 0:07

    like to welcome you to a new series

  6. 0:08

    called the more you code where we'll

  7. 0:10

    cover highly specialized topics in about

  8. 0:12

    two to three minutes and the reason I'm

  9. 0:14

    creating this series is because I have a

  10. 0:15

    massive list of video ideas that just

  11. 0:17

    don't really fit into the 10 to

  12. 0:19

    15-minute format that YouTube prefers so

  13. 0:21

    rather than be a slave to the YouTube

  14. 0:22

    algorithm I'm going to release some

  15. 0:24

    shorter videos that hopefully you find

  16. 0:26

    useful so let me know what you think

  17. 0:27

    about that idea in the comments because

  18. 0:28

    I'll be giving away another t-shirt with

  19. 0:30

    this video and congrats to Paul boma who

  20. 0:32

    is last week's winner so let's just go

  21. 0:34

    ahead and get right into it

  22. 0:35

    we have nest which is a nodejs framework

  23. 0:38

    for building scalable server-side

  24. 0:39

    applications and then we have cloud

  25. 0:41

    functions which is the actual

  26. 0:42

    infrastructure that allows a server-side

  27. 0:44

    application to scale infinitely sounds

  28. 0:46

    like a pretty good match if you ask me

  29. 0:48

    so let's look at two different ways we

  30. 0:50

    can combine these two technologies

  31. 0:51

    together friends who were majestic

  32. 0:54

    translucent seeds shooting flaming

  33. 0:56

    arrows I would follow you into the Mists

  34. 1:01

    of Avalon that's me

  35. 1:03

    the first option will look at starts

  36. 1:05

    with a nest application and then brings

  37. 1:07

    in cloud functions the second option

  38. 1:09

    will do the exact opposite start with a

  39. 1:11

    functions project and then bring in nest

  40. 1:13

    so this first option is ideal if you

  41. 1:15

    have an existing nest app that you want

  42. 1:17

    to deploy cloud functions so we'll go

  43. 1:19

    ahead and generate a new nest

  44. 1:20

    application then from the parent

  45. 1:22

    directory we'll go ahead and initialize

  46. 1:23

    firebase functions we don't actually

  47. 1:25

    want the functions directory so just go

  48. 1:27

    ahead and delete it now by default the

  49. 1:29

    firebase functions environment will be

  50. 1:31

    looking for the functions directory so

  51. 1:33

    we'll want to go into the firebase JSON

  52. 1:35

    and change the source to server or

  53. 1:37

    whatever the name of your nest

  54. 1:38

    application is and then we'll want to

  55. 1:40

    install the dependencies that we would

  56. 1:41

    normally use in the functions

  57. 1:43

    environment like firebase functions

  58. 1:44

    admin Express and then also nest Jas

  59. 1:47

    platform Express now when cloud

  60. 1:49

    functions attempts to run your code it

  61. 1:51

    will be looking for the main field in

  62. 1:52

    the package.json and we'll set that up

  63. 1:54

    as the dist index.js file and then

  64. 1:57

    you'll also want to set the node engine

  65. 1:59

    to 8 or 10 or whatever version you want