Prerequisites
- Created your Unkey account
- Created an API in the Unkey dashboard
Skip the tutorial
Don’t want to read the tutorial? Click this to get an example ready to test.
Creating a bun server protected by Unkey
1
Create a new Bun project
First we need a bun project, so create a new directory and init bun.
2
Install
Now install the
@unkey/api
package3
Modify the server
Open up the file called
index.ts
and add the following codeindex.ts
4
Running the server
5
Try it out
Go to It should return
https://app.unkey.com
and create a new key. Then verify it with our new server:{"keyId":"key_id","valid":true,"meta":{},"enabled":true,"permissions":[],"code":"VALID"}
and potentially more information about the key, depending on what you set up in the dashboard.