/node-crud

This repository was developed following Rocketseat's https://www.youtube.com/watch?v=9AO2hZJsHrs video to learn how to create a CRUD in a Node API using Express, TypeORM and PostgreSQL

Primary LanguageTypeScriptMIT LicenseMIT

📚 Node CRUD

This repository was developed following Rocketseat's https://www.youtube.com/watch?v=9AO2hZJsHrs video to learn how to create a CRUD in a Node API using Express, TypeORM and PostgreSQL

📫 Routes

CategoryController

POST — "/categories"

Create a new category

body:

{
	"name": string,
	"description": string
}

response:

{
	"id": string,
	"name": string,
	"description": string,
	"created_at": Date
}

GET — "/categories"

Get all categories

response:

[
   {
	  "id": string,
	  "name": string,
	  "description": string,
	  "created_at": Date
   }
]

DELETE — "/categories/{ id }"

Delete a category by your id

route params:

id: string


PUT — "/categories/{ id }"

Update category info by your id

route params:

id: string

body:

{
	"name": string,
	"description": string
}

response:

{
	"id": string,
	"name": string,
	"description": string,
	"created_at": Date
}

VideoController

POST — "/videos"

Create a new video

body:

{
	"name": string,
	"description": string,
	"duration": number,
	"category_id": string
}

response:

{
	"id": string,
	"name": string,
	"description": string,
	"duration": number,
	"category_id": string,
	"created_at": Date
}

GET — "/videos"

Get all videos

response:

[
   {
	  "id": string,
	  "name": string,
	  "description": string,
	  "duration": number,
	  "category_id": string,
	  "created_at": Date,
	  "category": {
		  "id": string,
		  "name": string,
		  "description": string,
		  "created_at": Date
	  }
   }
]

🌐 Status

Finished project ✅

🧰 Prerequisites

Node JS

Enviroment Variables

  • TYPEORM_CONNECTION
  • TYPEORM_HOST
  • TYPEORM_USERNAME
  • TYPEORM_PASSWORD
  • TYPEORM_DATABASE
  • TYPEORM_PORT
  • TYPEORM_MIGRATIONS = src/database/migrations/*.ts
  • TYPEORM_MIGRATIONS_DIR = src/database/migrations
  • TYPEORM_ENTITIES = src/entities/*.ts
  • TYPEORM_ENTITIES_DIR = src/entities

🔧 Installation

$ git clone https://github.com/AllanDutra/node-crud.git

$ cd node-crud

$ npm install

$ npm run dev

Node server listenning at http://localhost:3333/!

🔨 Tools used


Developed with 💜 by Allan Dutra!