A progressive Node.js framework for building efficient and scalable server-side applications.
Nest framework TypeScript starter repository.
$ yarn install
# development
$ yarn run start
# watch mode
$ yarn run start:dev
# production mode
$ yarn run start:prod
# unit tests
$ yarn run test
# e2e tests
$ yarn run test:e2e
# test coverage
$ yarn run test:cov
Nest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If you'd like to join them, please read more here.
- Author - Kamil Myśliwiec
- Website - https://nestjs.com
- Twitter - @nestframework
- Run
postgres
indocker
after installing the docker locally
docker run --name postgres-nest -p 5432:5432 -e POSTGRES_PASSWORD=postgres -d postgres
- How to check running containers in dockers locally
docker container ls
or
docker ps
or to see inactive containers
docker ps -a
- How to
stop
the container by name
docker container stop postgres-nest
- How to
start
the container after stopping it by name
docker container start postgres-nest
- How to
remove
ordelete
the container after stopping it by name
docker container rm postgres-nest
- Finally you can check that the access to the
postgres instance
using docker exec command as indicated below:
$ docker exec -it postgres-nest bash
root@9d983793b7b3:/# psql -h localhost -U postgres
psql (13.4 (Debian 13.4-1.pgdg110+1))
Type "help" for help.
postgres=# \list
List of databases
Name | Owner | Encoding | Collate | Ctype | Access P..
---------+--------+----------+------------+------------+------------
postgres |postgres| UTF8 | en_US.utf8 | en_US.utf8 |
template0|postgres| UTF8 | en_US.utf8 | en_US.utf8 |=c/postgres+
| | | | postgres=CTc/pos...
template1|postgres| UTF8 | en_US.utf8 |en_US.utf8. |=c/postgre + | | | | |postgres=CTc/pos...
(3 rows)
- Running pgAdmin docker container
- To download the latest stable version of the image, open a terminal and type the following:
docker pull dpage/pgadmin4:latest
- After downloading the image, we need to run the container making sure that the container connects with the other container running postgres. In order to do so we type the following command:
docker run --name my-pgadmin -p 55550:80 -e 'PGADMIN_DEFAULT_EMAIL=anand@ar.com' -e 'PGADMIN_DEFAULT_PASSWORD=postgresmaster'-d dpage/pgadmin4
- Accessing pgAdmin
-
You only need to open your favourite browser and type the following url: http://localhost:55550/ so your instance of pgAdmin will show up.
-
To access, type the username and the password you established in the step one, when running the postgres container (if you followed the tutorial the user name is
anand@ar.com
and the password ispostgresmaster
). -
Once you are on the main page, you have to create a connection with the postgres server. In order to do so, just click on
Add New Server
and a new dialog window will show up. There you must fill in 2 mandatory fields:-
As indicated in the following picture, a
Name
to identify the connection to ourPostgreSQL server
must be provided. In our case we have selectednest pg
. You can put anyname here. -
The second required value is
Host name/address
and it is located on the form under the tabConnection
. The value to input is172.17.0.2
in our case. This value can be obtained by using the commanddocker inspect
from the terminal (this command with the-f
option provides us with the networking parameters in JSON format of the containerpostgres-nest
).
-
docker inspect postgres-nest -f “{{json .NetworkSettings.Networks }}”
or
docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' container_name_or_id
the output will be as below:
{“bridge”:{“IPAMConfig”:null,”Links”:null,”Aliases”:null,”NetworkID”:”3893d72cd028eb21a8653ee56290c9aaba8822d16f1453777fb107e5e12afe70",”EndpointID”:”23fce49b0adfcb2ebf307076ae641b57c58e568704826fb1ed74aec86a27eb3f”,”Gateway”:”172.17.0.1",”IPAddress”:”172.17.0.2”,”IPPrefixLen”:16,”IPv6Gateway”:””,”GlobalIPv6Address”:””,”GlobalIPv6PrefixLen”:0,”MacAddress”:”02:42:ac:11:00:04",”DriverOpts”:null}}
- Once filled in the field
Host name/address
, you just need to inputpostgres
for the user field andpostgres
for the password field (if you followed till now).
- Changing
postgres
password
$ docker exec -it postgres-nest bash
root@9d983793b7b3:/# psql -h localhost -U postgres
psql (13.4 (Debian 13.4-1.pgdg110+1))
Type "help" for help.
postgres=# ALTER ROLE postgres WITH PASSWORD 'postgres';
ALTER ROLE
postgres=#
C:\Program Files\PostgreSQL\15\bin>psql -U postgres -p 5433
Password for user postgres:
psql (15.1)
WARNING: Console code page (437) differs from Windows code page (1252)
8-bit characters might not work correctly. See psql reference
page "Notes for Windows users" for details.
Type "help" for help.
postgres=# \list
List of databases
Name | Owner | Encoding | Collate | Ctype | ICU Locale | Locale Provider | Access privileges
-----------+----------+----------+----------------------------+----------------------------+------------+-----------------+-----------------------
postgres | postgres | UTF8 | English_United States.1252 | English_United States.1252 | | libc |
template0 | postgres | UTF8 | English_United States.1252 | English_United States.1252 | | libc | =c/postgres +
| | | | | | | postgres=CTc/postgres
template1 | postgres | UTF8 | English_United States.1252 | English_United States.1252 | | libc | =c/postgres +
| | | | | | | postgres=CTc/postgres
(3 rows)
postgres=#
- Connect to PostgreSQL Database on Linux, Windows
- How to install PostgreSQL on Windows
- Download PostgreSQL
- Class-Validator github
- How to run PostgreSQL & PgAdmin in 3 steps using Docker
- How to run Postgres on Docker part 1
- Active Record vs Data Mapper
- TypeOrm Repository APIs - doc
- Connecting TypeORM with NestJs - official doc
- Understanding object validation with Joi in NestJS
Nest is MIT licensed.