-
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 6fab92c
Showing
106 changed files
with
15,610 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,31 @@ | ||
# App port to run on | ||
PORT=8000 | ||
|
||
# The name of the site where Shrug is hosted | ||
SITE_NAME=Shrug | ||
|
||
# The domain that this website is on | ||
DEFAULT_DOMAIN=localhost | ||
API_BASE_URL=localhost | ||
|
||
|
||
# Postgres database credential details | ||
DB_HOST=shrug | ||
DB_PORT=5432 | ||
DB_NAME=shrug | ||
DB_USER=admin | ||
DB_PASSWORD=admin | ||
DB_SSL=false | ||
|
||
# Redis host and port | ||
REDIS_HOST=shrug | ||
REDIS_PORT=6379 | ||
REDIS_PASSWORD= | ||
|
||
# Google auth | ||
GOOGLE_CLIENT_ID=246061441813-0tttd85uuvvqn365hvhns2egj0gfu9gn.apps.googleusercontent.com | ||
|
||
|
||
JWT_SECRET_KEY=mySecretKey | ||
|
||
IP2LOCATION_DB_PATH="./files/IP2LOCATION-LITE-DB11.BIN" |
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,7 @@ | ||
.env | ||
client/node_modules | ||
client/public/dist | ||
**/**/.DS_Store | ||
server/play/ | ||
server/files/* | ||
!server/files/.gitkeep |
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,25 @@ | ||
FROM golang:1.15-alpine as server | ||
WORKDIR /app | ||
COPY ./server . | ||
RUN go mod vendor | ||
RUN go build -mod=vendor -ldflags "-w" -o shrug . | ||
|
||
FROM node:15.0.1 as client | ||
RUN mkdir -p /client | ||
WORKDIR /client | ||
COPY ./client ./ | ||
COPY ./.env ./.. | ||
RUN yarn install | ||
RUN yarn build:prod | ||
|
||
FROM alpine | ||
RUN addgroup -S shrug && adduser -S shrug -G shrug | ||
USER shrug | ||
|
||
WORKDIR /client/public | ||
COPY --from=client /client/public . | ||
|
||
WORKDIR /app | ||
COPY --from=server /app/shrug . | ||
|
||
CMD ["./shrug"] |
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,23 @@ | ||
# Shrug | ||
<p align="center"> | ||
<a href="http://shrug.ir"><img src="./client/public/images/shrug-ir.png" alt="shrug.ir"/></a> | ||
</p> | ||
|
||
Shrug is a fast & open source link shortner writen with Golang and React.JS. For demo check [shrug.ir](http://shrug.ir) | ||
|
||
## Installation | ||
|
||
Copy `.env.example` to `.env` fill dbs credentials | ||
|
||
### Develpment | ||
Then with `make run-server` & `make run-client` you can run server & client. | ||
|
||
### Deployment | ||
By `docker-compose up -d` the project will be up on port `80` which you can change it on `docker-compose.yml`. | ||
|
||
### Screnshots | ||
<p align="center"> | ||
<img style="max-width:700px; display: block;" src="./screenshots/1.png" alt="shrug.ir"/> | ||
<br/> | ||
<img style="max-width:700px; display: block;" src="./screenshots/2.png" alt="shrug.ir"/> | ||
</p> |
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 @@ | ||
{ | ||
"presets": [ | ||
"@babel/preset-react", | ||
"@babel/preset-env" | ||
], | ||
"plugins": [ | ||
"@babel/plugin-proposal-class-properties" | ||
] | ||
} |
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/ | ||
public/dist/ | ||
.env.test | ||
.env.development |
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,8 @@ | ||
{ | ||
"snapshotSerializers": [ | ||
"enzyme-to-json/serializer" | ||
], | ||
"setupFiles": [ | ||
"<rootDir>/src/tests/setupTests.js" | ||
] | ||
} |
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,72 @@ | ||
{ | ||
"name": "boilerplate-react-app", | ||
"version": "1.0.0", | ||
"main": "index.js", | ||
"author": "Andrew Mead", | ||
"license": "MIT", | ||
"scripts": { | ||
"build:dev": "webpack", | ||
"build:prod": "webpack -p --env production", | ||
"dev-server": "webpack-dev-server", | ||
"test": "cross-env NODE_ENV=test jest --config=jest.config.json", | ||
"start": "node server/server.js" | ||
}, | ||
"dependencies": { | ||
"@fortawesome/fontawesome-free": "^5.15.1", | ||
"@fortawesome/fontawesome-svg-core": "^1.2.32", | ||
"@fortawesome/free-brands-svg-icons": "^5.15.1", | ||
"@fortawesome/free-solid-svg-icons": "^5.15.1", | ||
"@fortawesome/react-fontawesome": "^0.1.11", | ||
"axios": "^0.20.0", | ||
"bootstrap": "4.5.3", | ||
"clean-webpack-plugin": "^3.0.0", | ||
"copy-to-clipboard": "^3.3.1", | ||
"css-loader": "0.28.4", | ||
"date-fns": "^2.16.1", | ||
"express": "^4.17.1", | ||
"extract-text-webpack-plugin": "^4.0.0-beta.0", | ||
"font-awesome": "^4.7.0", | ||
"history": "^5.0.0", | ||
"html-webpack-plugin": "^4.5.0", | ||
"moment": "^2.29.1", | ||
"node-sass": "^4.14.1", | ||
"normalize.css": "7.0.0", | ||
"numeral": "2.0.6", | ||
"qrcode.react": "^1.0.0", | ||
"react": "^17.0.1", | ||
"react-addons-shallow-compare": "15.6.0", | ||
"react-dates": "12.3.0", | ||
"react-dom": "^17.0.1", | ||
"react-google-authorize": "^1.0.4", | ||
"react-modal": "2.2.2", | ||
"react-redux": "5.0.5", | ||
"react-router-dom": "4.1.2", | ||
"react-simple-snackbar": "^1.1.10", | ||
"recharts": "^1.8.5", | ||
"redux": "3.7.2", | ||
"redux-mock-store": "1.2.3", | ||
"redux-thunk": "2.2.0", | ||
"sass-loader": "6.0.6", | ||
"style-loader": "0.18.2", | ||
"uuid": "3.1.0", | ||
"validator": "8.0.0" | ||
}, | ||
"devDependencies": { | ||
"@babel/core": "^7.12.9", | ||
"@babel/plugin-proposal-object-rest-spread": "^7.12.1", | ||
"@babel/plugin-syntax-dynamic-import": "^7.8.3", | ||
"@babel/preset-env": "^7.12.7", | ||
"@babel/preset-react": "^7.12.7", | ||
"@babel/preset-typescript": "^7.12.7", | ||
"babel-loader": "^8.2.2", | ||
"cross-env": "5.0.5", | ||
"dotenv": "4.0.0", | ||
"enzyme": "2.9.1", | ||
"enzyme-to-json": "1.5.1", | ||
"jest": "20.0.4", | ||
"react-test-renderer": "17.0.0", | ||
"webpack": "^4.44.2", | ||
"webpack-cli": "^3.3.12", | ||
"webpack-dev-server": "^3.11.0" | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,17 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
|
||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
<title>Shrug url shortener</title> | ||
<link rel="icon" type="image/png" href="/images/shrug-ir-logo.png" /> | ||
<link rel="stylesheet" type="text/css" href="/dist/styles.css" /> | ||
</head> | ||
|
||
<body> | ||
<div id="app"></div> | ||
<script src="/dist/bundle.js"></script> | ||
</body> | ||
|
||
</html> |
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 @@ | ||
# Shrug client |
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,15 @@ | ||
const path = require('path'); | ||
const express = require('express'); | ||
const app = express(); | ||
const publicPath = path.join(__dirname, '..', 'public'); | ||
const port = process.env.PORT || 3000; | ||
|
||
app.use(express.static(publicPath)); | ||
|
||
app.get('*', (req, res) => { | ||
res.sendFile(path.join(publicPath, 'index.html')); | ||
}); | ||
|
||
app.listen(port, () => { | ||
console.log('Server is up!'); | ||
}); |
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,62 @@ | ||
import { loginAPI, getUserAPI } from '../api/authAPI' | ||
import { startGetUrls } from './urls'; | ||
import { getCookie, setCookie, eraseCookie } from '../utils'; | ||
|
||
export const login = ( | ||
{ | ||
email = '', | ||
jwtToken = '' | ||
} | ||
) => ({ | ||
type: 'LOGIN', | ||
email, | ||
jwtToken | ||
}); | ||
|
||
export const startLogin = (accessToken) => { | ||
return (dispatch) => { | ||
loginAPI(accessToken).then((result) => { | ||
setCookie("jwtToken", result.jwtToken, 7) | ||
dispatch(login({ | ||
email: result.email, | ||
jwtToken: result.jwtToken | ||
})) | ||
dispatch(startGetUrls()) | ||
}) | ||
} | ||
} | ||
|
||
export const loadUser = ( | ||
{ | ||
email = '', | ||
jwtToken = '' | ||
} | ||
) => ({ | ||
type: 'LOAD_USER', | ||
email, | ||
jwtToken | ||
}); | ||
|
||
export const startLoadUser = (accessToken) => { | ||
return (dispatch) => { | ||
getUserAPI(accessToken).then((result) => { | ||
dispatch(loadUser({ | ||
email: result.email, | ||
jwtToken: getCookie("jwtToken") | ||
})) | ||
}) | ||
} | ||
} | ||
|
||
|
||
export const logout = () => ({ | ||
type: 'LOGOUT' | ||
}); | ||
|
||
export const startLogout = () => { | ||
return (dispatch) => { | ||
eraseCookie("jwtToken") | ||
dispatch(logout()); | ||
} | ||
} | ||
|
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,10 @@ | ||
|
||
// ADD_DATA | ||
export const addData = (data) => ({ | ||
type: 'ADD_DATA', | ||
data: data | ||
}); | ||
|
||
export const removeQRCode = () => ({ | ||
type: 'REMOVE_QRCODE' | ||
}); |
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,58 @@ | ||
import { getDaysAPI, getBrowsersStatsAPI, getOSStatsAPI, getOverviewStatsAPI } from '../api/urlAPI'; | ||
|
||
// ADD_DAYS | ||
export const addDays = (days) => ({ | ||
type: 'ADD_DAYS', | ||
days: days | ||
}); | ||
|
||
export const startAddDays = (id) => { | ||
return (dispatch) => { | ||
getDaysAPI(id).then((result) => { | ||
dispatch(addDays(result)) | ||
}) | ||
} | ||
} | ||
|
||
export const addBrowsers = (browsers) => ({ | ||
type: 'ADD_BROWSERS', | ||
browsers: browsers | ||
}); | ||
|
||
export const startAddBrowsersStats = (id) => { | ||
return (dispatch) => { | ||
getBrowsersStatsAPI(id).then((result) => { | ||
dispatch(addBrowsers(result)) | ||
}) | ||
} | ||
} | ||
|
||
export const addOS = (os) => ({ | ||
type: 'ADD_OS', | ||
os: os | ||
}); | ||
|
||
export const startAddOSStats = (id) => { | ||
return (dispatch) => { | ||
getOSStatsAPI(id).then((result) => { | ||
dispatch(addOS(result)) | ||
}) | ||
} | ||
} | ||
|
||
export const addOverview = (overview) => ({ | ||
type: 'ADD_OVERVIEW', | ||
overview: overview | ||
}); | ||
|
||
export const startaddOverviewStats = (id) => { | ||
return (dispatch) => { | ||
getOverviewStatsAPI(id).then((result) => { | ||
dispatch(addOverview(result)) | ||
}) | ||
} | ||
} | ||
|
||
export const cleanUpStats = () => ({ | ||
type: 'CLEAN_UP_STATS' | ||
}) |
Oops, something went wrong.