feat: initial commit

This commit is contained in:
 Ilya Atamas
2019-04-16 15:05:21 +03:00
commit 4dad509dc6
11 changed files with 307 additions and 0 deletions

34
main.go Normal file
View File

@@ -0,0 +1,34 @@
package main
import (
"net/http"
"time"
npmproxy "github.com/emeralt/npm-cache-proxy/proxy"
"github.com/go-redis/redis"
)
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()
}