This commit is contained in:
Schmitt, Max 2017-11-09 09:30:15 +01:00
parent 0ef906984b
commit 51cbfad078
4 changed files with 34 additions and 30 deletions

View File

@ -1,3 +1 @@
{
"prettier.singleQuote": true
}
{}

View File

@ -31,17 +31,13 @@ TODO
## Configuration
The configuration is a JSON file, an example is located [here](build/config.json). If your editor supports intellisense by using a schema (e.g. [VS Code](https://github.com/Microsoft/vscode)) then you can simply press space for auto completion.
The config parameters should be really selfexplaning, but here is a detailed description for all of these:
TODO: Add config parameters
The configuration is a JSON file, an example is located [here](build/config.json). If your editor supports intellisense by using a schema (e.g. [VS Code](https://github.com/Microsoft/vscode)) then you can simply press space for auto completion. The config parameters should be really selfexplaning, but [here](build/schema.md) is a detailed description for all of these:
## OAuth
### Google
Visit [console.cloud.google.com](https://console.cloud.google.com) and create or use an existing project, goto `APIs & Services` -> `Credentials` and create there an `OAuth Client-ID` for the application type `Webapplicaton`. There you get the Client-ID and the ClientSecret for your configuration. It's important, that you set in the Google Cloud Platform `YOUR_URL/api/v1/callback` as authorized redirect URL.
Visit [console.cloud.google.com](https://console.cloud.google.com) and create or use an existing project, go to `APIs & Services` -> `Credentials` and create there an `OAuth Client-ID` for the application type `Webapplicaton`. There you get the Client-ID and the ClientSecret for your configuration. It's important, that you set in the Google Cloud Platform `YOUR_URL/api/v1/callback` as authorized redirect URL.
## Clients
@ -53,18 +49,30 @@ In general the `POST` endpoints can be called, by using one of the following tec
- application/x-www-form-urlencoded
- multipart/form-data
For all the endpoints which have `protected` in her path there is the `Authorization` header required.
For all the endpoints which are on `/api/v1/protected` there is the `Authorization` header required.
### [ShareX](https://github.com/ShareX/ShareX)
For ShareX usage, we refer to the menu item in the frontend where your configuration will be generated. There are further information for the detailled use.
For ShareX usage, we refer to the menu item in the frontend where your configuration will be generated. There are further information for the detailed use.
## Why did you built this
Just only because I want to extend my current self hosted URL shorter and learn about new techniques like:
Just only because I want to extend my current self hosted URL shorter with some features and learn about new techniques like:
- Golang unit tests
- Golang unit testing
- React
- Makefiles
- Travis CI
- Key / Value databases
- Key / Value databases
## Utils
### Update Config Documentation
```
yarn global add jsonschema-md
go run build/schema.go
jsonschema-md.cmd build/schema.json > build/schema.md
```
After that adjust the title to `Configuration` and the description to `Golang URL Shortener Configuration`.

BIN
build/schema.md Normal file

Binary file not shown.

View File

@ -12,33 +12,31 @@ import (
// Configuration holds all the needed parameters use
// the URL Shortener
type Configuration struct {
Schema string `json:"$schema"`
Store Store
Handlers Handlers
Schema string `json:"$schema"`
Store Store `description:"Store holds the configuration values for the storage package"`
Handlers Handlers `description:"Handlers holds the configuration for the handlers package"`
}
// Store contains the needed fields for the Store package
type Store struct {
DBPath string
ShortedIDLength uint
DBPath string `description:"relative or absolute path of your bolt DB"`
ShortedIDLength uint `description:"Length of the random generated ID which is used for new shortened URLs"`
}
// Handlers contains the needed fields for the Handlers package
type Handlers struct {
ListenAddr string
BaseURL string
EnableGinDebugMode bool
Secret []byte
OAuth struct {
ListenAddr string `description:"Consists of 'IP:Port', normally the value ':8080' e.g. is enough"`
BaseURL string `description:"Required for the authentification via OAuth. E.g. 'http://mydomain.com'"`
EnableDebugMode bool `description:"Activates more detailed logging to the stdout"`
Secret []byte `description:"Used for encryption of the JWT and for the CookieJar. Will be randomly generated when it isn't set"`
OAuth struct {
Google struct {
ClientID string
ClientSecret string
}
}
ClientID string `description:"ClientID which you get from console.cloud.google.com"`
ClientSecret string `description:"ClientSecret which get from console.cloud.google.com"`
} `description:"Google holds the OAuth configuration for the Google provider"`
} `description:"OAuth holds the OAuth specific settings"`
}
// config holds the temporary loaded data for the
// singelton Get() method
var config *Configuration
var configPath string