- Don't worry if the code does not compile, you can use some pseudocode to help you if you don't remember the syntax, or even comments. The important thing is that we understand what you would do in a real situation. We won't execute it and won't run the tests, so don't worry about that.
- It is preferable to not finish all the endpoints but have a good design than finishing everything on time with bad practices.
- You are free to modify all existing code, they are just examples.
- Please add some automatic tests, at least for the average endpoint. (The important thing is that we know which cases you would test, nothing happens if the tests do not pass).
We have two types of assets, which can be either videos or images.
These assets have the following metadata: ID, type (video or image) and name.
Additionally, each one of these assets can have multiple scores, one for each Score Type (Type1, Type2, Type3). This score can be a number between 0 and 100.
To share these metrics with the rest of the organization, we need to be able to interact with this database and know the average score for each asset type (video, image) for a specific Score Type.
We propose to develop a few endpoints that interact with a database containing these assets.
The endpoints are as follows:
- An endpoint to create assets with scores.
- An endpoint to get the average score for a specific Score Type and a specific asset type. The endpoint receives an asset type (image, video), and a score type (Type1, etc). The endpoint should return the average score for that asset type and score type.
- An endpoint to get the data for an asset. The endpoint receives an asset id and returns the asset data, including all of the asset’s scores.
- Install Node js
- Windows / Mac: https://nodejs.org/en/download/
- Linux:
sudo apt install curl curl -fsSL https://deb.nodesource.com/setup_14.x | sudo -E bash - sudo apt-get install -y nodejs verify installation: node --version npm --version
- Run
npm install
command - Run
npm start
command (The server runs in http://localhost:3333/graphql) - For tests:
npm test
The project is configured to use a sqlite database.
- TypeScript as the language
- TypeORM as the database ORM
- TypeDi as dependency injection container
- Apollo as the graphql server
- Type-graphql as the graphql library
- Mocha as testing framework
- Chai as testing assert framework
- Create asset
mutation {
createAsset {
id
name
}
}
- Get all assets
query {
getAllAssets{
id
name
}
}