-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from shaniit-org/dev
Minor fix and tweaks
- Loading branch information
Showing
4 changed files
with
36 additions
and
3 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{} |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/** @type {import('./$types').RequestHandler} */ | ||
export async function GET() { | ||
/* | ||
const query = `{ | ||
'term': *[_type == 'random_terms'][0..10]{title,description,slug,_createdAt}, | ||
}`; | ||
// create file named dateSync | ||
const file = `dateSync`; | ||
const fileExists = fs.existsSync(file); | ||
if (!fileExists) { | ||
fs.writeFileSync(file, new Date().toISOString()); | ||
} | ||
// get time difference between now and last sync | ||
let lastSync = fs.readFileSync(file, 'utf8'); | ||
let lastSyncDate = new Date(lastSync); | ||
let now = new Date(); | ||
let diff = now.getTime() - lastSyncDate.getTime(); | ||
let diffHours = Math.floor(diff / 1000 / 60 / 60); | ||
// if more than 24 hours, sync | ||
if (diffHours > 24) { | ||
console.log('syncing'); | ||
} | ||
console.log('not syncing'); | ||
// if less than 24 hours, do nothing | ||
*/ | ||
return new Response( | ||
JSON.stringify({ | ||
status: 200, | ||
body: 'term' | ||
}) | ||
); | ||
} |