Skip to content

A sample nest js project to generate and validate access keys in two different apps

Notifications You must be signed in to change notification settings

vineetshar/nest-access-key-manager-sample

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Access Key Commands Nest Sample

A sample codebase to work with access keys written in NestJS. Note: This has no auth , please apply your own.

PGAdmin Configuration

  • Host: host.docker.internal
  • Individual config for DB connections is in individual docker-compose files per repository.

Setup Steps

  1. Docker compose up in root directory
  2. cd && Docker compose up in apps/access-key-generator directory
  3. cd && Docker compose up in apps/key-information-service directory
  4. Let docker running in background

Setup for access-key-generator app (after getting infra up via docker-compose up)

  1. Install dependencies:
    npm i
  2. Build the project:
    npm run build
  3. Run database migrations:
    npx prisma migrate dev
    npx prisma migrate deploy

Access Key Generator Commands

Admin Commands

Note : The admin app has no validation as of now - it doesnt validate for admins

  • List all keys:
    npm run list-all-keys
  • Generate a new key:
    npm run generate-key -- --level=admin --username=vineet --ratelimit=10 --expiry=10-11-2024
  • Delete a key:
    npm run delete-key -- --key-id=clwdrmjpu0000ax0t4jwcilt8
  • Update rate limit:
    npm run update-rate-limit -- -k clwdrkf830000lrz76f73rgdh -r 10
  • Update expiry date:
    npm run update-expiry -- -k clwdrkf830000lrz76f73rgdh -e 10-10-2024

User Commands

  • Update key status:
    npm run update-key-status -- -k clwdrfbdq000054lt4clwrqch -s enabled
  • Fetch key details:
    npm run fetch-key-details -- -k clwdrfbdq000054lt4clwrqch

Key Information Service Commands (after getting infra up via docker-compose up)

Setup

  1. Install dependencies:
    npm i
  2. Run database migrations:
    npx prisma migrate dev
    npx prisma migrate deploy
  3. Build the project:
    npm run build
  4. Start the service:
    npm run start

Usage for key validation in key-information-service

Make a GET call at http://localhost:3000/key-information/key.

Example:

http://localhost:3000/key-information/1234

This README provides a quick reference for setting up and managing access keys using the provided NestJS sample codebase.

About

A sample nest js project to generate and validate access keys in two different apps

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published