Coder Social home page Coder Social logo

clerk-fastify-starter's Introduction


Clerk Fastify Starter

This example shows how to use Clerk with Fastify.

chat on Discord documentation twitter

Running the starter

To run the example locally you need to:

  1. Sign up for a Clerk account at https://clerk.dev.
  2. Go to Clerk's dashboard and create an application.
  3. Clone the repo locally git clone [email protected]:clerkinc/clerk-fastify-starter.git && cd clerk-fastify-starter
  4. Set the required Clerk environment variables as shown in the example env file.
  5. npm install the required dependencies.
  6. npm run start to launch the demo Fastify server.

Contents

This example repo contains the following examples:

  • ./src/index.ts: Basic Clerk and Fastify usage. Run the example with npm run start
  • ./src/authenticating-specific-routes.ts: Instead of using Clerk globally, this examples show how to use Clerk for a subset of your routes, using the register Fastify helper. Run the example with npm run start:specific-routes.
  • ./src/using-runtime-keys.ts: Instead of setting environment variables, this examples shows how to initialise Clerk by passing the required API keys directly to clerkPlugin. Run the example with npm run start:runtime-keys

Learn more

To learn more about Clerk and Fastify, check out the following resources:

Contact

If you need support or have anything you would like to ask, please reach out in our Discord channel. We'd love to chat!

clerk-fastify-starter's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

clerk-fastify-starter's Issues

Missing clerk secret or API key

When trying this (without setting secret key as in example) nothing happen for first few tries.
https://github.com/clerkinc/clerk-fastify-starter/blob/main/src/authenticating-specific-routes.ts

but after that, it shows error

{
    "statusCode": 500,
    "error": "Internal Server Error",
    "message": "Missing Clerk Secret Key or API Key. Go to https://dashboard.clerk.com and get your key for your instance."
}

So I tried it like this, I overwrite the original clerkCLient

const clerkClient = createClerkClient({
  publishableKey: process.env.CLERK_PUBLISHABLE_KEY,
  secretKey: process.env.CLERK_SECRET_KEY,
})
const userClerkData = userId ? await clerkClient.users.getUser(userId) : null;

I see there's other sample here
https://github.com/clerkinc/clerk-fastify-starter/blob/main/src/using-runtime-keys.ts

but I want to use the first method link (where authenticate only on specific route)

but still same error shows up.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.