-
-
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.
- Loading branch information
Showing
4 changed files
with
98 additions
and
21 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,29 @@ | ||
/// <reference types="cypress" /> | ||
|
||
export { }; | ||
|
||
context("/api/greeter", () => { | ||
beforeEach(() => { | ||
cy.visit("/"); | ||
}); | ||
|
||
it("should get error when navigate to /api/greeter", () => { | ||
return cy.request({ | ||
method: "GET", | ||
url: "/api/greeter", | ||
failOnStatusCode: false, | ||
}).then((response) => { | ||
expect(response.status).equal(400); | ||
}); | ||
}); | ||
|
||
it("should say greeter name when navigate to /api/greeter?name=Dung", () => { | ||
return cy.request({ | ||
method: "GET", | ||
url: "/api/greeter?name=Dung", | ||
}).then((response) => { | ||
expect(response.status).equal(200); | ||
expect(response.body.name).equal("Dung"); | ||
}); | ||
}); | ||
}); |
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,19 @@ | ||
import { NextApiRequest, NextApiResponse } from 'next'; | ||
import { withValidation } from 'next-validations'; | ||
import * as valibot from 'valibot'; | ||
|
||
const schema = valibot.object({ | ||
name: valibot.string(), | ||
}); | ||
|
||
const validate = withValidation({ | ||
schema, | ||
type: 'Valibot', | ||
mode: 'query', | ||
}); | ||
|
||
const handler = (req: NextApiRequest, res: NextApiResponse) => { | ||
res.status(200).json(req.query); | ||
}; | ||
|
||
export default validate(handler); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
1edff78
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
next-validations – ./
next-validations-dunghd.vercel.app
next-validations.productsway.com
next-validations.vercel.app
next-validations-git-main-dunghd.vercel.app