A RESTful API for accessing the Northcoders News backend data.
The available endpoints are shown here.
The data is stored in a PSQL database. The database Interactions are carried out using Knex.
Requires a local running PSQL instance.
- Clone this repo:
git clone https://github.com/UpEight/be-nc-news
cd be-nc-news
- Install the dependencies:
npm install
- Create the following
knexfile.js
in your root directory:
const { DB_URL } = process.env;
const ENV = process.env.NODE_ENV || 'development';
const baseConfig = {
client: 'pg',
migrations: {
directory: './db/migrations'
},
seeds: {
directory: './db/seeds'
}
};
const customConfig = {
development: {
connection: {
database: 'nc_news'
user : 'your_database_user',
password : 'your_database_password',
}
},
test: {
connection: {
database: 'nc_news_test'
user : 'your_database_user',
password : 'your_database_password',
}
},
production: {
connection: `${DB_URL}?ssl=true`
}
};
module.exports = { ...customConfig[ENV], ...baseConfig };
- Create the test and development databases:
npm run setup-dbs
- Seed the databases:
npm run seed // seeds the development db
npm run seed-test // seeds the test db
- Start your local server:
npm start
Run the unit tests:
npm test
Run the utility function tests:
npm run test-utils