-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from yazilimcimekani/rewrite/golang
Golang Rewrite
- Loading branch information
Showing
20 changed files
with
255 additions
and
1,021 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,29 @@ | ||
name: Continuous Integration | ||
run-name: CI | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
- ci | ||
pull_request: | ||
branches: | ||
- main | ||
workflow_dispatch: | ||
|
||
jobs: | ||
ci: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
- name: Setup Go | ||
uses: actions/setup-go@v4 | ||
with: | ||
go-version: '>=1.21.4' | ||
- name: Setup Staticcheck | ||
uses: dominikh/[email protected] | ||
with: | ||
version: "2023.1.6" | ||
install-go: false | ||
min-go-version: "1.21.4" |
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 |
---|---|---|
@@ -1,130 +1,26 @@ | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
lerna-debug.log* | ||
.pnpm-debug.log* | ||
|
||
# Diagnostic reports (https://nodejs.org/api/report.html) | ||
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json | ||
|
||
# Runtime data | ||
pids | ||
*.pid | ||
*.seed | ||
*.pid.lock | ||
|
||
# Directory for instrumented libs generated by jscoverage/JSCover | ||
lib-cov | ||
|
||
# Coverage directory used by tools like istanbul | ||
coverage | ||
*.lcov | ||
|
||
# nyc test coverage | ||
.nyc_output | ||
|
||
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) | ||
.grunt | ||
|
||
# Bower dependency directory (https://bower.io/) | ||
bower_components | ||
|
||
# node-waf configuration | ||
.lock-wscript | ||
|
||
# Compiled binary addons (https://nodejs.org/api/addons.html) | ||
build/Release | ||
|
||
# Dependency directories | ||
node_modules/ | ||
jspm_packages/ | ||
|
||
# Snowpack dependency directory (https://snowpack.dev/) | ||
web_modules/ | ||
|
||
# TypeScript cache | ||
*.tsbuildinfo | ||
|
||
# Optional npm cache directory | ||
.npm | ||
|
||
# Optional eslint cache | ||
.eslintcache | ||
|
||
# Optional stylelint cache | ||
.stylelintcache | ||
|
||
# Microbundle cache | ||
.rpt2_cache/ | ||
.rts2_cache_cjs/ | ||
.rts2_cache_es/ | ||
.rts2_cache_umd/ | ||
|
||
# Optional REPL history | ||
.node_repl_history | ||
|
||
# Output of 'npm pack' | ||
*.tgz | ||
|
||
# Yarn Integrity file | ||
.yarn-integrity | ||
|
||
# dotenv environment variable files | ||
# If you prefer the allow list template instead of the deny list, see community template: | ||
# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore | ||
# | ||
# Binaries for programs and plugins | ||
*.exe | ||
*.exe~ | ||
*.dll | ||
*.so | ||
*.dylib | ||
|
||
# Environment variables | ||
.env | ||
.env.development.local | ||
.env.test.local | ||
.env.production.local | ||
.env.local | ||
|
||
# parcel-bundler cache (https://parceljs.org/) | ||
.cache | ||
.parcel-cache | ||
|
||
# Next.js build output | ||
.next | ||
out | ||
|
||
# Nuxt.js build / generate output | ||
.nuxt | ||
dist | ||
|
||
# Gatsby files | ||
.cache/ | ||
# Comment in the public line in if your project uses Gatsby and not Next.js | ||
# https://nextjs.org/blog/next-9-1#public-directory-support | ||
# public | ||
|
||
# vuepress build output | ||
.vuepress/dist | ||
|
||
# vuepress v2.x temp and cache directory | ||
.temp | ||
.cache | ||
|
||
# Docusaurus cache and generated files | ||
.docusaurus | ||
|
||
# Serverless directories | ||
.serverless/ | ||
|
||
# FuseBox cache | ||
.fusebox/ | ||
production.env | ||
prod.env | ||
|
||
# DynamoDB Local files | ||
.dynamodb/ | ||
# Test binary, built with `go test -c` | ||
*.test | ||
|
||
# TernJS port file | ||
.tern-port | ||
# Output of the go coverage tool, specifically when used with LiteIDE | ||
*.out | ||
|
||
# Stores VSCode versions used for testing VSCode extensions | ||
.vscode-test | ||
# Dependency directories (remove the comment below to include it) | ||
# vendor/ | ||
|
||
# yarn v2 | ||
.yarn/cache | ||
.yarn/unplugged | ||
.yarn/build-state.yml | ||
.yarn/install-state.gz | ||
.pnp.* | ||
# Go workspace file | ||
go.work |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,5 @@ | ||
module github.com/yazilimcimekani/mdoctor-server | ||
|
||
go 1.21.4 | ||
|
||
require github.com/joho/godotenv v1.5.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,2 @@ | ||
github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0= | ||
github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4= |
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 |
---|---|---|
@@ -1,20 +1,14 @@ | ||
set shell := ["powershell.exe", "-c"] | ||
|
||
readme: | ||
@just -l | ||
|
||
install: | ||
@yarn | ||
tidy: | ||
@go mod tidy | ||
|
||
build: install | ||
if (Test-Path -Path dist) { rmdir dist } | ||
@yarn tsc | ||
@mkdir dist/public | ||
@cp -r public/* dist/public | ||
run: | ||
@go run main.go | ||
|
||
dev: | ||
@start http://localhost:3000 | ||
@yarn dev | ||
build: | ||
@go build main.go | ||
|
||
start: | ||
@yarn start | ||
clean: | ||
if [ -e main ]; then rm main; fi |
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 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"log" | ||
"net/http" | ||
|
||
"github.com/joho/godotenv" | ||
"github.com/yazilimcimekani/mdoctor-server/pkg/controllers" | ||
"github.com/yazilimcimekani/mdoctor-server/pkg/env" | ||
) | ||
|
||
func main() { | ||
// Load the .env file | ||
envErr := godotenv.Load() | ||
if envErr != nil { | ||
log.Fatal("Error loading .env file") | ||
} | ||
port := env.GetEnv("PORT", "8080") | ||
|
||
// Define the handlers | ||
http.Handle("/public/", http.StripPrefix("/public/", http.FileServer(http.Dir("public")))) | ||
http.HandleFunc("/markdown", controllers.Markdown()) | ||
|
||
// Start the server on given port | ||
startMessage := fmt.Sprintf("Server started on http://localhost:%s", port) | ||
log.Println(startMessage) | ||
log.Fatal(http.ListenAndServe(fmt.Sprintf(":%s", port), nil)) | ||
} |
This file was deleted.
Oops, something went wrong.
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,18 @@ | ||
package controllers | ||
|
||
import ( | ||
"fmt" | ||
"net/http" | ||
|
||
"github.com/yazilimcimekani/mdoctor-server/pkg/mdtohtml" | ||
) | ||
|
||
func Markdown() func(w http.ResponseWriter, r *http.Request) { | ||
const mdTemplatePath = "views/md.html" | ||
var html string = mdtohtml.LoadFile(mdTemplatePath) | ||
fullHTML := fmt.Sprintf(html, mdtohtml.MarkdownToHtml("# Hello World\nSa\n# Hello\n###### Hellooooooooo i am a h6\nAnd i'm a normal text\n")) | ||
|
||
return func(w http.ResponseWriter, r *http.Request) { | ||
w.Write([]byte(fullHTML)) | ||
} | ||
} |
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 @@ | ||
package env | ||
|
||
import "os" | ||
|
||
func GetEnv(key string, defaultValue string) string { | ||
if os.Getenv(key) == "" { | ||
return defaultValue | ||
} | ||
return os.Getenv(key) | ||
} |
Oops, something went wrong.