This project was created to try CRUD operations.
The directory structure of project is following:
.
├── src
│ ├── constants
│ │ └── index.js
│ ├── controllers
│ │ └── user.controller.js
│ ├── db
│ │ └── index.js
│ ├── middlewares
│ │ └── error.middleware.js
│ ├── routes
│ │ └── user.route.js
│ └── index.js
├── package-lock.json
├── package.json
└── server.js
6 directories, 9 files
Use the package manager npm to install dependencies. In the project directory:
npm install
The content of .env file is following:
DB_USER = <database_username>
DB_HOST = <database_host>
DB_NAME = <database_name>
DB_PASS = <database_password>
DB_PORT = <database_port_number>
SERVER_PORT = <project_port_number>
PostgreSql must be ready before the project is started.
A table named users
is used. You can create a table on postgres database using following query:
CREATE TABLE users (
ID SERIAL PRIMARY KEY,
name VARCHAR(30),
email VARCHAR(30)
);
To run the project:
npm start