- Ctrl+Shift+P, settings => select Preferences: Open Settings (UI)
- select Workspace (creates a .vscode folder to root root folder "Siba")
- look for: rest client
- select rest client environment variables
- Creates Write to that settings.json:
{
"rest-client.environmentVariables": {
"$shared": {
}
}
}
- create a folder .vscode to the root root folder, the folder where you have Siba_be and siba-fe folders - if none yet
- create there settings.json - if none yet
- Then make it look like this:
{
"rest-client.environmentVariables": {
"$shared": {
"host":"http://localhost:1234/api"
},
"adminEnv": {
"token":"fasdflöjaösdlfkjöasdlkjf",
},
"plannerEnv": {
"token":"asdfasjdflöakjsdfölajsdf",
},
"statistEnv": {
"token":"asdfasdjfölasdkjfölasj",
}
}
}
Well, the tokens you get by logging in as respective role user. See the Logins.rest.
-
Then you can switch between different environments simply from lower right corner, when .rest file is open in VS Code
-
Then we create one file per database table. And in that file have at least C,R,U,D,L test cases, in the order: LRCUD, same order as the route file
Rest Client plugin can be used in VS Code to make requests in the running backend instead of Postman, which is convenient for developers to test apis. At first, install REST Client plugin in VS Code through extensions
- Create a folder for example request in the root of your backend project
mkdir request- Change your directory to the request folder
cd request- Create a file for example subject.rest Note: file extention should be .rest
touch subject.rest- Now you can write your requests inside the file subject.rest
You can follow these examples below:
Note: You need to seperate each next requests with ### to have more than one request in one file
Get all subjects
GET http://localhost:1234/api/subject
Authorization: Basic <put your token here>Get subject by id
GET http://localhost:1234/api/subject/<put subject id here>
Authorization: Basic <put your token here>Create subject
POST http://localhost:1234/api/subject
Authorization: Basic <put your token here>
Content-Type: application/json
{
"name": "Data structures",
"groupSize": 25,
"groupCount": 2,
"sessionLength": "02:30:00",
"sessionCount": 2,
"area": 35,
"programId": 3030,
"programName": "Avoin Kampus",
"spaceTypeId": 5002,
"spaceTypeName": "Luentoluokka"
}Update subject
PUT http://localhost:1234/api/subject
Authorization: Basic <put your token here>
Content-Type: application/json
{
"id": 4042,
"name": "Data structures and algorithm",
"groupSize": 25,
"groupCount": 2,
"sessionLength": "02:30:00",
"sessionCount": 2,
"area": 35,
"programId": 3030,
"programName": "Avoin Kampus",
"spaceTypeId": 5002,
"spaceTypeName": "Luentoluokka"
}Remove subject
DELETE http://localhost:1234/api/subject/<put subject id here>
Authorization: Basic <put your token here>For detail info, please visit here and here
Enjoy!!