Browse Source

Fix #7

dependabot/npm_and_yarn/web/prismjs-1.21.0
Schmitt, Max 8 years ago
parent
commit
51cbfad078
  1. 4
      .vscode/settings.json
  2. 28
      README.md
  3. BIN
      build/schema.md
  4. 30
      config/config.go

4
.vscode/settings.json

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

28
README.md

@ -31,17 +31,13 @@ TODO
## Configuration ## 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 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:
The config parameters should be really selfexplaning, but here is a detailed description for all of these:
TODO: Add config parameters
## OAuth ## OAuth
### Google ### 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 ## 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 - application/x-www-form-urlencoded
- multipart/form-data - 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) ### [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 ## 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 - React
- Makefiles - Makefiles
- Travis CI - 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

Binary file not shown.

30
config/config.go

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

Loading…
Cancel
Save