This application serves up a front-end, written in Vue.js, and a backend written in Node.js using the Serverless Framework. It allows you to see the latest UK news and filter articles by keywords.
Use the latest Node version as it's recommended.
On Mac, you can use [Homebrew] to get nvm to manage your version & yarn
for packages, then:
nvm install node
nvm use node
For other OSes, the installation tools are in the links fornvm
andyarn
above
- To run the backend service - written using the Serverless framework:
- If you haven't installed the serverless CLI tool, do so by using a package manager, like this:
npm install serverless -g
cd news-service
- set up your API key in the
.env
fileNEWS_API_KEY={{ your api key }}
yarn install
- Run
sls offline start --stage dev
- If you haven't installed the serverless CLI tool, do so by using a package manager, like this:
- To run the front-end app - written in VueJS:
cd news-app
- In
news-app
-.env
:NODE_ENV=dev VUE_APP_SERVICE_URL=http://localhost:3000/ VUE_APP_SERVICE_KEY={{ TBA API key for serverless when closer to deploy }}
yarn install
- Run
yarn serve
The key dependencies used are the news-api
module which allows us to fetch news from NewsAPI.org on our backend, axios
& Vuetify on front-end for fetching data and components respectively.
In news-app
front-end: App.vue
renders different views (in src/views
) through the router, and pulls in data from the backend endpoint to load each into its own article componenet (src/components/Article.vue
). The main view is src/views/Home.vue
Wanted to add articles to the store, or filtering options, but didn't have the time
In news-service
backend:
serverless.yml
defines how the endpoints will be declared for the provider, as well as doing some basic request validation / handling. Written in the context of an AWS Lambda service, as that can be easily deployed, basically free and is still scalablehandler.js
contains AWS-specific event handler logicnewsapi.js
contains "business" / user-focused logictest-data.js
is meant for mocking the API for testing, but we didn't have time for that yet
Both apps have Jest set up for testing in /tests
, and use ESLint & Prettier for code formatting. The front-end app has Cypress set up for E2E, but no E2E test has been written yet