This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 引用 axios | |
importScripts('../dist/axios.min.js'); | |
// 設定最大並行請求數限制 | |
const MAX_CONCURRENT_REQUESTS = 5; | |
let activeRequests = 0; | |
let queue = []; | |
self.onmessage = e => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const gitLabToken = '請貼上 GitHub Access Token'; | |
const postmanApiKey = '請貼上 Postman API Key'; | |
// 以下請貼上要匯進 Postman Collection 的清單 | |
const repoList = [ | |
{ | |
projectId: '48419806', | |
filePath: 'Postman_Collections/postman-backup-demo.json' | |
} | |
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const postmanApiKey = '請貼上 Postman API Key'; | |
const githubToken = '請貼上 GitHub Access Token'; | |
const repoOwner = '請貼上 GitHub 帳號名稱'; | |
// 以下請貼上要匯進 Postman Collection 的清單 | |
const repoList = [ | |
{ | |
repoName: 'postman-backup-demo', | |
filePath: 'Postman Collections/postman-backup-demo.json' | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 存進雲端 | |
function saveJsonToDrive({ name, json }) { | |
const today = getToday({ divider: '-' }); | |
const folderName = name; // 資料夾名稱 | |
const time = new Date().getTime(); | |
const fileName = `${time}_backup.json`; // 檔案名稱 | |
// 取得「備份」資料夾 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const express = require('express'); | |
const cors = require('cors'); | |
const app = express(); | |
const fileupload = require('express-fileupload'); | |
app.use(fileupload(), cors()) | |
const jsftp = require('jsftp'); | |
const Ftp = new jsftp({ | |
host: '這邊填FTP的主機', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'idempotent-babel-polyfill'; | |
// POST 給後端的 URL | |
const uploadUri = 'https://www.example.tw/uploadFileToFTP'; | |
// 處理每一個 POST | |
function fileUploadHandler(file) { | |
return new Promise((resolve, reject) => { | |
let formData = new FormData(); | |
formData.append('clientFile', file); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { getAuth, getRedirectResult, GithubAuthProvider } from "firebase/auth"; | |
const auth = getAuth(); | |
const providerGithub = new GithubAuthProvider(); | |
getRedirectResult(auth) | |
.then((result) => { | |
const credential = GithubAuthProvider.credentialFromResult(result); | |
if(credential) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { getAuth, signInWithPopup, GithubAuthProvider } from "firebase/auth"; | |
const auth = getAuth(); | |
const providerGithub = new GithubAuthProvider(); | |
signInWithPopup(auth, providerGithub) | |
.then((result) => { | |
const credential = GithubAuthProvider.credentialFromResult(result); | |
const token = credential.accessToken; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { getAuth, signInWithPopup, FacebookAuthProvider } from "firebase/auth"; | |
const auth = getAuth(); | |
const providerFb = new FacebookAuthProvider(); | |
signInWithPopup(auth, providerFb) | |
.then((result) => { | |
const credential = FacebookAuthProvider.credentialFromResult(result); | |
const accessToken = credential.accessToken; | |
const user = result.user; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { getAuth, getRedirectResult, GoogleAuthProvider } from "firebase/auth"; | |
const auth = getAuth(); | |
const providerGoogle = new GoogleAuthProvider(); | |
getRedirectResult(auth) | |
.then((result) => { | |
const credential = GoogleAuthProvider.credentialFromResult(result); | |
const token = credential.accessToken; | |
const user = result.user; |
NewerOlder