This project is a backend API developed with TypeScript, Node.js, Express, and PostgreSQL. The application includes database seeding, environment-specific configurations, and robust testing with Jest. It demonstrates best practices in backend development, type safety, and database management.
Note: Due to NDA restrictions, the
.env
files, test data, and seed generation files have been excluded from the repository and cannot be shared.
- Database Integration: Built with PostgreSQL, ensuring efficient and secure data handling.
- TypeScript Migration: Transitioned the project from JavaScript to TypeScript for enhanced type safety and maintainability.
- Seeding and Automation: Includes a streamlined database seeding process using
pg-format
and automated workflows withpsql
. - Testing: Comprehensive tests written in Jest, ensuring functionality and reliability.
- Environment-Specific Configuration: Utilizes
dotenv
for secure and adaptable environment setups. - Error Handling: Detailed and robust error handling for better debugging and production stability.
Ensure you have the following installed on your machine:
- Node.js (v18 or later)
- PostgreSQL (v13 or later)
- npm or yarn
- TypeScript (globally installed, optional)
-
Clone the repository:
git clone https://github.com/munaciella/data-analytics-api cd data-analytics-api
-
Install dependencies:
npm install
-
Create environment files:
Create.env.development
,.env.test
, and.env.production
files in the project root, based on your environments. The.env
files are not included in the repository. -
Database Setup:
- Ensure PostgreSQL is running.
- Create a new database:
createdb ultimate_hero
- Update the
.env
file with your database credentials.
-
Run database migrations:
psql -d ultimate_hero -f ./migrations/<migration_file.sql>
-
Seed the database:
npm run seed
To start the development server:
npm run dev
To build and run the production server:
npm run build
npm start
Run tests with:
npm run test
Testing is implemented using Jest, with a focus on unit and integration tests.
src/
├── db/
│ ├── data/ # Data files (excluded in .gitignore)
│ ├── migrations/ # SQL migration files
│ ├── seeds/ # Seed scripts
│ ├── connection.ts # Database connection setup
├── routes/ # Express routes
├── controllers/ # Request handlers
├── services/ # Business logic
├── tests/ # Jest test files
├── types/ # TypeScript type definitions
├── app.ts # Express application entry point
- The
.env
files, test data, and seed generation files are excluded for security and confidentiality reasons. - Follow the documented environment setup steps to configure and use the application locally.
This project is licensed under the MIT License.