Categorygithub.com/borosr/qa-site
modulepackage
0.0.0-20220323003750-59b6e811cc21
Repository: https://github.com/borosr/qa-site.git
Documentation: pkg.go.dev

# README

QA site

A test project to try out CockroachDB

Requirements

  • Go 1.17 or higher
  • Docker or pre-installed cockroachdb

Start project (locally)

cd infrastructure/local
./start.sh
cd ../..
go run main.go

Settings

For custom configuration change settings.json, following options are available:

NameTypeDescription
DBConnectionStringstringDatabase connection string to connect to CockroachDB
PortstringPort to listen for the HTTP server
JwtHMACstringJWT token's HMAC key
JwtSecretstringJWT token secret, can be any random string
RevokeHMACstringRevoke token's HMAC key
RevokeSecretstringRevoke token's secret, can be any random string
HostnamestringHostname of the instance
BadgerPathstringPath for the BadgerDB data files
VisibilitystringVisibility defines who can read the questions and answers, can be public or private. Public means, no need for authentication to read Q&A. Private requires authentication to read Q&A. Default value is private.

Api docs

MethodPathRequestResponse
GET/api/statusnoneStatus 200, {"status":"ok"}
GET/api/infononeStatus 200, {"visibility":"private","oauth_providers":{"github": false}}
POST/api/users{"username":"user","password":"secret","full_name":"Sir John"}Status 200,{"Msg":"user successfully created"}
POST/api/login{"username":"user","password":"secret"}Status 200, {"token":"jwtToken","revoke_token":"revoke token","auth_kind":"DefaultLogin"}
GET/api/login/githubnoneStatus 301
GET/api/login/github/callback?code=the_code_from_githubStatus 200, {"token":"jwtToken","revoke_token":"revoke token","auth_kind":"Github"}
GET/api/usersnoneStatus 200, [{"id":"user_id","username":"user","full_name":"Sir John"}]
GET/api/users/{user_id}noneStatus 200, {"id":"user_id","username":"user","full_name":"Sir John"}
PUT/api/users/{user_id}{"username":"user","password":"secret2","full_name":"Sir John"}Status 200, {"username":"user","password":"secret2","full_name":"Sir John"}
DELETE/api/users/{user_id}noneStatus 200, {"Msg":"success"}
GET/api/questions?limit=10&offset=0&sort=created_atStatus 200, {"count":1,data":[{"id":"question_id","title":"short_teext","description":"long_text","created_by":"user_id","created_at":"2021-01-01T00:00:00.0Z","status":"published","rating":10}]}
GET/api/questions/{question_id}noneStatus 200, {"id":"question_id","title":"short_teext","description":"long_text","created_by":"user_id","created_at":"2021-01-01T00:00:00.0Z","status":"published","rating":10}
DELETE/api/questions/{question_id}noneStatus 200, {"Msg":"OK"}
POST/api/questions{"title":"short_text","description":"long_text"}Status 200, {"id":"question_id","title":"short_teext","description":"long_text","created_by":"user_id","created_at":"2021-01-01T00:00:00.0Z","status":"published","rating":0}
PUT/api/questions/{question_id}{"title":"new_short_text","description":"new_long_text"}Status 200, {"id":"question_id","title":"new_short_teext","description":"new_long_text","created_by":"user_id","created_at":"2021-01-01T00:00:00.0Z","status":"published","rating":0}
GET/api/questions/{question_id}/answersnoneStatus 200, [{"id":"answer_id","question_id":"question_id","created_by":"user_id","answer":"text","created_at":"2021-01-01T00:00:00.0Z","answered":false,"rating":0}]
PUT/api/questions/{question_id}/answers/{answer_id}/answerednoneStatus 200, {"id":"answer_id","question_id":"question_id","created_by":"user_id","answer":"text","created_at":"2021-01-01T00:00:00.0Z","answered":true,"rating":0}
GET/api/answersnoneStatus 200, [{"id":"answer_id","question_id":"question_id","created_by":"user_id","answer":"text","created_at":"2021-01-01T00:00:00.0Z","answered":true,"rating":0}]
POST/api/answers{"question_id":"question_id",answer":"text"}Status 200, {"id":"answer_id","question_id":"question_id","created_by":"user_id","answer":"text","created_at":"2021-01-01T00:00:00.0Z","answered":true,"rating":0}
PUT/api/answers/{answer_id}{"answer":"text"}Status 200, {"id":"answer_id","question_id":"question_id","created_by":"user_id","answer":"text","created_at":"2021-01-01T00:00:00.0Z","answered":true,"rating":0}
PUT/api/answers/{answer_id}/ratenoneStatus 200, {"value":1}
PUT/api/answers/{answer_id}/unratenoneStatus 200, {"value":-1}
PUT/api/answers/{answer_id}/rate/dismissnoneStatus 200, {"value":0}
PUT/api/questions/{question_id}/ratenoneStatus 200, {"value":1}
PUT/api/questions/{question_id}/unratenoneStatus 200, {"value":-1}
PUT/api/questions/{question_id}/rate/dismissnoneStatus 200, {"value":0}
DELETE/api/logoutnoneStatus 200, {"Msg":"Logout success"}
POST/api/revoke{"revoke_token":"revoke token"}Status 200, {"token":"jwtToken","revoke_token":"revoke token","auth_kind":"DefaultLogin"}

# Packages

No description provided by the author