0% found this document useful (0 votes)
8 views2 pages

Athentication Nodejs

This project is a Node.js authentication API using MySQL and Docker. It provides secure user authentication and is documented with Swagger. It ensures CORS support, uses Docker for deployment, and has distinct environments for development and production.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views2 pages

Athentication Nodejs

This project is a Node.js authentication API using MySQL and Docker. It provides secure user authentication and is documented with Swagger. It ensures CORS support, uses Docker for deployment, and has distinct environments for development and production.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

# :green_heart: Node.

js Authentication API with MySQL and Docker

This project is a robust authentication API developed using Node.js. It leverages


MySQL for database management and Docker for containerization. The API ensures
secure user authentication and is comprehensively documented with Swagger for ease
of use and integration.

## :bookmark_tabs: Table of Contents

- [Quick Links](#quick-links)
- [What You Need](#what-you-need)
- [Key Features](#key-features)
- [Project Layout](#project-layout)
- [Prerequisites](#prerequisites)
- [Installation and Setup](#installation-and-setup)
- [Using the App](#using-the-app)
- [API Routes - Protected](#api-routes---protected)
- [Credentials](#credentials)

## :link: Quick Links

- [`MySQL`](https://www.mysql.com/)
- [`Docker`](https://www.docker.com/)
- [`OpenAPI 3.0`](https://swagger.io/specification/)

## :wrench: What You Need

- `Node.js`
- `IDE`
- `Docker`
- `MySQL`

## :star2: Key Features

- User authentication bolstered with `**CORS**` support.


- Interactive API documentation facilitated by Swagger.
- Docker containerization for simplified deployment and scalability.
- Distinct environment configurations for development and production stages.

## :file_folder: Project Layout

The project's directory structure is as follows:

- `config/`: Houses database configurations and other environment variables.


- `controllers/`: Contains control logic for authentication and protected routes.
- `db/`: Holds the database connection configuration.
- `docs/`: Contains API documentation in YAML format for Swagger.
- `environment/`: Contains environment variable files for different environments.
- `routes/`: Defines the API routes.
- `services/`: Contains services related to the user.
- `Dockerfile` and `docker-compose.yml`: Files necessary for Docker
containerization.

## :clipboard: Prerequisites

- Docker and Docker Compose (for containerization).


- Node.js (version 14.x or higher).
- MySQL (version 8.x or higher).
## :floppy_disk: Installation and Setup

To start a new Node.js project, you can use the `npm init` command. The `-y` flag
will automatically fill in the default information in the setup process.

```console
npm init -y
```

Navigate to the project directory:

```console
cd Auth-Tutorial-Lab02
```

Install the necessary dependencies:

```console
npm install
```

## :computer: Using the App

Start the server with:

```console
npm start
```

The server will run on [🔗](http://localhost:3000/docs)


</br>`http://localhost:3000/docs/`

## :closed_lock_with_key: API Routes - Protected

Access to a protected resource, requires basic authentication


[&#128279;](http://localhost:3000/docs/Protected)
</br>
`http://localhost:3000/docs/Protected`

## :key: Credentials

The project uses basic authentication to protect the `/protected` route. When
making a HTTP request to this route, you need to include these credentials in the
`Authorization` header of the request. The format is `Authorization`:

Basic {credentials}`, where `{credentials}` is the Base64 encoding of the username


and password joined by a colon.

Use the following credentials for testing:

**Username:** `basicUser` </br>


**Password:** `basicPassword`

You might also like