Giter VIP home page Giter VIP logo

todo-vanillajs's Introduction

A Simple Todo App with Fauna

Note
This repository contains unofficial patterns, sample code, or tools to help developers build more effectively with Fauna. All Fauna Labs repositories are provided "as-is" and without support. By using this repository or its contents, you agree that this repository may never be officially supported and moved to the Fauna organization.

This repo contains a single-page HTML file with embedded JavaScript that implements a simple web-based todo application.

The embedded JavaScript automatically creates a Todos collection and then shows any available todos. Use the input field to create a new todo. For listed todos, you can toggle their done state or delete them.

Each action triggers a Fauna query that creates, updates, or deletes a todo document, respectively.

Important

This code is provided for educational purposes. It is simple and it works.

However, embedding database secrets into HTML would be considered bad practice for production applications, and you should never do this.

Dependencies

  • A Fauna secret, which authorizes queries for a specific database. To acquire a secret:

    1. Log into the Fauna Dashboard. Sign up if you do not already have an account (it’s free!).

    2. Select, or create, a database.

    3. In the Security section, create a new key with the "admin" role. A secret is shown. Copy that to a safe place; a secret is only displayed once.

  • Fauna JavaScript driver: This is fetched from a CDN (you need an internet connection).

  • http-server: A Node.js web server so you can view the todo app locally.

Note that once you create a todo, you can visit the Fauna Dashboard and navigate to the database associated with the secret, and view the "Todos" collection to see the todos. You can manage todo documents in the Dashboard; when you refresh the app, you’ll see the changes.

Usage

  1. Clone this repo.

  2. Enter the clone’s directory.

  3. Run npm i to install http-server.

  4. Edit the index.html file and on line 25, replace the YOUR_FAUNA_SECRET text with your Fauna secret, then save the file.

  5. Run npm run serve to start http-server and view the application in your web browser.

Copyright Fauna, Inc. or its affiliates. All rights reserved. SPDX-License-Identifier: MIT-0

todo-vanillajs's People

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.