Skip to content

Pulser132/rest-api-basic

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

rest-api-basic

A basic REST API built with Node.js, TypeScript, and Express, protected by HTTP Basic Authentication.

Setup

  1. Install dependencies:

    npm install
    
  2. Create a .env file (see .env.example) with:

    PORT=3000
    USERNAME=admin
    PASSWORD=secret
    

Running

  • Development (with auto-reload):

    npm run dev
    
  • Build and run production:

    npm run build
    npm start
    

Endpoints

GET /hello

Requires HTTP Basic Authentication using the USERNAME and PASSWORD from .env.

Query parameters:

  • name - the name to greet

Response:

{ "message": "Hello <name>" }

Example:

curl -u admin:secret "http://localhost:3000/hello?name=World"

About

api to test basic authentication

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors