This is a simple Express application that provides an API for creating JSON Web Tokens (JWTs).
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.
- Node.js
- npm
- Clone the repository: git clone https://github.com/ariescghwartzman/signjwt.git
- Install dependencies: cd signjwt npm install
This project requires the following environment variables:
PORT
- The port on which the server will run. If not provided, defaults to 3000.API_KEY
- The API key for authenticating requests.
To configure your application for local development, you need to create a .env
file in the root directory of your project. This file will contain key-value pairs, which represent environment variables.
Here's an example of what your .env
file might look like:
PORT=3000
API_KEY=your_api_key
To start the server, run: npm start
-
POST /sign
- Creates a JWT from the provided payload.For example:
curl -X POST https://{host}/sign \ -H 'Content-Type: application/json' \ -H 'x-api-key: your_api_key' \ -d '{ "secret": "your_secret", "audience": "your_audience" }'
If the request is successful, you will receive a response like this:
{ "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWRpZW5jZSI6InlvdXJfYXVkaWVuY2UiLCJpYXQiOjE1MTYyMzkwMjIsImV4cCI6MTUxNjI0MjYyMn0.ih1a0wR5p07s7B8eIiKA7TbCqxGVuCwK3I2C6l1BwEI" }
-
GET /health
- Checks the health of the application.For example:
curl -X GET https://{host}/health
If the application is running properly, you will receive a response like this:
{ "status": "Healthy" }
- Express - The web framework used
- jsonwebtoken - Used to create JWTs
This project is licensed under the MIT License - see the LICENSE.md file for details