-
.env.development Create a .env.development file in your project folder and add the followings: PGDATABASE=nc_news This connects your application to the main development database
-
.env.test Create a .env.test file in the same directory and add PGDATABASE=nc_news_test This ensures your tests run against a separate test database called nc_news_test, so your development data remains unaffected.
behnoud-news-api is a backend API for a news platform, built with Node.js, Express, and PostgreSQL. It serves articles, comments, users, and more through RESTful endpoints, including features like comment counts on articles.
The API is hosted online and accessible at:
https://behnoud-news-api.onrender.com
Create a .env.development
file in your project root with the following content:
This connects your app to the local development database.
Create a .env.test
file in your project root with:
This configures the app to use a separate test database during automated testing, preventing interference with your development data.
For production, create a .env.production
file with your production database URL from Supabase:
DATABASE_URL=postgresql://username:password@host:port/database NODE_ENV=production
git clone https://github.com/your-username/behnoud-news-api.git cd behnoud-news-api
npm install
Create your local databases (nc_news and nc_news_test) in PostgreSQL, then run:
npm run setup-dbs
npm run seed-dev
npm test
Start the development server:
npm run dev
This project is deployed on Render with the database hosted on Supabase. Environment variables for production are set via Render’s dashboard.
Feel free to explore the API and contribute! For any questions or issues, please open an issue on GitHub.