diff --git a/.golangci.yml b/.golangci.yml
index 46bf5c5..68ef2c2 100644
--- a/.golangci.yml
+++ b/.golangci.yml
@@ -8,7 +8,6 @@ linters:
- metalinter
- module
- performance
- - sql
- style
- test
- unused
@@ -28,8 +27,6 @@ linters:
- wrapcheck
linters-settings:
- errcheck:
- ignore: "database/sql:Rollback"
gci:
local-prefixes: github.com/dstotijn/hetty
godot:
diff --git a/Dockerfile b/Dockerfile
index 4438028..79055cc 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -2,7 +2,7 @@ ARG GO_VERSION=1.16
ARG NODE_VERSION=14.11
ARG ALPINE_VERSION=3.12
-ARG CGO_ENABLED=1
+ARG CGO_ENABLED=0
FROM node:${NODE_VERSION}-alpine AS node-builder
WORKDIR /app
diff --git a/Makefile b/Makefile
index c86d914..7b0cd7f 100644
--- a/Makefile
+++ b/Makefile
@@ -7,7 +7,7 @@ build-admin:
.PHONY: build
build: build-admin
- CGO_ENABLED=1 mv admin/dist cmd/hetty/admin && go build ./cmd/hetty
+ CGO_ENABLED=0 mv admin/dist cmd/hetty/admin && go build ./cmd/hetty
.PHONY: release-dry-run
release-dry-run: build-admin
diff --git a/README.md b/README.md
index d965d54..a4f6621 100644
--- a/README.md
+++ b/README.md
@@ -33,7 +33,7 @@ for details.
## Installation
-Hetty compiles to a self-contained binary, with an embedded SQLite database
+Hetty compiles to a self-contained binary, with an embedded BadgerDB database
and web based admin interface.
### Install pre-built release (recommended)
@@ -47,11 +47,10 @@ and web based admin interface.
- [Go 1.16](https://golang.org/)
- [Yarn](https://yarnpkg.com/)
-Hetty depends on SQLite (via [mattn/go-sqlite3](https://github.com/mattn/go-sqlite3))
-and needs `cgo` to compile. Additionally, the static resources for the admin interface
+When building from source, the static resources for the admin interface
(Next.js) need to be generated via [Yarn](https://yarnpkg.com/). The generated
-files will be embedded (using the [embed](https://golang.org/pkg/embed/) package)
-when you use the `build` Makefile target.
+files will be embedded (using the [embed](https://golang.org/pkg/embed/)
+package) when you use the `build` Makefile target.
Clone the repository and use the `build` make target to create a binary:
@@ -64,7 +63,7 @@ $ make build
### Docker
A Docker image is available on Docker Hub: [`dstotijn/hetty`](https://hub.docker.com/r/dstotijn/hetty).
-For persistent storage of CA certificates and project databases, mount a volume:
+For persistent storage of CA certificates and projects database, mount a volume:
```
$ mkdir -p $HOME/.hetty
@@ -77,7 +76,7 @@ When Hetty is run, by default it listens on `:8080` and is accessible via
http://localhost:8080. Depending on incoming HTTP requests, it either acts as a
MITM proxy, or it serves the API and web interface.
-By default, project database files and CA certificates are stored in a `.hetty`
+By default, the projects database files and CA certificates are stored in a `.hetty`
directory under the user's home directory (`$HOME` on Linux/macOS, `%USERPROFILE%`
on Windows).
@@ -101,8 +100,8 @@ Usage of ./hetty:
CA certificate filepath. Creates a new CA certificate if file doesn't exist (default "~/.hetty/hetty_cert.pem")
-key string
CA private key filepath. Creates a new CA private key if file doesn't exist (default "~/.hetty/hetty_key.pem")
- -projects string
- Projects directory path (default "~/.hetty/projects")
+ -db string
+ Database directory path (default "~/.hetty/db")
```
You should see:
diff --git a/admin/src/components/projects/NewProject.tsx b/admin/src/components/projects/NewProject.tsx
index 1b762ca..8c0a793 100644
--- a/admin/src/components/projects/NewProject.tsx
+++ b/admin/src/components/projects/NewProject.tsx
@@ -24,9 +24,19 @@ const useStyles = makeStyles((theme: Theme) =>
})
);
+const CREATE_PROJECT = gql`
+ mutation CreateProject($name: String!) {
+ createProject(name: $name) {
+ id
+ name
+ }
+ }
+`;
+
const OPEN_PROJECT = gql`
- mutation OpenProject($name: String!) {
- openProject(name: $name) {
+ mutation OpenProject($id: ID!) {
+ openProject(id: $id) {
+ id
name
isActive
}
@@ -37,8 +47,15 @@ function NewProject(): JSX.Element {
const classes = useStyles();
const [input, setInput] = useState(null);
- const [openProject, { error, loading }] = useMutation(OPEN_PROJECT, {
- onError: () => {},
+ const [createProject, { error: createProjErr, loading: createProjLoading }] = useMutation(CREATE_PROJECT, {
+ onError: () => { },
+ onCompleted(data) {
+ input.value = "";
+ openProject({ variables: { id: data.createProject.id } });
+ },
+ });
+ const [openProject, { error: openProjErr, loading: openProjLoading }] = useMutation(OPEN_PROJECT, {
+ onError: () => { },
onCompleted() {
input.value = "";
},
@@ -47,10 +64,11 @@ function NewProject(): JSX.Element {
fields: {
activeProject() {
const activeProjRef = cache.writeFragment({
- id: openProject.name,
+ id: openProject.id,
data: openProject,
fragment: gql`
fragment ActiveProject on Project {
+ id
name
isActive
type
@@ -61,10 +79,11 @@ function NewProject(): JSX.Element {
},
projects(_, { DELETE }) {
cache.writeFragment({
- id: openProject.name,
+ id: openProject.id,
data: openProject,
fragment: gql`
fragment OpenProject on Project {
+ id
name
isActive
type
@@ -78,9 +97,9 @@ function NewProject(): JSX.Element {
},
});
- const handleNewProjectForm = (e: React.SyntheticEvent) => {
+ const handleCreateAndOpenProjectForm = (e: React.SyntheticEvent) => {
e.preventDefault();
- openProject({ variables: { name: input.value } });
+ createProject({ variables: { name: input.value } });
};
return (
@@ -88,7 +107,7 @@ function NewProject(): JSX.Element {