An open API service indexing awesome lists of open source software.

https://github.com/bhimrazy/express-blog-api

A Blog REST API with JWT authentication using ExpressJs, MongoDB, NodeJs and Typescript.
https://github.com/bhimrazy/express-blog-api

blog-api-with-nodejs-and-expressjs docker docker-compose express-validator expressjs jwt mongo mongoose nodejs typescript

Last synced: 3 months ago
JSON representation

A Blog REST API with JWT authentication using ExpressJs, MongoDB, NodeJs and Typescript.

Awesome Lists containing this project

README

          





# A Blog REST API App using ExpressJs, MongoDB, NodeJs and Typescript

This repo helps you to get started with ExpressJs, MongoDB, NodeJs and Typescript in docker Environment.

## Setup and Run Locally with or without using Docker

Commands

```bash
# clone github repo
$ git clone https://github.com/bhimrazy/express-blog-api
$ cd express-blog-api
$ cp .env.example .env

# Run without using docker
# SET DATABASE_URL
$ npm install
$ npm run dev

# Run with docker
# start containers
$ docker-compose up -d
# start containers
$ docker-compose up -d
# stop containers
$ docker-compose down

# check logs of docker image
$ docker logs

# Run tests
$ npm run test
```

## Directory Structure

```
.
├── dist/ # Build files
├── public/ # Contains static files
├── src/ # All
│ ├── configs/ # Contains all the configurations
│ ├── models/ # Contains all the database schema and models
│ ├── services/ # Contains all the services
│ ├── controllers/ # Contains all the controllers
│ ├── middlewares/ # Contains all the middlewares
│ ├── validators/ # Contains all the request validators
│ ├── serializers/ # Contains all the serializers
│ └── routes/ # Contains all the routes
├── tests/ # Contains all the test files
├── tsconfig.json # Typescript Config
├── index.ts # Index file
├── package.json
├── package-lock.json
└── README.md
```

## API Reference

Postman Docs: https://documenter.getpostman.com/view/8091590/2s8YRnmXTd

#### Get Home URL

```
GET /api/v1/
```

#### Register User

```
POST /api/v1/register
```

| Parameter | Type | Description |
| :--------- | :------- | :-------------------------- |
| `name` | `string` | **Required**. Your Name |
| `email` | `string` | **Required**. Your Email |
| `password` | `string` | **Required**. Your Password |

#### Login User

```
POST /api/v1/login
```

| Parameter | Type | Description |
| :--------- | :------- | :-------------------------- |
| `email` | `string` | **Required**. Your Email |
| `password` | `string` | **Required**. Your Password |

#### Blogs API

```
GET /api/v1/blogs/
GET /api/v1/blogs/:id
POST /api/v1/blogs/
PUT /api/v1/blogs/:id
DELETE /api/v1/blogs/:id
```

## References

## License

[MIT](https://github.com/bhimrazy/express-blog-api/blob/main/LICENSE)