Code Monkey home page Code Monkey logo

mongoose-starter's Introduction

Static Web Apps - Mongoose starter

This template is designed to be a starter for creating React apps 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 deployment

Please refer to the documentation for information on creating the appropriate server resources and deploying the project.

Important

Two environmental variables are required for the project:

  • AZURE_COSMOS_CONNECTION_STRING: The connection string to the database server
  • AZURE_COSMOS_DATABASE_NAME: The name of the database

These can be stored in application settings in Azure Static Web Apps. When developing locally, the project will default to using MongoDB running on localhost.

Local development

You can run the project locally using containers by following the local setup instructions.

Project structure

This starter project is designed to be a template for React with Redux and hosted on Azure Static Web Apps. It uses the Redux Toolkit. The project is a Todo application using authentication for Azure Static Web Apps. Todo items are collected in lists, and are scoped to individual users. To use the application:

  1. Login using GitHub by clicking the login link.
  2. Create a list.
  3. Create todo items for the list.

package.json scripts

  • dev: Starts the SWA CLI, Azure Functions and the React app. The application will be available on http://localhost:4280

src/app

Contains store.js, which manages global state for the application.

src/features

Contains three "features", one each for items, lists and user. lists and items contain a slice to manage their respective state and a React component.

api

Root folder for Azure Functions. All new serverless functions are added to this directory.

api/config

Contains the configuration for the database. Two environmental variables are required for the project:

  • AZURE_COSMOS_CONNECTION_STRING: The connection string to the database server
  • AZURE_COSMOS_DATABASE_NAME: The name of the database

These can be stored in application settings in Azure Static Web Apps. When developing locally, the project will default to using MongoDB running on localhost. You can change the default values by updating default.json.

api/models

Contains the two Mongoose models, TodoItemModel and TodoListModel. It also contains store.js, which exposes helper functions for CRUD operations.

mongoose-starter's People

Contributors

hannahzhuswe avatar khowling avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.