Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/MicrosoftDocs/mslearn-module-shifting-nodejs-express-apis-to-serverless
Code samples for mslearn-module-shifting-nodejs-express-apis-to-serverless
https://github.com/MicrosoftDocs/mslearn-module-shifting-nodejs-express-apis-to-serverless
Last synced: 18 days ago
JSON representation
Code samples for mslearn-module-shifting-nodejs-express-apis-to-serverless
- Host: GitHub
- URL: https://github.com/MicrosoftDocs/mslearn-module-shifting-nodejs-express-apis-to-serverless
- Owner: MicrosoftDocs
- License: mit
- Created: 2020-03-11T23:48:12.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2024-04-15T15:45:30.000Z (7 months ago)
- Last Synced: 2024-07-31T19:54:49.689Z (3 months ago)
- Language: TypeScript
- Size: 25.8 MB
- Stars: 42
- Watchers: 6
- Forks: 26
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
- Security: SECURITY.md
Awesome Lists containing this project
README
---
page_type: sample
name: Refactor Node.js Express APIs into serverless Azure Functions APIs
languages:
- javascript, typescript
products:
- azure
- vs-code
- azure-functions
---# β‘Refactor Node.js Express APIs into serverless Azure Functions APIs
[![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MicrosoftDocs/mslearn-module-shifting-nodejs-express-apis-to-serverless)
[![Refactor Node.js APIs Azure Functions](/resources/refactor-nodejs-azure-functions.png)](https://learn.microsoft.com/en-us/training/modules/shift-nodejs-express-apis-serverless/)
> This repository contains the source code for the [Refactor Node.js Express APIs into serverless Azure Functions APIs](https://learn.microsoft.com/en-us/training/modules/shift-nodejs-express-apis-serverless/) module.
## π« Overview
This project was created to help represent a fundamental app written with Node Express APIs and TypeScript that can be shifted to serverless functions with TypeScript.
The client-side (Front-end) app is `Angular`. However, it could just as easily be `Vue` or `React`. The `vacation` theme is used throughout the app.
by [John Papa](http://twitter.com/john_papa)
## π§ Technologies/Tools used
- β **[Visual Studio Code](https://code.visualstudio.com/?WT.mc_id=javascript-120166-gllemos)**
- β **[Visual Studio Code Extension Marketplace](https://marketplace.visualstudio.com/vscode)**
- β **[Node.js](https://nodejs.org/)**
- β **[Visual Studio Code Extension for Node on Azure](https://marketplace.visualstudio.com/items?itemName=ms-vscode.vscode-node-azure-pack&WT.mc_id=javascript-120166-gllemos)**
- β **[TypeScript](https://www.typescriptlang.org/)**
- β **[Angular](https://angular.io/)**
- β **[Express.js](https://expressjs.com/)**
- β **[Azure Functions](https://azure.microsoft.com/services/functions/?WT.mc_id=javascript-120166-gllemos)**
- β **[Azure Functions Core Tools](https://docs.microsoft.com/azure/azure-functions/functions-run-local?WT.mc_id=javascript-120166-gllemos)**
- β **[Azure Functions extension for Visual Studio Code](https://marketplace.visualstudio.com/items?itemName=ms-azuretools.vscode-azurefunctions&WT.mc_id=javascript-120166-gllemos)**
- β **[Azure Free Trial](https://azure.microsoft.com/free/?WT.mc_id=javascript-120166-gllemos)**## βWhy
I love Node.js and Express.js for creating APIs! These require a server and paying for that server in the cloud. Shifting to serverless alleviates the cost of server upkeep, helps scale up and down easily, and reduces the surface area of the middleware required for a robust Express app. Is it perfect? No, of course not! But this is a solid option if these factors affect you.
## π― Prerequisites
Make a copy of the `env.example` file named `.env`, in the root of the project. It should contain the following code.
`.env`
```bash
NODE_ENV=development
PORT=7070
WWW=./
```## π Getting Started
1. Clone this repository
```bash
git clone https://github.com/MicrosoftDocs/mslearn-module-shifting-nodejs-express-apis-to-serverless learn-functions
cd learn-functions
```1. Install the npm packages
```bash
npm install
```1. Build the Node.js, Express.js and the Angular code
```bash
npm run full:build
```1. Run the app
```bash
npm run node:start
```## π Debug Node.js, Express.js and Angular
1. Stop any debugging sessions that may be currently running
1. Open `proxy.conf.json` and set the port to `7070`
1. Open the VS Code Command Palette `F1`
1. Type `View: Show Debug` and press `ENTER`
1. Select `Debug Express and Angular`
1. Press `F5`
1. Open the browser to
You may now set break points in the Express and Angular code.
## π Debug Functions and Angular
1. Stop any debugging sessions that may be currently running
1. Open `proxy.conf.json` and change the port to `7071`
1. Open the VS Code Command Palette `F1`
1. Type `View: Show Debug` and press `ENTER`
1. Select `Debug Functions and Angular`
1. Press `F5`
1. Open the browser to
You may now set break points in the Functions and Angular code.
## π Problems or Suggestions
[Open an issue here](/issues)
## π Important Resources
- β **[Documentation: Quickstart: Create a JavaScript function in Azure using Visual Studio Code](https://learn.microsoft.com/azure/azure-functions/create-first-function-vs-code-node?pivots=nodejs-model-v4&WT.mc_id=javascript-120166-gllemos)**
- β **[Documentation: Quickstart: Create a JavaScript function in Azure from the command line](https://learn.microsoft.com/en-us/azure/azure-functions/create-first-function-cli-node?tabs=windows%2Cazure-cli%2Cbrowser&pivots=nodejs-model-v4)**
- β **[Documentation: Quickstart: Create a function in Azure with TypeScript using Visual Studio Code](https://learn.microsoft.com/azure/azure-functions/create-first-function-vs-code-typescript?pivots=nodejs-model-v4&WT.mc_id=javascript-120166-gllemos)**
- β **[Documentation: Quickstart: Create a TypeScript function in Azure from the command line](https://learn.microsoft.com/en-us/azure/azure-functions/create-first-function-cli-typescript?tabs=windows%2Cazure-cli%2Cbrowser&pivots=nodejs-model-v4)**
- β **[Documentation: Deploy - Continuous delivery by using GitHub Actions](https://learn.microsoft.com/en-us/azure/azure-functions/functions-how-to-github-actions?tabs=windows%2Cdotnet&pivots=method-manual)**
- β **[Step by Step Guide: Migrating v3 to v4 programming model for Azure Functions for Node.Js Application](https://techcommunity.microsoft.com/t5/educator-developer-blog/step-by-step-guide-migrating-v3-to-v4-programming-model-for/ba-p/3897691?WT.mc_id=javascript-120166-gllemos)**
- β **[Visual Studio Code - macOS keys](https://code.visualstudio.com/shortcuts/keyboard-shortcuts-macos.pdf?WT.mc_id=javascript-120166-gllemos)**
- β **[Visual Studio Code - Windows keys](https://code.visualstudio.com/shortcuts/keyboard-shortcuts-windows.pdf?WT.mc_id=javascript-120166-gllemos)**
### π Debugging Resources
- β **[Debugging Angular in Visual Studio Code](https://code.visualstudio.com/docs/nodejs/angular-tutorial?WT.mc_id=javascript-120166-gllemos)**
- β **[Debugging React in Visual Studio Code](https://code.visualstudio.com/docs/nodejs/reactjs-tutorial?WT.mc_id=javascript-120166-gllemos)**
- β **[Debugging Vue in VS Code](https://code.visualstudio.com/docs/nodejs/vuejs-tutorial?WT.mc_id=javascript-120166-gllemos)**
- β **[Tasks in Visual Studio Code](https://code.visualstudio.com/Docs/editor/tasks?WT.mc_id=javascript-120166-gllemos)**
## βπ» Next steps & Free Courses
Because learning is a never-ending journey, we want to help you as much as we can to get you ready for what's coming next. You'll find here a great collection of resources you can use to build your knowledge.
- β **[Build a Node.js app for Azure Cosmos DB in Visual Studio Code](https://docs.microsoft.com/learn/modules/build-node-cosmos-app-vscode?WT.mc_id=javascript-120166-gllemos)**
- β **[Automate Node.js deployments with Azure Pipelines](https://docs.microsoft.com/learn/modules/deploy-nodejs/?WT.mc_id=javascript-120166-gllemos)**
- β **[Create serverless applications](https://learn.microsoft.com/training/paths/create-serverless-applications/?WT.mc_id=javascript-120166-gllemos)**
- β **[Authenticate users with Azure Static Web Apps](https://learn.microsoft.com/training/modules/publish-static-web-app-authentication/?WT.mc_id=javascript-120166-gllemos)**
- β **[Publish an API to Azure Static Web Apps](https://learn.microsoft.com/training/modules/publish-static-web-app-api-preview-url/?WT.mc_id=javascript-120166-gllemos)**
- β **[Expand query and transaction functionality in Azure Cosmos DB for NoSQL](https://learn.microsoft.com/training/modules/expand-query-transaction-functionality-azure-cosmos-db-sql-api/?WT.mc_id=javascript-120166-gllemos)**
## π» Contributing
This project welcomes contributions and suggestions. Most contributions require you to agree to a
Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us
the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.When you submit a pull request, a CLA bot will automatically determine whether you need to provide
a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions
provided by the bot. You will only need to do this once across all repos using our CLA.This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or
contact [[email protected]](mailto:[email protected]) with any additional questions or comments.## βοΈLegal Notices
Microsoft and any contributors grant you a license to the Microsoft documentation and other content
in this repository under the [Creative Commons Attribution 4.0 International Public License](https://creativecommons.org/licenses/by/4.0/legalcode),
see the [LICENSE](LICENSE) file, and grant you a license to any code in the repository under the [MIT License](https://opensource.org/licenses/MIT), see the
[LICENSE-CODE](LICENSE-CODE) file.Microsoft, Windows, Microsoft Azure and/or other Microsoft products and services referenced in the documentation
may be either trademarks or registered trademarks of Microsoft in the United States and/or other countries.
The licenses for this project do not grant you rights to use any Microsoft names, logos, or trademarks.
Microsoft's general trademark guidelines can be found at http://go.microsoft.com/fwlink/?LinkID=254653.Privacy information can be found at https://privacy.microsoft.com/en-us/
Microsoft and any contributors reserve all other rights, whether under their respective copyrights, patents,
or trademarks, whether by implication, estoppel or otherwise.