-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add mock-create-rule nextjs endpoint #373
- Loading branch information
Showing
2 changed files
with
51 additions
and
0 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,21 @@ | ||
import { withAuthenticatedSessionRoute } from "@/lib/infrastructure/auth/session-utils"; | ||
import { NextApiRequest, NextApiResponse } from "next"; | ||
|
||
async function endpoint(req: NextApiRequest, res: NextApiResponse, rucioAuthToken: string) { | ||
if(req.method !== 'POST') { | ||
res.status(405).json({ error: 'Method Not Allowed' }) | ||
return | ||
} | ||
|
||
|
||
const data = req.body | ||
|
||
if(!data) { | ||
res.status(400).json({ error: 'Missing body' }) | ||
return | ||
} | ||
|
||
res.status(200).json(req.body) | ||
} | ||
|
||
export default withAuthenticatedSessionRoute(endpoint); |
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,30 @@ | ||
import { withAuthenticatedSessionRoute } from "@/lib/infrastructure/auth/session-utils"; | ||
import { NextApiRequest, NextApiResponse } from "next"; | ||
import { fixtureRuleMetaViewModel, generateSequenceArray } from "test/fixtures/table-fixtures"; | ||
|
||
async function endpoint(req: NextApiRequest, res: NextApiResponse, rucioAuthToken: string) { | ||
if(req.method !== 'POST') { | ||
res.status(405).json({ error: 'Method Not Allowed' }) | ||
return | ||
} | ||
if(!req.body) { | ||
res.status(400).json({ error: 'Missing body' }) | ||
return | ||
} | ||
const { dids } = req.body | ||
if(!dids) { | ||
res.status(400).json({ error: 'Missing dids' }) | ||
return | ||
} | ||
const response = dids.map((did: string) => { | ||
return { | ||
did, | ||
is_valid: true, | ||
reason: null | ||
} | ||
}) | ||
|
||
res.status(200).json(response) | ||
} | ||
|
||
export default withAuthenticatedSessionRoute(endpoint); |