The Pen Post is a project created for the back-end block of the Northcoders bootcamp and is a web application that is designed to host news articles. This relational database stores articles, comments, topics and users. This project is a Node.js Express application using a RESTful API server to curate data from a postgreSQL database.
Back-end is hosted on Heroku
Front-end was created using React.js and is hosted on Heroku
Github repo for front-end: https://github.com/IkraP/NC-The-Pen-Post
- Node (download here)
- Git (download here)
- PostgreSQL (download here)
- API Testing tool (Insomnia, Postman etc)
- Clone this repository
git clone https://github.com/IkraP/NC-news-api.git
cd
into the repository
cd NC-news-api
- Install all dependencies
npm install
- Create a knexfile.js file in the root directory with the following code:
const ENV = process.env.NODE_ENV || "development";
const { DB_URL } = process.env;
const baseConfig = {
client: "pg",
migrations: {
directory: "./db/migrations",
},
seeds: {
directory: "./db/seeds",
},
};
const customConfig = {
production: {
connection: `${DB_URL}?ssl=true`,
},
development: {
connection: {
database: "nc_news",
// if you are using a Linux, enter your username and password here
// username: 'yourUsername'
// password: 'yourPassword'
},
},
test: {
connection: {
database: "nc_news_test",
// if you are using a Linux, enter your username and password here
// username: 'yourUsername'
// password: 'yourPassword'
},
},
};
module.exports = { ...customConfig[ENV], ...baseConfig };
- Database will require seeding - please follow these steps:
npm run setup-dbs
npm run seed
GET /api/topics
GET /api/users/:username
GET /api/articles/:article_id
PATCH /api/articles/:article_id
POST /api/articles/:article_id/comments
GET /api/articles/:article_id/comments
GET /api/articles
PATCH /api/comments/:comment_id
DELETE /api/comments/:comment_id
GET /api
The-Pen-Post-API has a suite of tests that have been used to check the functionality of endpoints of the server, error handling and any utility functions that were used to seed the data. The scripts are already present in this repository. Please follow the command below to run tests:
npm test
- Express - Node.js web application framework
- Knex - SQL query builder
- PostgreSQL - open source database
- Ikra - Github