Nestjs backend rest api - Ecommerce project. Introduction & setup.
Summary
TLDRThis video tutorial guides viewers through creating a backend REST API for an e-commerce project using Nest.js, a framework for Node.js applications. It highlights the choice of TypeScript for type safety and TypeORM for database interactions with PostgreSQL. The presenter demonstrates installing necessary software, setting up the project structure with npm, and configuring the initial server to run on port 3000. The script also briefly touches on dependency injection and service creation, providing a foundational step for building out the API.
Takeaways
- 🛠️ The speaker is creating a back-end REST API using the Miss.js framework for Node.js server-side applications.
- 📚 TypeScript is chosen alongside Miss.js for its strong typing features, enhancing code quality and maintainability.
- 🔍 The ORM (Object-Relational Mapping) tool of choice is TypeORM, facilitating database interactions in a more abstract way.
- 🗃️ PostgreSQL is selected as the database for its robustness and scalability, suitable for an e-commerce platform.
- 🛒 The project is an e-commerce REST API, chosen for its comprehensive coverage of major features without being overly complex.
- 💻 Software prerequisites include Node.js, PostgreSQL, and a code editor like VS Code.
- 🔧 Postman or similar tools are recommended for checking API routes and functionality.
- 📝 The script provides step-by-step instructions for setting up the project, starting with installing Miss.js CLI.
- 📁 The project structure includes essential files like main.ts, app.module.ts, and app.controller.ts for organizing the application logic.
- 🔄 Dependency Injection is mentioned as a concept that will be explored later in the context of Miss.js services.
- 🔗 The script outlines how services and controllers interact within the Miss.js framework, with services providing business logic and controllers handling requests.
- 🚀 The final takeaway is about configuring the database connection, which is crucial for the API to interact with the PostgreSQL database.
Q & A
What is the purpose of creating a back-end REST API using Miss.js?
-The purpose is to create an e-commerce REST API, which is chosen for its comprehensive coverage of major features suitable for a medium-sized project.
Why is Dash JS chosen for the Node.js server-side application?
-Dash JS is chosen because it is a framework that is typically used for creating server-side applications in Node.js.
What is the role of TypeScript in this project?
-TypeScript is used alongside Miss.js to provide type safety and other benefits of static typing in the development of the e-commerce REST API.
What ORM is being used in conjunction with TypeScript?
-TypeORM is being used as an Object-Relational Mapping (ORM) tool alongside TypeScript to interact with the database.
Which database is chosen for the e-commerce REST API project?
-PostgreSQL is chosen as the database for the project due to its robustness and scalability.
What software is required to be installed before starting the project?
-Node.js, PostgreSQL, and an IDE like Visual Studio Code are required to be installed before starting the project.
What is the role of Postman in the development process?
-Postman is used for checking and testing the routes of the REST API during the development process.
How does one initiate the creation of a new application using Miss.js CLI?
-One initiates the creation of a new application by running the command 'npm init @miss-js/cli' followed by 'next <project-name>', such as 'next Bazaar API'.
What is the significance of the 'main.ts' file in the project structure?
-The 'main.ts' file is the entry point of the application, where the server is set up to run on a specific port and the app module is initialized.
What is the function of 'app.module.ts' in the application?
-'app.module.ts' is responsible for importing other modules, controllers, and providers that are part of the application's architecture.
Why is 'app.controller.speak.ts' being deleted from the project?
-'app.controller.speak.ts' is intended for unit testing, which is not part of the current project scope, hence it is being deleted.
What is the role of dependency injection in the application?
-Dependency injection is used to manage the dependencies of the application, such as services, in a way that promotes modularity and ease of testing.
How is the 'app.service.ts' utilized in the application?
-'app.service.ts' defines the services used in the application, which can be injected into controllers to provide business logic or data access.
What does the 'app.controller.ts' file contain?
-'app.controller.ts' contains the controllers that handle incoming requests and interact with services to return responses.
How does the application configure the database connection?
-The script does not provide explicit details on configuring the database connection, but it is implied that this will be covered in subsequent steps of the project.
Outlines
🛠️ Setting Up a Back-End E-Commerce REST API with Miss.js
The speaker introduces the project of creating a back-end REST API for an e-commerce platform using Miss.js, a framework for Node.js server-side applications. They chose this project for its comprehensive coverage of major features without being overly complex. The video script details the installation of necessary software, including Node.js and PostgreSQL, and the use of VS Code for coding. It also covers the use of Postman for route checking. The process begins with installing 'next-js-cli' using npm and creating a new project named 'Bazaar API'. The script explains the file and folder structure generated by the 'next' command, including the main entry point in 'main.ts' and the server's configuration to run on port 3000.
📂 Exploring the Project Structure and Initial Setup
This paragraph delves into the project's source (SRC) folder, which contains several files crucial for the application's operation. The speaker explains the purpose of each file, such as 'main.ts' being the entry point, 'app.module.ts' for importing modules, controllers, and providers, and 'app.controller.ts' for creating controllers. The script mentions the deletion of the 'app.controller.speak.ts' file as it's for unit testing, which is not part of the current project scope. It also touches on the concept of dependency injection through 'app.service.ts', which is the only service file and is injectable, returning a 'hello world' string when called in the controller. The paragraph concludes with a mention of configuring the database connection in subsequent parts of the video.
Mindmap
Keywords
💡REST API
💡Nest.js
💡TypeScript
💡ORM
💡PostgreSQL
💡E-commerce
💡VS Code
💡Postman
💡npm
💡Dependency Injection
💡Controllers and Services
Highlights
Creating a back-end REST API using Nest.js, a framework for Node.js server-side applications.
Utilizing TypeScript along with TypeORM as an ORM for database interactions.
Choosing PostgreSQL as the database for the e-commerce REST API.
E-commerce project selected for covering major features without being too large or small.
Installing necessary software like Node.js and PostgreSQL before starting the project.
Using Visual Studio Code as the preferred code editor.
Checking routes with Postman or alternative tools like Insomnia.
Installing NestJS CLI using npm for project scaffolding.
Creating a new project folder and initializing it with NestJS CLI.
Choosing npm as the package manager for the project.
Exploring the file structure generated by NestJS, including node_modules, src, and package.json.
Deleting unnecessary test files to focus on the main application logic.
Understanding the role of main.ts as the entry point of the application.
Importing AppModule and setting up the server to run on port 3000.
AppModule's responsibility to import files, controllers, and providers.
Introduction to dependency injection and its usage in the application.
Creating and organizing controllers and services within the application.
Using AppService for business logic and injecting it into the controller.
Configuring the database connection for the e-commerce REST API.
Transcripts
delete your welcome
I am going to create a back-end rest API
with miss.js
Dash JS is used for node.js server side
application
it's a framework I choose to create an
e-commerce rest API
's framework typically use
typescript I also
use typescript along with
type or M as an orm and as for database
I use postgres SQL
you can ask why I choose eCommerce
project
I chose it because it's not a small
project
but not the biggest project either
actually it's covered most of the major
features that I know
before going to create these
rest API we need to
install some softwares
first is node.js
then
database postgres SQL
I am
using vs code
for coding you can use vs code or
whatever you want
and
checking the route
I will use
Postman you can use Postman or insomnia
or whatever you compute till compute
okay
if you
install these
softwares then here
these
messages documentation
it says several
points to
install niches
there is another one
there is another one but I
I will use this
npm I
Dash G at Ms JS slash CLI then next new
then project name
so
I'm copying these
line first npm I Dash G at mesh JS CLI
I have opened my visual studio code
then I open my terminal
so
I create a next API namely
a folder and it's in desktop
you can choose
file path or folder path and your viewer
computer
now I am
paste this line and click on enter
it will
take some time
okay I have installed next jscli now
it's time to create new application
openness.js
to
install new application we have to
copy these
command
then go again
paste it next new project name and I am
going to
name it
Bazaar API
okay next new Bazar API without
installing this next jsli remember it
will not
what so first install this JS CLI then
this command will work
next it tells which package manager
audio
like to use I am using npm if you
want you can choose yarn or pnpm I'm
using npm enter
okay
it's installed
now if we expand
API folder we can see the
node.js messages
file and folder structure plus node
modules then SRC test then sum of the
file
we
should have used
package.json
there is
starting
script
third div
and Etc
let's open SRC folder
SRC folder has some several files
main.ts appservice.ts
app
Dot module.ts
app.controller.ts
app.controller.speak.ts
this speak dot TS this is for unit
testing we are not going to paste
anything or dot unit testing
so I am going to
delete this file first because we don't
I don't need this
okay
main.ts this is our entry
point
and this import next Factory import app
module
this is the boot step
this function will be called first
and here is our
server is running on Port 300. and it's
have it list Factory dot create app
module and where is our app module app
module is app.module.ts
so this file
call in Main
dot TS and app module it's can import
file
and controller and providers
there is only one controller
app controller and here is our app
controller this is this
you can create as many as you want
and then you have to
put this
their controllers after one controller
then comma another controller and
providers providers is Services Services
there is only one service in this app so
for now this is
app.service.ts this is app service and
it's injectable what is
dependency injection we will see it
later but first It
app service and it return date hello
which string hello world and it's called
in controller
if you open controller app controller
here is the gate hello string and this
is called these dot f service dot gate
hello these dot app service and if this
is our
service and it's called this function so
it will return hello world and it will
return hello
and this is string
so
this is for now next oh you will
see how to
configure our database connection
okay bye
Ver Más Videos Relacionados
How to deploy a NextJS app on Digital Ocean instead of Vercel
Connect a PostgreSQL database to a Spring Boot Application Tutorial
Entity Framework Setup - GRAPHQL API IN .NET w/ HOT CHOCOLATE #5.1
Asp.Net Core Web API Client/Server Application | Visual Studio 2019
AR Indoor Navigation from scratch in under 30 minutes with Unity 6
Microservices Using Spring Boot and Spring Cloud #1
5.0 / 5 (0 votes)