feat: add cli - start server, list packages, purge packages

This commit is contained in:
 Ilya Atamas
2019-04-18 01:14:20 +03:00
parent e8dfb5a945
commit 61dca22a01
11 changed files with 300 additions and 102 deletions

29
main.go
View File

@@ -1,34 +1,9 @@
package main
import (
"net/http"
"time"
npmproxy "github.com/emeralt/npm-cache-proxy/proxy"
"github.com/go-redis/redis"
"github.com/emeralt/npm-cache-proxy/cli"
)
func getOptions() (npmproxy.Options, error) {
return npmproxy.Options{
RedisPrefix: "",
RedisExpireTimeout: 1 * time.Hour,
UpstreamAddress: "http://registry.npmjs.org",
ReplaceAddress: "https://registry.npmjs.org",
StaticServerAddress: "http://localhost:8080",
}, nil
}
func main() {
proxy := npmproxy.Proxy{
RedisClient: redis.NewClient(&redis.Options{}),
HttpClient: &http.Client{
Transport: http.DefaultTransport,
},
GetOptions: getOptions,
}
proxy.Server(npmproxy.ServerOptions{
ListenAddress: "localhost:8080",
}).ListenAndServe()
cli.Run()
}