Git repository for laboradmin backend service
You will need the following things properly installed on your computer.
Clone repository
git clone <repository-url>
Install npm packages
cd szglab5-backend
npm install
Install nodemon (automatic server restart)
npm install nodemon -g
Create database (default is "laboradmin")
psql -U postgres
CREATE DATABASE laboradmin;
Available node environments ('dev' | 'prod' | 'test')
Steps to add specific config:
npm run cli:dev seed test1.seed.json
Starts the API server
npm run start:dev
The endpoints format fit JSON API specification.
Model names in plural (-> modelNamePlural):
{
"data": [
{
"type": "questions",
"id": 4,
"attributes": {
"id": 4,
"text": "tuturu 2",
"createdAt": "2017-03-15T17:07:30.284Z",
"updatedAt": "2017-03-15T17:07:30.284Z",
"testId": 2
},
"relationships": {
"test": {
"data": {
"id": 2,
"type": "tests"
}
}
}
},
{
"type": "questions",
"id": 1,
"attributes": {
"id": 1,
"text": "Kérdés 1",
"createdAt": "2017-03-15T17:07:30.244Z",
"updatedAt": "2017-03-15T17:07:30.244Z",
"testId": null
},
"relationships": {
"test": null
}
},
{
"type": "questions",
"id": 2,
"attributes": {
"id": 2,
"text": "Kérdés 2",
"createdAt": "2017-03-15T17:07:30.261Z",
"updatedAt": "2017-03-15T17:07:30.261Z",
"testId": null
},
"relationships": {
"test": null
}
}
]
}
{
"data": {
"type": "questions",
"id": 2,
"attributes": {
"id": 2,
"text": "Kérdés 2",
"createdAt": "2017-03-15T17:07:30.261Z",
"updatedAt": "2017-03-15T17:07:30.261Z",
"testId": null
},
"relationships": {
"test": null
}
}
}
!Not supported yet!
{
"data": {
"type": "questions",
"attributes": {
"text": "New questiion, yupiii blblblblblb"
},
"relationships": {
"test": {
"data": {
"type": "tests",
"id": 3
}
}
}
}
}
Response:
{
"data": {
"type": "questions",
"id": 8,
"attributes": {
"id": 8,
"text": "New questiion, yupiii blblblblblb",
"updatedAt": "2017-03-16T09:12:29.966Z",
"createdAt": "2017-03-16T09:12:29.956Z",
"testId": 3
}
}
}
{
"data": {
"type": "questions",
"attributes": {
"text": "Change this text!"
},
"relationships": {
"test": {
"data": {
"type": "tests",
"id": 3
}
}
}
}
}
Response: 204 (No Content)