This project is designed to be a starter creating sites using Azure Static Web Apps, with Azure Cosmos DB API for Mongo DB as a database and a Mongoose client. It's built with the following:
- Azure resources
- Application libraries
- Vanilla JavaScript
- Mongoose
- Azure Functions
- Development libraries
Please refer to the documentation for information on creating the appropriate server resources and deploying the project.
You can run the project locally using containers by following the local setup instructions.
This starter project is heavily commented and designed to be both a template and learning tool. The key files you'll want to be aware of:
At the root of the project is package.json, which consists of a dev script for starting the server, and references to both Vite and Azure Static Web Apps CLI to enable running the project locally.
Configuration file for Vite, which instructs the service to use public as the root for the client.
Root folder for the client and index.html, style.css and script.js. script.js contains the code to interact with the server and is heavily commented.
Root folder for Azure Functions. All new serverless functions are added to this directory.
The data store for the project. Contains one Mongoose model for TaskModel
, methods for interacting with the database, and logic to start the MongoDB Memory Server if no connection string is provided.
NOTE: Note the environment variable of
CONNECTION_STRING
. This must be set for the application to use an external database.
The code for Azure Functions is placed in a folder for each function and named index.js. It contains the code to get the current user information and use connect to the database and perform the operation.