-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit c7e3792
Showing
52 changed files
with
11,659 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
*/node_modules | ||
*/vendor | ||
*/data | ||
*/build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
.idea/ | ||
|
||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
/.env | ||
*.old | ||
/data | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
############################ | ||
# Build api | ||
############################ | ||
FROM golang:1.11.2-alpine3.8 AS apibuilder | ||
RUN apk update && apk add --no-cache git dep | ||
COPY api $GOPATH/src/github.com/alexbrazier/go-url/api | ||
WORKDIR $GOPATH/src/github.com/alexbrazier/go-url/api | ||
|
||
# install the dependencies without checking for go code | ||
RUN dep ensure -vendor-only | ||
|
||
# Build my app | ||
RUN go build -o /go/bin/server | ||
|
||
############################ | ||
# Build frontend | ||
############################ | ||
FROM node:10.14.0-alpine AS frontendbuilder | ||
|
||
COPY frontend /app | ||
WORKDIR /app | ||
|
||
RUN yarn --frozen-lockfile && \ | ||
yarn build | ||
|
||
############################ | ||
# Build actual image | ||
############################ | ||
FROM alpine:3.8 | ||
# Copy our static executable. | ||
COPY --from=apibuilder /go/bin/server /go/bin/server | ||
COPY --from=frontendbuilder /app/build /go/bin/public | ||
WORKDIR /go/bin | ||
# Run the hello binary. | ||
ENTRYPOINT ["/go/bin/server"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2018 Alex Brazier | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
SHELL := /bin/bash | ||
|
||
APP_NAME=go-url | ||
CWD=${shell pwd}/ | ||
API_DIR=$(CWD)/api | ||
FRONTEND_DIR=$(CWD)/frontend | ||
|
||
install: | ||
cd $(API_DIR) && \ | ||
dep ensure && \ | ||
cd $(FRONTEND_DIR) && \ | ||
yarn && \ | ||
cd $(CWD) | ||
|
||
start-api: | ||
cd $(API_DIR) && \ | ||
go run server.go | ||
|
||
start-frontend: | ||
cd $(FRONTEND_DIR) && \ | ||
yarn start | ||
|
||
build-local: | ||
cd $(API_DIR) && go build server.go && \ | ||
cd $(FRONTEND_DIR) && yarn build && \ | ||
cd $(CWD) && \ | ||
|
||
build: | ||
docker build -t $(APP_NAME) . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# Go URL | ||
|
||
A simple URL shortener written in Go with a React frontend and MongoDB database | ||
|
||
# Features | ||
|
||
- Shorten urls based on a user defined key | ||
- Alias a key to point to another short url | ||
- Open multiple pages at once by separating keys with a comma | ||
- Alias a key to point to multiple other keys | ||
- Opensearch integration to provide suggestions directly to browser | ||
- Frontend to view most popular searches and search to find existing links | ||
- Frontend to allow anyone to add and edit links | ||
- Optional authentication using Azure AD | ||
|
||
# Getting Started | ||
|
||
The app uses Makefiles. To build the docker image run `make build`. | ||
|
||
Before starting the app for the first time run `make install`, then: | ||
- To start the api run `make start-api`. | ||
- To start the frontend run `make start-frontend` | ||
|
||
|
||
## Enviroment Configuration | ||
|
||
### Authentication | ||
```bash | ||
# Enable Azure auth or not - if enabled, all other fields must be filled in | ||
ENABLE_AUTH=false | ||
# These come from the Azure AD dashboard | ||
AD_TENANT_ID= | ||
AD_CLIENT_ID= | ||
AD_CLIENT_SECRET= | ||
# Secret session token to store the user sessions | ||
SESSION_TOKEN= | ||
``` | ||
|
||
### Other | ||
```bash | ||
PORT=1323 | ||
DEBUG=false | ||
JSON_LOGS=false | ||
# List of addresses for mongo to connect to, e.g. localhost:27017,other | ||
MONGO_ADDRESSES=localhost | ||
MONGO_DATABASE=go | ||
MONGO_USER= | ||
MONGO_PASS= | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
0.0.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
## Go ### | ||
# Binaries for programs and plugins | ||
*.exe | ||
*.dll | ||
*.so | ||
*.dylib | ||
|
||
# Test binary, build with `go test -c` | ||
*.test | ||
|
||
# Output of the go coverage tool, specifically when used with LiteIDE | ||
*.out | ||
|
||
# Project-local glide cache, RE: https://github.com/Masterminds/glide/issues/736 | ||
.glide/ | ||
/vendor | ||
|
||
/data | ||
server |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.