forked from OwnZones/orchestration-gui
-
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.
- Loading branch information
Showing
13 changed files
with
220 additions
and
33 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { NextRequest, NextResponse } from 'next/server'; | ||
import { isAuthenticated } from '../../../../../api/manager/auth'; | ||
import { Params } from 'next/dist/shared/lib/router/utils/route-matcher'; | ||
import { purgeInventorySourceItem } from '../../../../../api/manager/inventory'; | ||
|
||
export async function PUT( | ||
request: NextRequest, | ||
{ params }: { params: Params } | ||
): Promise<NextResponse> { | ||
if (!(await isAuthenticated())) { | ||
return new NextResponse(`Not Authorized!`, { | ||
status: 403 | ||
}); | ||
} | ||
|
||
try { | ||
const response = await purgeInventorySourceItem(params._id); | ||
if (response.acknowledged && response.modifiedCount === 0) { | ||
return new NextResponse(`Did not match requirements`, { | ||
status: 204 | ||
}); | ||
} else if (response.acknowledged) { | ||
return new NextResponse(null, { | ||
status: 200 | ||
}); | ||
} else { | ||
return new NextResponse(`Could not update database-status`, { | ||
status: 500 | ||
}); | ||
} | ||
} catch (error) { | ||
return new NextResponse( | ||
`Error occurred while posting to DB! Error: ${error}`, | ||
{ | ||
status: 500 | ||
} | ||
); | ||
} | ||
} |
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
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.