Code Monkey home page Code Monkey logo

nav's Introduction

Navigation Website

A small navigation website.

banner

Features

  • Data storage based on Google Sheets.
  • API based on Vercel Serverless Functions.
  • Data cache use LocalStorage & ServiceWorker.

Deploy

  1. Fork this project.
  2. Create a new project in vercel dashboard and connect to your project.
  3. Create Google Cloud platform credentials keyFile & extract client_email, private_key field. set sheet name to Sheet1.
  4. Set environment variables in the project dashboard.

ENV

Environment variables required by the project.

Key Value Description
TOKEN String access token
CLIENT_EMAIL String credentials keyFile client_email field
PRIVATE_KEY String credentials keyFile private_key field

Note:

  • Recommended TOKEN env is generated use crypto.randomBytes(16).toString('hex')
  • Environment variables are best added using the vercel client, use the Web UI can be problematic

WebUI Operation

  1. Click the setting button to fill in SheetID & Token field.
  2. Click the Add Link button to add website infomation.
  3. Start your navigation website.

APIs

{domain}/api/list get

Get all data in data storage.

Parameter Type Description isRequired?
sheetId String sheetId of Google Sheets required
token String access token required
const result = await axios.get(`${domain}/api/list`, {
  params: {
    token: "74e1dcd881627ee5efa73340324ee47f",
    sheetId: "f82452e3e4979a0a02d2a1ca6c7d74e41959fd6212d2",
  }
});

console.log(result); // output log: [{ name: 'example', icon: 'https://example.com/logo.png', desc: 'this is demo', link: 'https://example.com', category: 'demo' })]

{domain}/api/extract post

Parse the metadata of the website.

Parameter Type Description isRequired?
link String website link required
token String access token required
const result = await axios.post(
  `${domain}/api/extract`,
  {
    link: "https://www.google.com",
    token: "74e1dcd881627ee5efa73340324ee47f"
  }
);

console.log(result); // output log: { name: 'example', icon: 'https://example.com/logo.png', desc: 'this is demo' }

{domain}/api/add post

Add data to data storage.

Parameter Type Description isRequired?
sheetId String sheetId of Google Sheets required
token String access token required
link String website link required
name String website name required
icon String website icon required
desc String website description optional
category String website category optional
const result = await axios
  .post(
    `${domain}/api/add`,
    {
      name: "Example",
      icon: "https://example.com/logo.png",
      desc: "This is demo",
      link: "https://example.com",
      category: "demo",
      token: "74e1dcd881627ee5efa73340324ee47f",
      sheetId: "f82452e3e4979a0a02d2a1ca6c7d74e41959fd6212d2"
    }
  )

console.log(result); // response status: 200

{domain}/api/update post

Update data to data storage.

Parameter Type Description isRequired?
sheetId String sheetId of Google Sheets required
token String access token required
link String website link required
name String website name required
icon String website icon required
desc String website description optional
category String website category optional
const result = await axios
  .post(
    `${domain}/api/update`,
    {
      name: "Example",
      icon: "https://example.com/logo.png",
      desc: "This is demo",
      link: "https://example.com",
      category: "demo",
      token: "74e1dcd881627ee5efa73340324ee47f",
      sheetId: "f82452e3e4979a0a02d2a1ca6c7d74e41959fd6212d2"
    }
  )

console.log(result); // response status: 200

{domain}/api/delete post

Delete data from data storage.

Parameter Type Description isRequired?
link String website link required
token String access token required
sheetId String sheetId of Google Sheets required
const result = await axios.post(
  `${domain}/api/delete`,
  {
    link: "https://www.google.com",
    token: "74e1dcd881627ee5efa73340324ee47f",
    sheetId: "f82452e3e4979a0a02d2a1ca6c7d74e41959fd6212d2",
  }
);

console.log(result); // output log: { name: 'example', icon: 'https://example.com/logo.png', desc: 'this is demo' }

Related Documentation

Vercel functions using environment variables

Create Google Cloud platform credentials keyFile

License

MIT.

nav's People

Contributors

2046 avatar simmzl 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.