-
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.
feat: toteuta testaukseen tapa siirtää nähtävilläolokuulutuksen päätt…
…ymisaika välittömästi menneisyyteen (#317)
- Loading branch information
1 parent
a90a44e
commit 13b716f
Showing
7 changed files
with
94 additions
and
32 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
36 changes: 36 additions & 0 deletions
36
src/pages/api/test/[oid]/nahtavillaolomenneisyyteen.dev.ts
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,36 @@ | ||
import { NextApiRequest, NextApiResponse } from "next"; | ||
import { projektiDatabase } from "../../../../../backend/src/database/projektiDatabase"; | ||
import { validateCredentials } from "../../../../util/basicAuthentication"; | ||
|
||
export default async function handler(req: NextApiRequest, res: NextApiResponse) { | ||
let environment = process.env.ENVIRONMENT; | ||
if ((environment == "dev" || environment == "test") && !(await validateCredentials(req.headers.authorization))) { | ||
res.status(401); | ||
res.setHeader("www-authenticate", "Basic"); | ||
|
||
res.send(""); | ||
return; | ||
} | ||
|
||
const oid = req.query["oid"]; | ||
if (oid instanceof Array || !oid || oid.length == 0) { | ||
res.status(400); | ||
res.send(""); | ||
return; | ||
} | ||
|
||
res.setHeader("Content-Type", "text/plain; charset=UTF-8"); | ||
|
||
let dbProjekti = await projektiDatabase.loadProjektiByOid(oid); | ||
if (!dbProjekti) { | ||
res.send("Projektia ei löydy"); | ||
return; | ||
} | ||
if (dbProjekti?.nahtavillaoloVaiheJulkaisut) { | ||
for (const julkaisu of dbProjekti.nahtavillaoloVaiheJulkaisut) { | ||
julkaisu.kuulutusVaihePaattyyPaiva = "2022-01-01"; | ||
await projektiDatabase.updateNahtavillaoloVaiheJulkaisu(dbProjekti, julkaisu); | ||
} | ||
} | ||
res.send("OK"); | ||
} |