Giter Site home page Giter Site logo

challenge-nestjs-postgresql's Introduction

Nest Logo PostgreSql Logo

Challenge NestJS and PostgreSQL

NPM Version Package License

Description

Challenge of building an API using nestjs Nest framework TypeScript and PostgreSql.

Clone

https://github.com/EduDevHe/challenge-nestJs-postgresql.git

Running the app ๐Ÿš€

# development
$ pnpm run start

# watch mode
$ pnpm run start:dev

# production mode
$ pnpm run start:prod

Docker ๐Ÿณ

docker-compose up --build

API docs ๐Ÿ“š

Get place by id in API

Url example

http://localhost:3000/place/1

Method GET

Return

    {
        "id": 1,
        "name": "rio",
        "state": "bahia",
        "city": "barreiras",
        "createdAt": "2024-01-11T00:28:03.143Z",
        "updatedAt": "2024-01-11T00:28:03.143Z"
    }

Get all places in api

Url example

	http://localhost:3000/place/all

Method GET

Return

[
	{
		"id": 1,
		"name": "rio",
		"state": "bahia",
		"city": "barreiras",
		"createdAt": "2024-01-11T00:28:03.143Z",
		"updatedAt": "2024-01-11T00:28:03.143Z"
	},
	{
		"id": 2,
		"name": "cais",
		"state": "bahia",
		"city": "barreiras",
		"createdAt": "2024-01-11T00:28:19.339Z",
		"updatedAt": "2024-01-11T00:28:19.339Z"
	},
	{
		"id": 3,
		"name": "centro",
		"state": "bahia",
		"city": "barreiras",
		"createdAt": "2024-01-11T00:28:10.101Z",
		"updatedAt": "2024-01-11T01:31:58.283Z"
	}
]

Search places in API

Url example

http://localhost:3000/place?name=barreirinhas
http://localhost:3000/place?name=barreirinhas&state=bahia

Method GET

Return

[
	{
		"id": 5,
		"name": "barreirinhas",
		"state": "bahia",
		"city": "barreiras",
		"createdAt": "2024-01-11T00:28:03.143Z",
		"updatedAt": "2024-01-11T00:28:03.143Z"
	}
]

Create a place in the api

Url example

http://localhost:3000/place/create

Method POST

Header example

method: 'GET',
headers: {
    'Authorization': `Bearer ${token}`,
  },

Body

{
"name":"centro",
"city":"barreiras",
"state":"bahia"
}

Return

{
	"message": "Place created successfully",
	"place": {
		"id": 8,
		"name": "centro",
		"state": "bahia",
		"city": "barreiras",
		"createdAt": "2024-01-11T03:10:31.861Z",
		"updatedAt": "2024-01-11T03:10:31.861Z"
	}
}

Delete a place by id in the API

You need to be authenticated with a valid jwt token

Url example

http://localhost:3000/place/8

Method DELETE

Header example

method: 'DELETE',
headers: {
    'Authorization': `Bearer ${token}`,
  },

Return

{
	"message": "Deleted place",
	"place": {
		"id": 8,
		"name": "centro",
		"state": "bahia",
		"city": "barreiras",
		"createdAt": "2024-01-11T03:10:31.861Z",
		"updatedAt": "2024-01-11T03:10:31.861Z"
	}
}

Upadate a place by id in the API

You need to be authenticated with a valid jwt token

Example

http://localhost:3000/place/7

Method PATCH

Header example

method: 'PATCH',
headers: {
    'Authorization': `Bearer ${token}`,
  },

Body

{
"name":"centro"
}

Return

{
	"message": "Updated place",
	"place": {
		"id": 7,
		"name": "centro",
		"state": "bahia",
		"city": "barreiras",
		"createdAt": "2024-01-11T00:28:19.339Z",
		"updatedAt": "2024-01-11T04:18:01.780Z"
	}
}

Create a user in the API

Url example

http://localhost:3000/auth/register

Method POST

Body

{
	"username":"test",
	"email": "[email protected]",
	"password": "12345"
}

Return

{
	"message": "User created successfully",
	"username": "test",
	"email": "[email protected]",
	"createdAt": "2024-01-11T03:27:02.702Z"
}

Login

Url example

http://localhost:3000/auth/login

Method POST

Body

{
	"email": "[email protected]",
	"password": "12345"

}

Return

{
	"message": "login successfully",
	"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJlbWFpbCI6InRlc3QiLCJzdWIiOjUsImlhdCI6MTcwNDk0MzY1MSwiZXhwIjoxNzA0OTQ3MjUxfQ.Wa3lx6HUv6x5h90HBpb1DdF6ivHa8Ohybgr_ycekNHw",
	"login": true
}

challenge-nestjs-postgresql's People

Contributors

edudevhe avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.