-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into cover-page-api
- Loading branch information
Showing
43 changed files
with
748 additions
and
132 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
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
20 changes: 20 additions & 0 deletions
20
desci-server/prisma/migrations/20240604123832_add_doi_records_table/migration.sql
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,20 @@ | ||
-- CreateTable | ||
CREATE TABLE "DoiRecord" ( | ||
"id" SERIAL NOT NULL, | ||
"doi" TEXT NOT NULL, | ||
"dpid" TEXT NOT NULL, | ||
"uuid" TEXT NOT NULL, | ||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
"updatedAt" TIMESTAMP(3) NOT NULL, | ||
|
||
CONSTRAINT "DoiRecord_pkey" PRIMARY KEY ("id") | ||
); | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "DoiRecord_doi_key" ON "DoiRecord"("doi"); | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "DoiRecord_dpid_key" ON "DoiRecord"("dpid"); | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "DoiRecord" ADD CONSTRAINT "DoiRecord_uuid_fkey" FOREIGN KEY ("uuid") REFERENCES "Node"("uuid") ON DELETE RESTRICT ON UPDATE CASCADE; |
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,18 @@ | ||
import { Response } from 'express'; | ||
|
||
import { SuccessResponse, communityService, logger } from '../../internal.js'; | ||
import { RequestWithUser } from '../../middleware/authorisation.js'; | ||
|
||
export const checkMemberGuard = async (req: RequestWithUser, res: Response) => { | ||
const log = logger.child({ | ||
module: 'ATTESTATIONS::MemberGuard', | ||
}); | ||
const userId = req.user.id; | ||
const communityId = parseInt(req.params.communityId); | ||
|
||
log.info({ userId: req.user.id, community: communityId }, 'Community Member Guard check'); | ||
const isMember = await communityService.findMemberByUserId(communityId, userId); | ||
|
||
if (!isMember) new SuccessResponse({ ok: false }).send(res); | ||
else new SuccessResponse({ ok: true }).send(res); | ||
}; |
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,27 @@ | ||
import { NextFunction, Request, Response } from 'express'; | ||
|
||
import { DoiError } from '../../core/doi/error.js'; | ||
import { BadRequestError, SuccessResponse, doiService, logger } from '../../internal.js'; | ||
|
||
export const checkMintability = async (req: Request, res: Response, _next: NextFunction) => { | ||
const { uuid } = req.params; | ||
if (!uuid) throw new BadRequestError(); | ||
try { | ||
await doiService.checkMintability(uuid); | ||
new SuccessResponse(true).send(res); | ||
} catch (err) { | ||
logger.error(err, 'module:: checkMintability'); | ||
if (!(err instanceof DoiError)) { | ||
// TODO: Sentry error reporting | ||
} | ||
new SuccessResponse(false).send(res); | ||
} | ||
}; | ||
|
||
export const getDoi = async (req: Request, res: Response, next: NextFunction) => { | ||
const { identifier } = req.params; | ||
if (!identifier) throw new BadRequestError(); | ||
|
||
const doi = await doiService.getDoiByDpidOrUuid(identifier); | ||
new SuccessResponse(doi).send(res); | ||
}; |
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,2 @@ | ||
export * from './check.js'; | ||
export * from './mint.js'; |
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,11 @@ | ||
import { Request, Response, NextFunction } from 'express'; | ||
|
||
import { BadRequestError, SuccessResponse, doiService, ensureUuidEndsWithDot } from '../../internal.js'; | ||
|
||
export const mintDoi = async (req: Request, res: Response, next: NextFunction) => { | ||
const { uuid } = req.params; | ||
if (!uuid) throw new BadRequestError(); | ||
const sanitizedUuid = ensureUuidEndsWithDot(uuid); | ||
const doi = await doiService.mintDoi(sanitizedUuid); | ||
new SuccessResponse(doi).send(res); | ||
}; |
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.