A small navigation website.
- Data storage based on Google Sheets.
- API based on Vercel Serverless Functions.
- Data cache use LocalStorage & ServiceWorker.
- Fork this project.
- Create a new project in vercel dashboard and connect to your project.
- Create Google Cloud platform credentials keyFile & extract
client_email
,private_key
field. set sheet name toSheet1
. - Set environment variables in the project dashboard.
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 usecrypto.randomBytes(16).toString('hex')
- Environment variables are best added using the vercel client, use the Web UI can be problematic
- Click the setting button to fill in
SheetID
&Token
field. - Click the Add Link button to add website infomation.
- Start your navigation website.
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' })]
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' }
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
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
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' }
Vercel functions using environment variables
Create Google Cloud platform credentials keyFile
MIT.