Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/portier/portier-node
Portier client for Node.js
https://github.com/portier/portier-node
Last synced: 2 months ago
JSON representation
Portier client for Node.js
- Host: GitHub
- URL: https://github.com/portier/portier-node
- Owner: portier
- License: mit
- Created: 2016-10-27T13:16:51.000Z (about 8 years ago)
- Default Branch: main
- Last Pushed: 2024-08-14T08:12:14.000Z (5 months ago)
- Last Synced: 2024-09-14T12:40:13.955Z (4 months ago)
- Language: TypeScript
- Size: 85.9 KB
- Stars: 48
- Watchers: 9
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-repositories - portier/portier-node - Portier client for Node.js (TypeScript)
README
# portier-node
A [Portier] client library for Node.js
[portier]: https://portier.github.io/
### Example
```js
import Fastify from "fastify";
import formPlugin from "@fastify/formbody";
import PortierClient from "portier";const portier = new PortierClient({
redirectUri: "http://localhost:8000/verify",
});const app = Fastify();
app.register(formPlugin);app.get("/", (req, res) => {
res.type("text/html");
return `
Enter your email address:
Login
`;
});app.post("/auth", async (req, res) => {
const authUrl = await portier.authenticate(req.body.email);
res.redirect(303, authUrl);
});app.post("/verify", async (req, res) => {
if (req.body.error) {
res.type("text/html");
return `
Error: ${req.body.error_description}
`;
}const email = await portier.verify(req.body.id_token);
res.type("text/html");
return `
Verified email address ${email}!
`;
});app.listen({ port: 8000 });
```