-
Notifications
You must be signed in to change notification settings - Fork 156
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: refactor content storages (#87)
- Loading branch information
Showing
8 changed files
with
160 additions
and
94 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
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
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 |
---|---|---|
@@ -1,10 +1,24 @@ | ||
// import { clearDatabase } from '../../database' | ||
import { IncomingMessage } from 'http' | ||
import { useBody } from 'h3' | ||
import { buildContent, buildStorage } from '../content' | ||
|
||
interface Body { | ||
key: string | ||
event: 'remove' | 'update' | ||
} | ||
|
||
/** | ||
* Reload the database. | ||
*/ | ||
export default () => { | ||
// clearDatabase() | ||
export default async (req: IncomingMessage) => { | ||
const { key, event } = await useBody<Body>(req) | ||
|
||
if (event === 'remove') { | ||
buildStorage.removeItem(key) | ||
} else if (await buildStorage.hasItem(key)) { | ||
// Rebuild/Reload content | ||
await buildContent(key) | ||
} | ||
|
||
return true | ||
} |
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
Oops, something went wrong.