This is a command-line application to manage a company's employee database, using Node.js, Inquirer, and PostgreSQL. The application is written in TypeScript.
Watch a video demo of the Employee Tracker application in action:
- View all departments, roles, and employees
- Add new departments, roles, and employees
- Update employee roles
- Interactive command-line interface
- Node.js
- TypeScript
- Inquirer
- PostgreSQL
- pg (node-postgres)
- Console.table
- Clone the repository.
- Navigate to the project directory.
- Run
npm installto install the necessary dependencies. - Set up your PostgreSQL database using the provided
schema.sqlandseeds.sqlfiles. - Create a
.envfile in the root directory with your PostgreSQL database credentials:
DB_USER=your_postgres_user
DB_HOST=localhost
DB_DATABASE=employee_tracker_db
DB_PASSWORD=your_postgres_password
DB_PORT=5432
- Navigate to the
dbdirectory:cd db - Run the
schema.sqlscript to create the database and tables:psql -U postgres -f schema.sql - Run the
seeds.sqlscript to populate the database with initial data:psql -U postgres -d employee_tracker_db -f seeds.sql - Navigate back to the project root directory:
cd .. - Compile the TypeScript code to JavaScript:
npm run build - Start the application:
npm start - Follow the prompts to view, add, update, or delete employees, roles, and departments.
npm run build: Compiles the TypeScript code to JavaScript.npm start: Runs the compiled JavaScript code.
The PostgreSQL client configuration is set up to use environment variables from the .env file:
const client = new Client({
user: process.env.DB_USER,
host: process.env.DB_HOST,
database: process.env.DB_DATABASE,
password: process.env.DB_PASSWORD,
port: parseInt(process.env.DB_PORT || '5432', 10),
});Ensure you have a .gitignore file to exclude node_modules, dist, and .env files from version control:
node_modules/
dist/
.env