Skip to content

buraksaraloglu/auth-service

Repository files navigation

Auth Service

Authentication service with jwt tokens.

Dependencies

Installation

git clone https://github.com/buraksaraloglu/auth-service.git
cd auth-service
npm install

Development

npm dev

Deployment

npm run build

Usage

npm start

Testing

npm test

Example Requests

Create User (Register)

# POST /auth/users

curl --location --request POST '<service-uri>/auth/users' \
  --header 'Content-Type: application/json' \
  --data-raw '{
    "email": "test@example.com",
    "password": "12345678"
  }'

Create Session (Login)

# POST /sessions

curl --location --request POST '<service-uri>/sessions' \
  --header 'Content-Type: application/json' \
  --data-raw '{
    "email": "test@example.com",
    "password": "12345678"
  }'

Get Session (Authorize)

# GET /sessions

curl --location --request GET 'http://localhost:5000/sessions' \
  --header 'x-refresh-token: <refreshToken in create session response>' \
  --header 'Authorization: Bearer <accessToken in create session response>'

Delete Session (Sign out)

# DELETE /sessions

curl --location --request DELETE 'http://localhost:5000/sessions' \
  --header 'x-refresh-token: <refreshToken in create session response>' \
  --header 'Authorization: Bearer <accessToken in create session response>'

About

An authentication service built with TypeScript, Express, MongoDB

Resources

License

Stars

Watchers

Forks