makupi / backend-homework Goto Github PK
View Code? Open in Web Editor NEWhttps://github.com/togglhire/backend-homework
https://github.com/togglhire/backend-homework
Probably two tables, questions
and options
questions
id: pkey, int | body: text |
---|
options
id: pkey, int | body: text | correct: bool | question_id: fkey(questions.id), int |
---|
Use GraphQL instead of REST to implement the API
Define a schema for the API that covers the basic requirements and implement all queries and resolvers. You do not need to implement the REST API if you choose to do this.
Pagination for the list endpoint
This can be in the form of basic offset pagination, or seek pagination. The difference is explained in this post.
Clients are required to send a JSON Web Token that identifies the user in some way. The API returns only questions that belong to the authenticated user. Endpoint for generating tokens is not needed, we can generate them through jwt.io
The PORT environment variable is used as the port number for the server, defaulting to 3000
Endpoint that allows to delete existing questions
Create an interface for the storage and an sqlite implementation
The third endpoint updates an existing question and returns the updated question in the response. The whole question is included in the request body, including all attributes. The question to be updated should be identified in the request URL. The order of options in the request body should be stored the same way as explained in the create endpoint above.
For example, to change the question from before to ask about sunrise, we would send the following JSON.
{
"body": "Where does the sun rise?",
"options": [
{
"body": "East",
"correct": true
},
{
"body": "West",
"correct": false
}
]
}
The first endpoint should return a list of all questions in the database. The order of questions and options inside questions should be stable, i.e. not change on every request. The whole question, including the options is returned.
For example, the response could look like this:
[
{
"body": "Where does the sun set?",
"options": [
{
"body": "East",
"correct": false
},
// other options...
]
},
{
"body": "What is the answer to the ultimate question of life, the universe, and everything?",
// rest of the question...
},
{
"body": "But what is the ultimate question?",
// rest of the question...
}
]
The second endpoint creates a new question in the database and then returns it in the response. The request body contains the question in JSON. The order of options in the request body should be stored as well and the same order should be returned by the API from all requests.
For example, for the request containing the following JSON, the server would return the question show above, in the Questions section.
{
"body": "Where does the sun set?",
"options": [
{
"body": "East",
"correct": false
},
{
"body": "West",
"correct": true
}
]
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.